Pressure Sensor

  • tommig
    21st Jan 2012 Member 0 Permalink
    Hi guys!
    I came up with an idea earlier, so I tried to make it.
    I want it to be that if the pressure is greater than the temparature, the particle creates a spark.
    My code is:
    #include <element.h>

    int update_PRSN(UPDATE_FUNC_ARGS) {
        int r, rx, ry;
    {
    if (parts[i].temp>=256.0+273.15)
    parts[i].temp=256.0+273.15;
    if (parts[i].temp<= -256.0+273.15)
    parts[i].temp = -256.0+273.15;

    if ([y/CELL][x/CELL]>= parts[i].temp)
    {
    create_part(PT_SPRK)
    parts[i].ctype == PT_PRSN
    parts[i].life = 4;
    }
    return 0;
    }

    But it doesn't work. Can anyone tell me what I'm doing worng?
    Thanks
    Tommig
  • Turban-of-Terror
    21st Jan 2012 Member 0 Permalink
    I have to say this: wouldn't this break tons of saves? Maybe in an independent mod it might work. Sounds.like a good idea. Keep working at it. I'm not sure how to read such code stuff but I like where this is going. At first I thought it was a mechanical "ear". Using breakable material to pass through a detector to send a spark to a LCD display. I have been working on a project, highly classified but its almost completely out of the blue prints stage. :)
  • Catelite
    21st Jan 2012 Former Staff 0 Permalink
    A new element can't break saves if it hasn't existed before. :3
  • tommig
    21st Jan 2012 Member 0 Permalink
    @Turban-of-Terror (View Post)
    How would it break saves? It's a completely new element...
  • Turban-of-Terror
    21st Jan 2012 Member 0 Permalink
    Oh so now its an element, I was thinking it was a new reaction. Sorry...thank you for disclosing this new feature in a manner people who don't understand code could also understand..your description was very vaugue, to the point of illegibility. I probably should have assumed that the word "particle" referee to a new element, but assumptions never got anybody anywhere.
  • jacksonmj
    21st Jan 2012 Developer 0 Permalink
    To change the particle into SPRK (since that seems to be what your code is aiming to do at the moment):
    #include <element.h>

    int update_PRSN(UPDATE_FUNC_ARGS)
    {
    int r, rx, ry;
    if (parts[i].temp>=256.0+273.15)
    parts[i].temp = 256.0+273.15;
    if (parts[i].temp<= -256.0+273.15)
    parts[i].temp = -256.0+273.15;

    if (pv[y/CELL][x/CELL]+273.15f >= parts[i].temp)
    {
    part_change_type(i, x, y, PT_SPRK);
    parts[i].ctype = PT_PRSN;
    parts[i].life = 4;
    }
    return 0;
    }


    To spark surrounding particles, see btry.c
  • tommig
    21st Jan 2012 Member 0 Permalink
    @jacksonmj (View Post)
    That code has worked fine, but the particle heats up when it transmitts a spark, and I don't know how to stop it...
  • jacksonmj
    21st Jan 2012 Developer 0 Permalink
    Spark surrounding particles instead of changing the PRSN particle into SPRK.

    jacksonmj:

    To spark surrounding particles, see btry.c