Forum

> > CS2D > Scripts > Multiple freeimages
Forums overviewCS2D overview Scripts overviewLog in to reply

English Multiple freeimages

9 replies
To the start Previous 1 Next To the start

old Multiple freeimages

Alistaire
User Off Offline

Quote
(old title)
Spoiler >


1
2
3
4
5
6
7
8
freeimage(id)
		id=image("gfx/Medieval Mod/Cavalry/Horse.png",1,1,100+id)
		id=image("gfx/Medieval Mod/Cavalry/Horse2.png",1,1,200+id)
		if player(id,"team")==1 then
			id=image("gfx/Medieval Mod/Cavalry/CavalryT.png",1,1,200+id)
		elseif player(id,"team")==2 then
			id=image("gfx/Medieval Mod/Cavalry/CavalryCT.png",1,1,200+id)
		end

The first two images work, the team conditional image doesn't..
edited 3×, last 29.10.11 11:53:39 am

old Re: Multiple freeimages

DC
Admin Off Offline

Quote
you are using the player id ("id" variable) for everything, which is wrong.
the image command returns a unique image id each time you call it. so you have to use another variable each time you call image (if you plan to free or modify the image later on). otherwise you have no possibility to access the image at all.

also note:
• the first freeimage does nothing (or removes a random image that has the same ID as the player)
• afterwards you create and instantly free an image. that's of course just waste of traffic because it doesn't change anything

old Re: Multiple freeimages

Bowlinghead
User Off Offline

Quote
No I think you have to use

1
2
id=image("gfx/Medieval Mod/Cavalry/Horse.png",1,1,100+id)
          id=image("gfx/Medieval Mod/Cavalry/Horse2.png",1,1,200+id)

and

1
2
id=image("gfx/Medieval Mod/Cavalry/Horse.png",1,1,100+id)
          id2=image("gfx/Medieval Mod/Cavalry/Horse2.png",1,1,200+id)

(You have to use freeimage also with "id2" if you wanna delete this)

old Re: Multiple freeimages

EngiN33R
Moderator Off Offline

Quote
More >


I'm not very sure about the task itself, but having merged the two snippets provided I think this will work and is a more efficient way of performing the task. Let me know if I did something you was not aiming to do completely.

old Re: Multiple freeimages

Deleted User

Quote
You can use tables

like
1
2
3
4
5
6
id = {}
if blabla then
	id[1] = image(blabla)
elseif
	id[2] = image(blabla)
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview