Well, to put it simply, I am a n00b modder making an LUA mod. I got an idea to add corn and popcorn. Pretty simple. However, when I try to pop my corn, it works for a while, but then my particles go inside of each other and make a black hole, which eats all of my popcorn. Also, I will sometimes get a "particle does not exist error". Here's the script for the popcorn:
function popcorn(i,x,y,s,n,w,o)
o = (2500 - tpt.get_property('temp', x, y))
if o < 1 then
o = 1
end
if tpt.get_property('temp', x, y) > 373.15 and math.random(1,o) == 1 then
tpt.set_property('type', tpt.element('PPCN'), x, y)
tpt.set_property('vy', -3, x, y)
end
end
tpt.element_func(popcorn, tpt.element("CORN"))
As you can probably tell, CORN is corn and PPCN is popcorn.
I don't see why it is making black holes. Can someone suggest a fix? Thanks in advance.
Try using:
sim.partChangeType(sim.pmap(x,y), tpt.element("PPCN"))
instead of tpt.set_property('type', ...).
If that doesn't work, please post the whole script (element properties as well as update function, so that I can run it).
That worked, thanks! I'm guessing the problem was that while it was changing into PPCN, other particles could go into that space for some reason. With this command, they can't. Thanks again!