So instead of making hair red, it makes another image red. Is there a way to customly set the id of each image? Or should I just make a separate file for each hair colour?
Forum
Scripts
How to use imagecolor for same img in diff rounds
How to use imagecolor for same img in diff rounds
1 reply
1

So instead of making hair red, it makes another image red. Is there a way to customly set the id of each image? Or should I just make a separate file for each hair colour?
image CS2D assigns a new free image ID. You have to save this ID in an variable if you want to do additional things with the image like using
imagecolor for instance.NEVER use fixed IDs when working with images. It will go wrong as you noticed. Multiple objects in CS2D are sharing that ID-space so depending on what happens in the game the IDs can and will be different.
WRONG - that "1" (or any other fixed number) as ID is always bad.1
2
2
image(....) imagecolor(1,255,0,0)
RIGHT - save & use the ID that image returns!1
2
2
local id = image(....) imagecolor(id,255,0,0)
(of course you have to insert proper parameters for image instead of just "....")
1

Offline