I'm sorry if this is a simple question, but I am new to Lua modding, and I am unsure how to make 2 elements mix. For example, if I wanted DUST and WATR to make CNCT, what line(s) would I need to put in? I could probably do something like 'if tpt.getproperty('type', x + 1, y)' for each of the sides of the particle, but I think there might be an easier way. Is there? And if there is, what is it?
function newdustupdate (index, x, y, surround_space, no_type)
-- find WATR particles:
-- go over the moore neighborhood of the particle
for part in sim.neighbors(x, y, 1, 1)
-- if a particle in the moore neighborhood has the type WATR (expressed as an integer,
-- so tpt.element is used to convert the string "WATR" too into an integer)
if sim.partProperty(part, 'type') == tpt.element('WATR') then
-- create a concrete particle in dust's place
-- edit2: jehkab one wuz heer 2, also fancy field_* constants!
sim.partCreate(part, sim.partProperty(part, sim.FIELD_X), sim.partProperty(part, sim.FIELD_Y), elem.DEFAULT_PT_CNCT)
sim.partKill(i)
return 1
end
end
end
end
-- element_func is cooler than partProperty("Update",...) maybe
tpt.element_func(newdustupdate, tpt.element('DUST'))
sim.partCreate(part, sim.partProperty(part, sim.FIELD_X), sim.partProperty(part, sim.FIELD_Y), elem.DEFAULT_PT_CNCT)
sim.partKill(i)
return 1
It says 'do expected near if' on the line with if, so I put a 'do' on the 'for' before it, and it fixed that, and then it said ''<eof>' expected near end' on the last end. I'm new to Lua, so I'm not sure what the issue is.
I did that, and now DUST just destroys WATR and makes nothing.
Actually, I forgot to put your edit in. This time it worked in making the CNCT, but the DUST wasn't destroyed.
EDIT:
I changed sim.partKill(i)
to
sim.partKill(index)
and it worked! Thank you!