This program does not work from terminal but works in zerobrane

82 views Asked by At
x = 10
io.write("Enter the name of the variable you want to be printed: ")
index = io.read()
f = loadstring("return " ..  index)
print(f())

The above code gives this error when used in a terminal, but not when ran in zerobrane studio

main.lua:874: attempt to call a nil value (global 'loadstring') 
stack traceback: 
    main.lua:874: in main chunk [C]: in ? 

This is important because i am coding lua in emacs. how can i correct this problem? Need help.

1

There are 1 answers

0
Spar On

Your terminal version of Lua is higher than Lua in ZeroBrane.

Lua 5.3 removed loadstring and it exists as load now.