All are silly operations:
Windows:
Copy the luavs. BAT file in the etc directory to the root directory of Lua and run it directly!
Linux:
$ Make Linux & make install standard Linux Installation
Luaedit has a bug that the author has not fixed. It happened to me. I need to reflect on my Rp! Go to Linux and use VI.
An interesting example is to use Lua to output a sine curve.
$ Mkdir aol_study
$ CD aol_study
$ Touch plot. Lua
$ VI plot. Lua
Function eraseterminal ()
Io. Write ("/27 [2j ")
End
-- Writes an '*' at column 'x', row 'y'
Function mark (x, y)
Io. Write (string. Format ("/27 [% d; % DH *", Y, x ))
End
-- Terminal size
Termsize = {W = 80, H = 24}
-- Plot a function
-- (Assume that domain and image are in the range [-1, 1])
Function plot (f)
Eraseterminal ()
For I = 1, termsize. w do
Local x = (I/termsize. W) * 2-1
Local y = (f (x) + 1)/2 * termsize. h
Mark (I, Y)
End
Io. Read () -- wait before spoiling the screen
End
After saving, enter the following command:
$ Lua
Enter Lua Mode
> Dofile "plot. Lua"
> Plot (function (x) return math. Sin (x * 2 * Math. Pi) end)
Haha, I output a sine curve composed of "*", as if I had returned to learning basic drawing before.