Rather than creating a new element which I attempted to do before and didnt work, that is a copy of an element such as fire but with a different color, I was wondering if it possible for an element to change its color when it comes in contact with another element. I was wondering if this is possible as well as how to accomplish this within the code.
I know that, but I don't know if there is a built in function to use in TPT code to change a color of one element when it comes in contact with another element. I know I will have to create a .c class for that element I am asking if anybody has any experience of changing an elements color within a .c class and if they could give me some tips on how to code such a method.
@star400040(View Post) You mean change the color of all the elements, or just the colour of the element it touches, whatever its type? In case one, put a variable instead of an Hex value in the basic properties table. In case two, just put decoration ( From the decoration layer ) on the particle it touches
Alright I think I understand, but how would I tell the .c method of the element to look at the color variable in powder.h? What function would I have to use
EDIT: Additionally even when I change the color of fire, the flames dont actually change color, it must be some sort of decoration, where do I change that?
Did you create a graphics function in newgraphics.c? If you did, you can check the pmap like this: if ((pmap[nx+1][ny]&0xFF) != 0) { *colr = xxx; *colg = ... }. You could also change the fire colors(*fireb, *firea) instead.
I was looking at firea and fireb as I only want to change the color of fire when it comes in contact or is produced from one of my new elements, yet I can't find where to put the new HEX codes of the color, I checked the new graphics function of hflame and I see firea and fireb and clr and what not, but I can't seem to find where they are pointing to or getting their info from. Also what is dcolour I see that property in powder.h and I assume it has to do with colors but even if I set parts[r>>8].dcolour = something it doesnt do anything.
EDIT: Ok so I tried creating a new function in the newgraphics.c and the hmap.h, but when I did it began to mess up the graphics functions of the previous elements so I commented out the code I added in, I am not sure exactly what I did wrong there either, if somebody could answer my other questions in this post before I link another copy of my powder.h and the other files that would be great.
@star400040(View Post) You don't need to make a new hex code for the fire color, it just ignores the old one in powder.h when drawing it if you change the colx variables. Just put in any number for the firer you want, it's not getting the info from anywhere.
dcolour is decoration color from the decoration editor, you shouldn't change that. Also, you don't need to change hmap.h or use any variables in that, only a few elements use it.
You probably need to make an update function then that changes its life/ctype/... to something whenever one of those happens. Then instead of checking the pmap in the graphics update function, check if (cpart->life == 1) { *firer = 255 *fireg = 255 *fireb = 255 }. Your element will need both of these functions to be defined in powder.h and added to the ptypes table.