Why doesn't this code work

  • PizzaPlatypus
    7th Sep 2011 Member 0 Permalink
    This is in it's own .c file I want the GBOB to explode into HSLF on contact with anything but itself.
    Here's the code:

    #include

    int update_GBOB(UPDATE_FUNC_ARGS) {
    int r,rx,ry;
    for (rx=-2; rx<3; rx++)
    for (ry=-2; ry<3; ry++)
    if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
    {
    r = pmap[y+ry][x+rx];
    if ((r>>8)>=NPART || !r)
    continue;
    if ((r&0xFF)!=PT_GBOB)
    {
    pv[x/CELL][y/CELL]+=1.5;
    parts[i].type=PT_HSLF;
    }
    }
    return 0;
    }
  • PizzaPlatypus
    7th Sep 2011 Member 0 Permalink
    please help
  • jenn4
    7th Sep 2011 Member 0 Permalink
    what are those brs? What should that code do?
  • mniip
    7th Sep 2011 Developer 0 Permalink
    Br seems to be unenclosed < and >
    to enclose them use &lt; for < and &gt; for >
  • PizzaPlatypus
    7th Sep 2011 Member 0 Permalink
    I want the element GBOB to explode into the element HSLF on contact with anything except itself. Instead it just drops like regular dust and doesn't do anything apart from the regular stuff dust does.
    What should I do with the brs when I have finished what should the brs look like.
  • mniip
    7th Sep 2011 Developer 0 Permalink
    I think you should use create_n_parts or whatever, not just setting a type
  • PizzaPlatypus
    7th Sep 2011 Member 0 Permalink
    @mniip (View Post)
    But the pressure still isn't created so it doesn't matter.
  • jacksonmj
    7th Sep 2011 Developer 0 Permalink
    @PizzaPlatypus (View Post)
    Make sure you've added &update_GBOB to the end of the GBOB line in the ptypes array (in powder.h).

    y coordinate goes first for pv, so pv[y/CELL][x/CELL].
    And it's better to use part_change_type(i, x, y, PT_HSLF); to change a particle's type.

    @jenn4 @mniip
    The <br />s were just because the "less than" symbols in the for loops were interfering with the HTML. Quote PizzaPlatypus's post to see the actual code. Original post has been fixed.

  • PizzaPlatypus
    7th Sep 2011 Member 0 Permalink
    The pressure now works but not the element change.
  • me4502
    7th Sep 2011 Member 0 Permalink
    @PizzaPlatypus (View Post)
    what is your code now...