How to run a lua file
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 3
- Joined: Wed Aug 19, 2015 9:52 pm
How to run a lua file
I was searching it in wiki, but didn't found it. How do I run other lua file?
Re: How to run a lua file
im assuming you want to know how to take the folder that houses all of your lua files and run them in love. you just drag the folder into the love application icon on your desktop.
Re: How to run a lua file
Because it's not question about LÖVE. It's question about Lua.TheJebForge wrote:I was searching it in wiki, but didn't found it.
Read PIL ("Programming in Lua" book). Read about "dofile", "loadstring", "require".TheJebForge wrote:How do I run other lua file?
And if you want to run other .love file then you can "os.execute("love.exe other.love")" for example.
Re: How to run a lua file
-On windows-
If you have lua installed you can just open a command prompt go to the directory you have the lua file for example (if it's on desktop)
and then type
I don't know how to run lua programs in other operating systems because I only use Windows
I hope I that makes sense
If you have lua installed you can just open a command prompt go to the directory you have the lua file
Code: Select all
cd Desktop
and then type
Code: Select all
lua main.lua
I hope I that makes sense

Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeooow!!
Re: How to run a lua file
I'm pretty sure what OP is needing is just require. Say you have a file called "somescript.lua" in the same folder as "main.lua". Then somewhere in main.lua, you can call
And it will load and run the other script.
Code: Select all
require "somescript"
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
-
- Prole
- Posts: 3
- Joined: Wed Aug 19, 2015 9:52 pm
Re: How to run a lua file
I want to run other love script. Like options... Or actual game... Sorry for not accurate post.
Re: How to run a lua file
Put something like this in a separate file:
and then in your main file:
Also if you want to do options and stuff like that you should read about state managing:
https://en.wikipedia.org/wiki/State_management
http://gamedev.stackexchange.com/questi ... screen-etc
You can find some Libraries for LÖVE if you search the wiki and the forums. I usually use my own https://github.com/rm-code/screenmanager for different screens like main menu, game and options.
Code: Select all
local Foo = {};
function Foo.someFunction()
...
end
return Foo;
Code: Select all
local Foo = require("Foo");
-- Call function from other module.
Foo.someFunction();
https://en.wikipedia.org/wiki/State_management
http://gamedev.stackexchange.com/questi ... screen-etc
You can find some Libraries for LÖVE if you search the wiki and the forums. I usually use my own https://github.com/rm-code/screenmanager for different screens like main menu, game and options.
-
- Prole
- Posts: 3
- Joined: Wed Aug 19, 2015 9:52 pm
Re: How to run a lua file
Ok, I'll try to do so. thxrmcode wrote:Put something like this in a separate file:and then in your main file:Code: Select all
local Foo = {}; function Foo.someFunction() ... end return Foo;
Also if you want to do options and stuff like that you should read about state managing:Code: Select all
local Foo = require("Foo"); -- Call function from other module. Foo.someFunction();
https://en.wikipedia.org/wiki/State_management
http://gamedev.stackexchange.com/questi ... screen-etc
You can find some Libraries for LÖVE if you search the wiki and the forums. I usually use my own https://github.com/rm-code/screenmanager for different screens like main menu, game and options.
Who is online
Users browsing this forum: Bing [Bot] and 8 guests