I have a very simple (possibly naive) solution to checking particles touching a particle: if each particle can retrieve it's coordinates tuple (x,y), and a particle can be found at a position given by a similar tuple, you could probe the surrounding pixels of each particle of your detector particle and find the particles around it. For example, for each detector particle at (x,y), find particles (x+1, y), (x-1, y), (x,y+1) and (x,y-1) and change their types. If I am not mistaken, this is a Von Newman Cellular Automaton neighbourhood. This seems like a real lag machine if you ask me; is there a better implementation?
ok, found out this does sort of what I want; I'll just have to run it once per every direction; though that might get slow.
if sim.partProperty(sim.partID(x, y+1), sim.FIELD_TYPE)==elements.DEFAULT_PT_GLAS then
sim.partProperty(sim.partID(x, y+1), sim.FIELD_TYPE , elements.DEFAULT_PT_METL)
end
for i in sim.neighbors(x, y, 1, 1, tpt.el.glas.id) do
tpt.set_property("type", i, tpt.el.metl.id)
end
jacob1:
@mniip (View Post)
I guess I don't know the functions very well either, lol. The one you posted was the one I was thinking of.
@boxmein (View Post)
I tried that, but it didn't work because you used the "sim" shortcut instead of "simulation" which I was trying. http://boxmein.x10.mx/tptelements/lua-reference.html#simulation.partNeighbors didn't work.
@zBuilder (View Post)
if you can use sim.neighbors that would work a lot better and be less laggy.for i in sim.neighbors(x, y, 1, 1, tpt.el.glas.id) do
tpt.set_property("type", i, tpt.el.metl.id)
end
Also I prefer the old api since more people know it and it's much cleaner ... but really doesn't matter. Also I tried this and it doesn't completely work for some reason ... weird. It changed the ones on the corners though.
when I use partneigbours it fails because it is "calling a table value", whatever that means. though your arguments look different then the last set I saw so I'll give it a shot! :)
edit: sorry, that one throws an error instead as well :(