Why doesn't this code work?

  • Videogamer555
    17th Jan 2012 Member 0 Permalink
    Had to take out the pound sign because the stupid software made it into a link.
    include

    int update_HETR(UPDATE_FUNC_ARGS) {
    int r;
    r=pmap[x][y]>>8;
    parts[r].temp=9999;
    return 0;
    }


    It should make the temperature of the particle ALWAYS equal the maximum temperature. But it's not working. The temperature of the particle of HETR can actually be changed! I set it's initial temp to 9999 in the particle properties table in elementdata.c and then want to hold it perminently at that temperature so I used the above code in a file called hetr.c. I then followed the portion of the tutorial that told how to get it to recognise my new partical's update function, but it seems to not be able to detect the particle's update function becasause I'm able to change the temperature of the particle!!!!

    Please help me.
  • Neospector
    17th Jan 2012 Member 0 Permalink
    In powder.h, did you remember to make the particle recognize the .c file?
    int update_GOO(UPDATE_FUNC_ARGS);
    int update_HETR(UPDATE_FUNC_ARGS);
    int update_HSWC(UPDATE_FUNC_ARGS);
    ... "Heats objects it touches", ST_SOLID, TYPE_SOLID, &update_HETR},
  • jenn4
    17th Jan 2012 Member 0 Permalink
    @Videogamer555 (View Post)
    Vanquidh told me to tell you this at IRC: "Your code is little short and you will need a little more code to get it to work, it would be better if you went back to the coding tutorial(https://powdertoy.co.uk/Wiki/W/Coding-tutorial.html) and followed the part down the bottom about how hetr works and your should be able to get it to work, thecode there is a bit overcomplicated but it is good to teach you about things which you would use.." I hope it helps.
  • Neospector
    17th Jan 2012 Member 0 Permalink
    @jenn4 (View Post)
    While you are on there, can you ask if my ban was actually 9000 hours? I had thought I calculated correctly at about 1.027 years, but I am unsure. I want to check my math.
  • mniip
    17th Jan 2012 Developer 0 Permalink
    @Neospector (View Post)
    lol, thats much less...
    wait, no, itsa year
  • jacksonmj
    17th Jan 2012 Developer 0 Permalink
    @Videogamer555 (View Post)
    You've put x and y the wrong way round. It should be pmap[y][x].

    However, there's an easier way of accessing the current particle in the update function. parts[i].temp

    All update functions have the same variables passed to them:
    i - the index of the particle being updated
    x, y - the co-ordinates of the particle being updated
    surround_space - whether there is empty space around the particle
    nt - whether there is a particle around the current particle, that is NOT the current particle's type
    #define UPDATE_FUNC_ARGS int i, int x, int y, int surround_space, int nt
  • Videogamer555
    17th Jan 2012 Member 0 Permalink

    Neospector:

    In powder.h, did you remember to make the particle recognize the .c file?
    int update_GOO(UPDATE_FUNC_ARGS);
    int update_HETR(UPDATE_FUNC_ARGS);
    int update_HSWC(UPDATE_FUNC_ARGS);
    ... "Heats objects it touches", ST_SOLID, TYPE_SOLID, &update_HETR},

    Thanks I was missing this part:
    ... "Heats objects it touches", ST_SOLID, TYPE_SOLID, &update_HETR},"

    I just added the &update_HETR to that line (previously I'd copied DMND as my base so I wouldn't have to type all that line myself, but it didn't have an &update_DMND in it at all). But now I see it works with adding the &update_HETR code to the line. Thanks a bunch!