Meaning of arguments in update function

  • frogo112
    25th Mar 2016 Member 0 Permalink

    So I can't find any information about what the arguments to the standard update function mean as they are uncommented and highly abbreviated.

     

    What I am talking about are the values: i, x, y, s, and nt.

     

    I understand that i is index, but index of what?

    x and y of what?

    And I have no idea what s and nt are for.

     

    It would be greatly appreciated if anyone could fill me in on this.

  • boxmein
    25th Mar 2016 Former Staff 0 Permalink
    I lost some updates on my TPTElements site, but essentially it's this:

    function update(index, x, y, surround_space, nt)
    ...
    end
    elements.partProperty("WATR", "Update", update)


    where
    index - particle index in the parts[] array (useful for directly accessing the particle, in case you're modifying a particle)
    x, y - the coordinates of the particle in the game field (note, up to 5 different particles can be on the same x/y without ehole)
    surround_space - in the direct (Moore) neighborhood of this particle (1 pixel in every direction), how many cells are empty?
    nt - in the direct neighborhood of this particle, how many cells are not the same type as this particle? (if this is an update function for WATR, this returns the count of non-WATR particles - including empty cells!)

    In the source code, here is where surround_space and nt are created.
  • frogo112
    25th Mar 2016 Member 0 Permalink

    Thank you. I can finally use the update function. I had actually found the surround_space in the wiki but no information on what it did.