How do I run a script from the console?

  • Videogamer555
    12th Dec 2011 Member 0 Permalink
    I want to type a command that will run a Lua script file. Any Ideas?
  • jacksonmj
    12th Dec 2011 Developer 0 Permalink
    dofile('filename.lua')

    This is described at the beginning of the Lua wiki page.
    https://powdertoy.co.uk/Wiki/W/Lua.html#How_to_run_a_script
  • Videogamer555
    12th Dec 2011 Member 0 Permalink
    Thanks. But now how do I write a "for" loop in the script. I tried

    for n = 1,10,1
    do something here
    end


    but it says returns an error saying I need "do" near "for", yet I've seen other people's scripts and they don't have a the word "do" anywhere in their script files. Please help.


    Using wikipedia's info I tried

    for y = 0,239 do
    for x = 0,319 do
    do tpt.set_property("type","wood",x,y)
    end
    end

    but that still doesn't work.
    Again, need some help here.
    It keeps saying I need to end the for in line 1 at EOF. But theres not SUPPOSED to be an EOF until the 5th line is done, as there are FIVE WHOLE LINES. Please help me some more.
  • jacksonmj
    12th Dec 2011 Developer 0 Permalink
    "do" is required at the end of the first line in the for loop.

    for n = 1,10,1 do
    --do something here
    end



    Too many "do"s, don't need one before tpt.set_property:
    for y = 0,239 do
    for x = 0,319 do
    tpt.set_property("type","wood",x,y)
    end
    end