How to run scripts on Lua?
- Andrey01
- Member
- Posts: 2579
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
How to run scripts on Lua?
I`ve started to learn Lua at first time today. But i don`t know how to run a file with scripts. In one book it says it needs to call the comand % lua <filename>, but it doesn`t work.
Re: How to run scripts on Lua?
Minetest includes lua internally, but the `lua` command isn't part of that. You likely need to install a standalone `lua` package first before that command becomes available.Andrey01 wrote:I`ve started to learn Lua at first time today. But i don`t know how to run a file with scripts. In one book it says it needs to call the comand % lua <filename>, but it doesn`t work.
- Andrey01
- Member
- Posts: 2579
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
Re: How to run scripts on Lua?
Now i can run scripts. It appears i don`t need '%' symbol for comand 'lua <filename'. I tried other way to run ones is to use function dofile() in console.sofar wrote:Minetest includes lua internally, but the `lua` command isn't part of that. You likely need to install a standalone `lua` package first before that command becomes available.Andrey01 wrote:I`ve started to learn Lua at first time today. But i don`t know how to run a file with scripts. In one book it says it needs to call the comand % lua <filename>, but it doesn`t work.
Re: How to run scripts on Lua?
Lua is an interpreted language that is not intended to run by itself. It is similar to Python, which is intended to run by itself. Lua is intended to run as part of other programs such as: Gimp or minetest. It expects to find itself inside of another program. That is, if someone includes Lua in their program its to give you access to the internal functions of their program. Python can be used in the same way, but Lua is made for this almost exlusively. You can run Lua from the commandline, but its not really meant for that.
Re: How to run scripts on Lua?
That's just silly. Interpreted languages are just as easily usable outside of another program as they are as an embedded modding language.lightseer wrote:but its not really meant for that.
Code: Select all
echo -e '#!/usr/bin/env lua\nprint("hello")\n' > test.lua && chmod 755 test.lua && ./test.lua
Lua was designed to be small, and Lua's small size makes it *excellent* for embedding, but that does not logically translate that Lua was designed to be embedded. It also makes for an excellent scripting language by itself just fine.
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: How to run scripts on Lua?
I've never read so much nonsense in one single post.lightseer wrote:Lua is an interpreted language that is not intended to run by itself. It is similar to Python, which is intended to run by itself. Lua is intended to run as part of other programs such as: Gimp or minetest. It expects to find itself inside of another program. That is, if someone includes Lua in their program its to give you access to the internal functions of their program. Python can be used in the same way, but Lua is made for this almost exlusively. You can run Lua from the commandline, but its not really meant for that.
Re: How to run scripts on Lua?
Sounds like I misspoke. It is usually found embedded in things.sofar wrote:That's just silly. Interpreted languages are just as easily usable outside of another program as they are as an embedded modding language.lightseer wrote:but its not really meant for that.
The above demonstrates that lua could just be used like a shell script or a python script, without embedding.Code: Select all
echo -e '#!/usr/bin/env lua\nprint("hello")\n' > test.lua && chmod 755 test.lua && ./test.lua
Lua was designed to be small, and Lua's small size makes it *excellent* for embedding, but that does not logically translate that Lua was designed to be embedded. It also makes for an excellent scripting language by itself just fine.
Re: How to run scripts on Lua?
From the Lua documentation page: https://www.lua.org/semish94.html This is "The first paper describing Lua." It is described as "A language for extending applications."
Who is online
Users browsing this forum: No registered users and 20 guests