question about comands

  • archived_account
    29th Jun 2018 Member 0 Permalink

    does someone saw full list of (at least) tpt._ and sim._ comands? im not. seaching commands in scripts is time wasting, but i dont found any list. can anyone give me, if its real? 

  • archived_account
    30th Jun 2018 Member 0 Permalink
  • archived_account
    3rd Jul 2018 Member 0 Permalink

    oh, i got two another questions: how to set delay (waiting) betwen executing comands and how to make graphics.__ drawing always? 

    Edited once by DayTimer253. Last: 3rd Jul 2018
  • jacob2
    3rd Jul 2018 Member 0 Permalink
    It's hard to give an example from my phone, but look into tpt.register_step

    This registers a function that runs every frame.

    As for delays, you can use the step function too and check the time. Use os.time() to check time in seconds, or socket.gettime() for milliseconds.
  • archived_account
    3rd Jul 2018 Member 0 Permalink

    @jacob2 (View Post)

     nah, im made the function as an element (on android :O), but its anyway drawing only when simulation is freezing (ex.console or settings)... 

  • jacob1
    3rd Jul 2018 Developer 0 Permalink
    @DayTimer253 (View Post)
    You can't draw graphics inside of update functions (not graphics functions either). The fact that it shows up sometimes is a really minor issue on Android that will be fixed if I ever convert all the interfaces to the new style.

    You need to draw graphics inside of step functions, I think that is the only place they work. You might want to store a list of particles that will need custom graphics drawn on them, then draw all that in the update function and clear the list.
  • archived_account
    3rd Jul 2018 Member 0 Permalink

    @jacob1 (View Post)

    i dont understand nothing. inside of step? but how i will run it, if i want drawing relatively to elements? also the mod, where i copied pieces of elements code (star wars) drawing lines (tpt.drawline) inside a graphics function

  • jacob1
    4th Jul 2018 Developer 0 Permalink
    @DayTimer253 (View Post)
    Where is the script you copied from? How old is it? Many years ago you could draw stuff inside of update and graphics functions. It's possibly even a bug that you can't anymore (at least for graphics functions), but I haven't looked into how stuff would need to be reordered to make it work.

    Anyway, look at this script for an example of what I mean (only the very beginning):
    https://starcatcher.us/scripts/?view=44

    In the update function it adds to a table of all particles that need special graphics drawn for them. It has a step function registered with tpt.register_step() that does the actual drawing.

    Some relevant parts are:
    local crabs = {}
    function seeker(i, x, y, s, n)
    ...
    table.insert(crabs, i)
    ...
    end
    tpt.element_func(seeker,HeadCrab)

    function draw()
    for i,v in ipairs(crabs) do
    ...
    end
    if tpt.set_pause() == 0 then
    crabs = {}
    end
    end
    tpt.register_step(draw)
    Edited 2 times by jacob1. Last: 4th Jul 2018