2
votes

Im trying to make a terminal but im stuck on one thing. In the doer program command do. I want docom to be the output of of the loadstring. input = io.read() its a lua terminal inside my program but nothing displays any output. Here is the code that is relevant:

docom = loadstring(input)
print(docom)

How do i make the output display? Because currently its like this:

welcome to the terminal!
loaded
do
do:
print("hello")
function: 0x809b60
do:

The third and fifth line are user inputs. how do i fix this so it shows the hello string instead of the function name. i want this to be able to manage it as i have everything else in the same lua script. please help.

1
assert(loadstring(input))() - Egor Skriptunoff

1 Answers

0
votes

You probably want print(docom()).

loadstring compile a script into a function. That's what you see function: 0x809b60.

loadstring does not run the function. Hence the call docom().

You may want to add error handling by checking whether docom is nil and by calling docom via pcall.