Help in coding

  • bowserinator
    22nd Aug 2014 Member 0 Permalink

    Just wondering how does an element check the ctype/life/tmp, etc... of itself I'm making a force field element here's my current code:

     


    //#TPT-Directive ElementHeader Element_FFLD static int update(UPDATE_FUNC_ARGS)
    int Element_FFLD::update(UPDATE_FUNC_ARGS)
    {
        int r, rx, ry;
        int temp = Temperature;
        for(rx = -1; rx<2;rx++)
            for(ry=-1;ry<2;ry++)
                if(BOUNDS_CHECK)
                {
                r = pmap[y+ry][x+rx];
                if (!r || (r&0xFF) == PT_FFLD)
                    r = sim->photons[y+ry][x+rx];
                if (!r)
                    continue;
                    //CHECK TMP HERE SO IT CAN DO DIFFRENT EFFECTS
                        parts[r>>8].type = FIRE;
                    
                }
            }
        return 0;
    }




  • iamdumb
    22nd Aug 2014 Member 0 Permalink

    try

    this->partProperty

    Edited 2 times by iamdumb. Last: 22nd Aug 2014
  • bowserinator
    22nd Aug 2014 Member 0 Permalink

    Could you please give me an example of how it's used? I'm new

  • iamdumb
    22nd Aug 2014 Member 0 Permalink

    @bowserinator (View Post)

     I'm not an expert, it's probably actually sim.

     

    EDIT: parts[i].tmp

    is the value. I'm more into lua

     

    EDIT again: so erm, if(parts[i].tmp == 0) {

    // do stuff

    }

     

    EDIT again...: i is the index of the currect particle.

    Edited 4 times by iamdumb. Last: 22nd Aug 2014
  • jacob1
    22nd Aug 2014 Developer 0 Permalink
    If you want to check the index of the other particle, you can use parts[r>>8].tmp.

    Also never directly set .type, that causes bugs. You can do sim->part_change_type(...) or sim->create_part(r>>8, ...) instead.
  • bowserinator
    23rd Aug 2014 Member 0 Permalink

    Thanks

     

    Also anyone know how to debug (run without compiling) in visual studio 2013)

    As in which file to open to run with

    Edited 2 times by bowserinator. Last: 23rd Aug 2014