why does this run even when paused

  • AerospaceFan
    12th June Member 0 Permalink

    help i suffered for 5 hours and failed

     https://limewire.com/d/wqSN2#yG1iocxHHk

    i cant post here without indentation being broken but here it is anyways, if it doesnt work then use the link thing above

    -- this one took a LONG time

    local VRUS = elements.allocate("COOLVIRUS", "VRUS")

    elements.property(elements.COOLVIRUS_PT_VRUS, "Name", "VRUS")
    elements.property(elements.COOLVIRUS_PT_VRUS, "Description", "Virus, grows a network and spreads everywhere, dont touch!")
    elements.property(elements.COOLVIRUS_PT_VRUS, "Colour", 0xC0C0C0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "MenuSection", elem.SC_SOLIDS)
    elements.property(elements.COOLVIRUS_PT_VRUS, "MenuVisible", 1)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Gravity", 0.0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Flammable", 0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Explosive", 0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Loss", 0.75)
    elements.property(elements.COOLVIRUS_PT_VRUS, "AirLoss", 0.94)
    elements.property(elements.COOLVIRUS_PT_VRUS, "AirDrag", 0.02)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Advection", 0.0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Weight", 100)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Diffusion", 0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Meltable", 0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Hardness", 18)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Falldown", 0)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Properties", elem.TYPE_SOLID)
    elements.property(elements.COOLVIRUS_PT_VRUS, "Temperature", 295.15)
    elements.property(elements.COOLVIRUS_PT_VRUS, "HeatConduct", 82)
    elements.property(elements.COOLVIRUS_PT_VRUS, "HighTemperature", 473.15)
    elements.property(elements.COOLVIRUS_PT_VRUS, "HighTemperatureTransition", elements.DEFAULT_PT_EMBR)
    elements.property(elements.COOLVIRUS_PT_VRUS, "HighPressure", 30)
    elements.property(elements.COOLVIRUS_PT_VRUS, "HighPressureTransition", elements.DEFAULT_PT_EMBR)

    local VRUS = elements.COOLVIRUS_PT_VRUS
    local dirs = {
    {1,0}, {1,1}, {0,1}, {-1,1},
    {-1,0}, {-1,-1}, {0,-1}, {1,-1}
    }
    -- ahhhh

    tpt.register_step(function()
    local list = {}

    for i in sim.parts() do
    if i then
    list[#list + 1] = i
    end
    end

    for _, i in ipairs(list) do

    if sim.partProperty(i, "type") == VRUS then

    local x = sim.partProperty(i, "x")
    local y = sim.partProperty(i, "y")

    local d = sim.partProperty(i, "tmp")
    if d < 1 or d > 8 then
    d = math.random(1, 8)
    sim.partProperty(i, "tmp", d)
    end

    local dx = dirs[d][1]
    local dy = dirs[d][2]

    local nx = x + dx
    local ny = y + dy

    local target = sim.partID(nx, ny)

    if math.random(20) == 1 then
    sim.partProperty(i, "tmp", math.random(1, 8))
    end

    if type(target) == "number" and target ~= -1 then

    if sim.partProperty(target, "type") ~= VRUS then
    if math.random(100) == 1 then
    sim.partChangeType(target, VRUS)
    end
    end

    else
    if math.random(300) == 1 then
    sim.partCreate(-1, nx, ny, VRUS)
    end
    end

    end
    end
    end)

  • LBPHacker
    12th June Developer 0 Permalink
    This post has been removed by LBPHacker: unhelpful (I misread), see answer below
  • jacob1
    12th June Developer 1 Permalink
    You're using tpt.register_step, which (besides the fact it's replaced by evt.tick) tells it to run every frame, no matter what. You could try registering a different event type like evt.aftersim, which only runs when unpaused.

    By the way, no need to iterate through the parts list twice. You can just loop through sim.parts() once and get rid of the local variable "list".
  • AerospaceFan
    12th June Member 0 Permalink

    ok thanks, ill try to fix it now

    EDIT: oh em gee it works im stupid

    Edited once by AerospaceFan. Last: 12th June