Modding Help?

  • megamageiii
    12th Jun 2014 Member 0 Permalink

    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.

    Edited once by megamageiii. Last: 12th Jun 2014
  • jacksonmj
    12th Jun 2014 Developer 0 Permalink

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

    Edited once by jacksonmj. Last: 12th Jun 2014
  • megamageiii
    12th Jun 2014 Member 0 Permalink

    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!