delay in startup script "urgent"

  • Quezler
    23rd Apr 2014 Member 0 Permalink

    how can i add a delay to this startup script that it runs every X seconds? i tried a few ways but i cannot seem to figure out what to do

     

    while true do
    tpt.set_property("type","clne",clne)
    end

     

    curently this startup script causes the "infinite loop" bug

  • jacob1
    23rd Apr 2014 Developer 0 Permalink
    I'm not sure exactly what you intended it to do, but here is something that sets the ctype of clne to clne every 3 seconds:
    local lastTimer = 0
    local function moo()
    if os.time() > lastTimer then
    tpt.set_property("ctype", "clne", "clne")
    lastTimer = os.time()+3
    end
    end
    tpt.register_step(moo)
  • Quezler
    23rd Apr 2014 Member 0 Permalink

    i tested and it works as i intended, but there is one problem i find:

     

    local lastTimer = 0
    local function moo()
    if os.time() > lastTimer then
    tpt.set_property("ctype", "clne", "clne")
    lastTimer = os.time()+0.001
    end
    end
    tpt.register_step(moo)

     

    i want the change to happen more rapidly, but even on this setting it goes quite slow, is this the correct way to speed it up?

    Edited once by Quezler. Last: 23rd Apr 2014
  • jacob1
    23rd Apr 2014 Developer 0 Permalink
    os.time() is only accurate to the second, if you want it to be any faster there's a nice function socket.gettime(), which I think measures time to the millisecond
    local lastTimer = 0
    local function moo()
    if socket.gettime() > lastTimer then
    tpt.set_property("ctype", "clne", "clne")
    lastTimer = socket.gettime()+.5
    end
    end
    tpt.register_step(moo)
  • Quezler
    24th Apr 2014 Member 0 Permalink

    what is weird is that if you set the ctype of clone to clone with the tool you see that the ctype is clone when you hover over it, with this script it does not show anything in the ctype when you hover over it, and it still clones particles it touches, which he should not be able to accept

  • jacob1
    25th Apr 2014 Developer 0 Permalink
    @Quezler (View Post)
    It shows up as CLNE(CLNE) for me, except for the new CLNE created, which is just CLNE().
    CLNE(CLNE) is considered an invalid ctype by the game, and treated as if it was empty, so it will still pick up and clone any other particles that touch it. There's no way to create clone that clones itself without the console anyway.
  • Quezler
    25th Apr 2014 Member 0 Permalink

    i have seen other lua scripts that add actual particles, can i also create a "clone that clones everything" particle?