Writing to files

  • minecraft-physics
    17th May 2016 Member 0 Permalink
    I'm trying to write a script that prints the coordinates of all pixels on the screen to a csv file. I tried using
    file = io.open("~/Desktop/test.csv") but file just returns nil, suggesting that the lua interpreter has been sandboxed.
    I'm dealing with a lot of numbers, so the tiny window with the result of an expression is insufficient. Is there a way to get these values without manually typing them all out?
    Edited once by minecraft-physics. Last: 17th May 2016
  • jacob1
    17th May 2016 Developer 0 Permalink
    You can print them to a file ... using the actual lua functions. open is a python function.

    You probably want something likelocal file = io.open("~/Desktop/test.csv")
    file:write("djfhasdfakljsdfhlkajsdfhlkajsdf")
    file:close()


    (untested, if those are the wrong functions, look at the lua reference manual)
  • minecraft-physics
    17th May 2016 Member 0 Permalink
    I originally did check the reference (it was a typo, I used io.open()) and the pointer still returns nil. I've found a workaround using tpt.setclipboard() though, so it's not an issue.
  • jacob2
    17th May 2016 Member 0 Permalink
    @minecraft-physics (View Post)
    Hmm, maybe use 'w' as the second argument. Or use a full path, it may not understand the ~ for some reason