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!
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.