Difference between revisions of "Loading Order of Lua Files"

From GiderosMobile
m
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
<!-- GIDEROSOBJ:Loading Order of Lua Files -->
 
 
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''Available since:''' Gideros 2020.5<br/>
 
'''Available since:''' Gideros 2020.5<br/>
Line 7: Line 5:
 
=== Description ===
 
=== Description ===
 
You can now implement Gideros Code Dependency by code instead of Gideros project setting.
 
You can now implement Gideros Code Dependency by code instead of Gideros project setting.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
--!NEEDS:your_file.lua
 
--!NEEDS:your_file.lua
</source>
+
</syntaxhighlight>
  
 
'''PS: the path is relative to the file in which you call --!NEEDS:''' (unless your path begins with a /)
 
'''PS: the path is relative to the file in which you call --!NEEDS:''' (unless your path begins with a /)
 
  
 
This will tell Gideros to load '''your_file.lua''' before the file containing the above code.
 
This will tell Gideros to load '''your_file.lua''' before the file containing the above code.
Line 18: Line 15:
  
 
The other Gideros Code Dependency you can implement by code is the exclude file. To tell Gideros the file should not be executed/parsed right on start but will be loaded through a require or a loadfile command, you can write:
 
The other Gideros Code Dependency you can implement by code is the exclude file. To tell Gideros the file should not be executed/parsed right on start but will be loaded through a require or a loadfile command, you can write:
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
--!NOEXEC
 
--!NOEXEC
</source>
+
</syntaxhighlight>
 +
 
 +
 
 +
You can also assign a name to library files:
 +
<syntaxhighlight lang="lua">
 +
--!LIBRARY:your_library_name
 +
</syntaxhighlight>
  
  
 
'''This is very useful if you develop a Lua library that is meant to be used in several projects.'''
 
'''This is very useful if you develop a Lua library that is meant to be used in several projects.'''
  
=== Example ===
+
=== Examples ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
--!NEEDS:../../tiled/tiled_ellipse.lua
 
--!NEEDS:../../tiled/tiled_ellipse.lua
 
--!NEEDS:luashader/luashader.lua
 
--!NEEDS:luashader/luashader.lua
 +
 +
--!LIBRARY:GiderosUI
 +
...
 +
--!NEEDS:(GiderosUI)/uistyle.lua
  
 
local function makeEffect(name,vshader,fshader)
 
local function makeEffect(name,vshader,fshader)
 
...
 
...
 
end
 
end
</source>
+
</syntaxhighlight>
  
 
=== See also ===
 
=== See also ===
 
'''[[Require]]'''
 
'''[[Require]]'''
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
| style="width: 50%; vertical-align:top;"|
 
=== Events ===
 
=== Constants ===
 
|}
 
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 14:30, 13 July 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.png
Available since: Gideros 2020.5

Description

You can now implement Gideros Code Dependency by code instead of Gideros project setting.

--!NEEDS:your_file.lua

PS: the path is relative to the file in which you call --!NEEDS: (unless your path begins with a /)

This will tell Gideros to load your_file.lua before the file containing the above code.


The other Gideros Code Dependency you can implement by code is the exclude file. To tell Gideros the file should not be executed/parsed right on start but will be loaded through a require or a loadfile command, you can write:

--!NOEXEC


You can also assign a name to library files:

--!LIBRARY:your_library_name


This is very useful if you develop a Lua library that is meant to be used in several projects.

Examples

--!NEEDS:../../tiled/tiled_ellipse.lua
--!NEEDS:luashader/luashader.lua

--!LIBRARY:GiderosUI
...
--!NEEDS:(GiderosUI)/uistyle.lua

local function makeEffect(name,vshader,fshader)
	...
end

See also

Require