Dofile

From MaratisWiki
(Difference between revisions)
Jump to: navigation, search
m
 
Line 1: Line 1:
 
{{lua-function|dofile|file}}
 
{{lua-function|dofile|file}}
  
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 functions or to include external third party libraries.
+
Use this command to include additional lua files.
  
{{lua-function-param|file|lua script file to execute}}
+
{{lua-function-param|file|local path of the lua file to include}}
 +
<br>
  
'''Example 1:''' This script will add an external light effect library
+
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")  
 
     dofile("lights/lightsfx.lua")  

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
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox