Potion Script Causes Extreme Lag

  • BrianTheEngineer
    4th Dec 2019 Member 0 Permalink

    As you might know, I am making a potion script. However, I have reached a severe problem. You see I just added a new element, and when I place too many, the window lags to the point where it was one frame per second.

     

    Here is my code:

     

    local levitationPotion = elements.allocate("POTIONS""LEVI")

    elements.element(levitationPotion, elements.element(elem.DEFAULT_PT_WATR))

    elements.property(levitationPotion, "Name""LEVI")

    elements.property(levitationPotion, "Description""Levitation Potion")

    elements.property(levitationPotion, "MenuVisible"1)

    elements.property(levitationPotion, "MenuSection", elem.SC_LIQUID)

    local function levitationUpdate (i, x, y, s, n)

        for element in sim.neighbors(x, y, 1515do

            if sim.partProperty(element, "type"== elem.DEFAULT_PT_STKM then

                sim.partChangeType(element, elem.DEFAULT_PT_GOLD)

            end

        end

    end

    elements.property(levitationPotion, "Update", levitationUpdate)
    Edited once by BrianTheEngineer. Last: 4th Dec 2019
  • LBPHacker
    4th Dec 2019 Developer 0 Permalink

    That's what we mean when we say Lua elements are laggy. Btw I'm quite sure you meant id instead of element in the for loop.

  • gamers4
    6th Dec 2019 Member 0 Permalink

    Oh, i know one scripter who had the same problem. try making field smaller

     

    lol it happened to me once too, but i just deleted the code XD