Dofile
From MaratisWiki
(Difference between revisions)
(Created page with "To every scene can be attached only one lua file. Use this command to use multiple files in your scene script. It can be used to include a common file that contains common fun...") |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{lua-function|dofile|file}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | Use this command to include additional lua files. | |
− | + | {{lua-function-param|file|local path of the lua file to include}} | |
+ | <br> | ||
− | + | Finding the local path : | |
+ | /scripts/main.lua' -> from here call dofile("other/additional.lua")<br> | ||
+ | /scripts/other/additional.lua<br> | ||
+ | |||
+ | /scripts/something/main.lua -> from here call dofile("../other/additional.lua")<br> | ||
+ | /scripts/other/additional.lua<br> | ||
+ | |||
+ | |||
+ | '''Example :''' This script will add an external light effect library | ||
+ | |||
+ | dofile("lights/lightsfx.lua") | ||
+ | light = getObject("Light") | ||
function onSceneUpdate() | function onSceneUpdate() | ||
flickerLightEffects(light) | flickerLightEffects(light) | ||
end | end | ||
+ | |||
+ | [[Category:Lua scripting]] | ||
+ | [[Category:Lua function]] | ||
+ | [[Category:System]] |
Latest revision as of 11:06, 6 April 2014
dofile(file)
Use this command to include additional lua files.
-
file
: local path of the lua file to include
Finding the local path :
/scripts/main.lua' -> from here call dofile("other/additional.lua")
/scripts/other/additional.lua
/scripts/something/main.lua -> from here call dofile("../other/additional.lua")
/scripts/other/additional.lua
Example : This script will add an external light effect library
dofile("lights/lightsfx.lua") light = getObject("Light") function onSceneUpdate() flickerLightEffects(light) end