Closing the console

  • stevenspell
    13th August Member 0 Permalink

    so im trying to run this code 

    trgt=sim.pmap(6, 188);

    sim.partProperty(trgt, "ctype", 1);

    sim.framerender(1);

    for i=1,0x3ffffffe do

    crnt=sim.partProperty(trgt, "ctype")+1;

    sim.partProperty(trgt, "ctype", crnt);

    sim.framerender(1); end

    so that a filt goes through all the colors while a cray is creating crmc and i do have it so that subframe magic is happening so it is happening every frame but when i try to run it, it doesn't work properly as it keeps me in the console and I don't understand how evt.tick works and I've also tried interface.console(false) in front but it still doesn't work. sorry but im a little new to all this (lua and tpt lua api).

  • jacob1
    13th August Developer 0 Permalink
    sim.framerender doesn't do what you think it does. It's the same as pressing 'f' once, so it will advance the sim a frame the next chance it gets. Which is not while running your script. No simulation work is being done while your script is running, so it's impossible to write a for loop that will do actions between sim frames.

    The only way to solve it is to trigger your code in an event like evt.tick.

    local trgt = nil
    evt.register(evt.TICK, function()
        if trgt == nil then trgt = sim.pmap(6, 188)
        sim.partProperty(trgt, "ctype", sim.property(trgt, "ctype") + 1)
    end)

    There's a good start for it, I guess, will increment the ctype by 1 every frame. Probably not what you want though since that's crazy slow, but you can work on adjusting it.