Dirt not turning to Mud

  • MrDucku
    4th Jun 2016 Member 0 Permalink

    local function checkwtr(i, x, y, n, nt)
    if sim.partProperty(n, sim.FIELD_TYPE) == DEFAULT_PT_WATR then
    sim.partChangeType(i, elem.DEFAULT_PT_OIL)
    sim.partChangeType(n, elem.DEFAULT_PT_OIL)
    end
    end
    elem.property(dirt, "Update", checkwtr)

     

    short little thing, the dirt, when I put water on it, doesn't turn into mud, both elements are defined. Thanks!

  • LBPHacker
    4th Jun 2016 Developer 1 Permalink

    It's because n and nt are not particle IDs. They are the number of empty cells and cells containing a particle not of the type of i, respectively. You'll have to call sim.neighbours to get a list of the particles around i. It's an iterator factory, so you'll need a loop to use it. You could also do the search for neighbours yourself.

    Edited 5 times by LBPHacker. Last: 4th Jun 2016
  • MrDucku
    4th Jun 2016 Member 0 Permalink

    ok thank you!