How to run a lua file
Posted: Wed Aug 19, 2015 9:55 pm
I was searching it in wiki, but didn't found it. How do I run other 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?
Code: Select all
cd Desktop
Code: Select all
lua main.lua
Code: Select all
require "somescript"
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();
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.