i read the following:
The require Function
i am not sure if it is what i am searching for...
i guess it executes the lua file as it is required.
what i am asking is it possible to use another lua file (same as in php, java or c/c++ by include?)
so that i can use functions from this file when i want?
greets
LuMo, who is totally new to lua
include in lua
Moderators: Shine, Insert_witty_name
You have probably figured it out by now, but:
"...require does the same job as dofile, but with two important differences. First, require searches for the file in a path; second, require controls whether a file has already been run to avoid duplicating the work." - Programming in Lua
So basically use dofile unless you need to search for the file dynamically and you want to load the code several times.
Not sure why you would want to do this...I really would recommend sticking to one file. Do you have some Lua Libraries you are developing?
"...require does the same job as dofile, but with two important differences. First, require searches for the file in a path; second, require controls whether a file has already been run to avoid duplicating the work." - Programming in Lua
So basically use dofile unless you need to search for the file dynamically and you want to load the code several times.
Not sure why you would want to do this...I really would recommend sticking to one file. Do you have some Lua Libraries you are developing?
You can always use a comment line with asterisks across it, or some other deliniater. If I have reusable code I keep it seperate from the games code by doing such. Also, I HOPE you are using a Lua dev...there are a few out there. I use find a lot...would be nice to have a IDE with a little search box at the bottom like Firefox.