Dofile

From MaratisWiki
(Difference between revisions)
Jump to: navigation, search
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
To every scene can be attached only one lua file.
+
{{lua-function|dofile|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.
+
  
Example 1 : This script will add an external light effect library
+
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")  
 
     dofile("lights/lightsfx.lua")  
Line 11: Line 22:
 
         flickerLightEffects(light)
 
         flickerLightEffects(light)
 
     end
 
     end
 +
 +
[[Category:Lua scripting]]
 +
[[Category:Lua function]]
 +
[[Category:System]]

Latest revision as of 12: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