Engine:CLUA require: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Created page with "{{dev/uiclua}} Loads and runs lua text file asset from engine data. <kua>require "file.lua"</kua> == Arguments == * name - name and path of the file to be run == Associations == * Is by default placed in the default Lua runtime. == Details == A global Lua runtime function that loads and runs verbatim a Lua code file in the current Lua runtime. No parameters are passed when run. Will be loaded as a chunk and executed. The chunk will have no references to it such tha...")
 
Line 16: Line 16:
== Examples ==
== Examples ==
=== Default values ===
=== Default values ===
From lua:
<lua>
require 'frame.lua'
-- or
require('frame.lua')
</lua>
From script in engine, in the 'global' contest:
From script in engine, in the 'global' contest:
<kua>
<kua>
Line 23: Line 29:
require 'frame.lua'
require 'frame.lua'
</kua>
</kua>
From lua:
<lua>
require 'frame.lua'
-- or
require('frame.lua')
</lua>
: All of these will effectively run the Lua 'require' function in the current Lua runtime, load the script file from data, and load it and run it in the calling Lua runtime.
: All of these will effectively run the Lua 'require' function in the current Lua runtime, load the script file from data, and load it and run it in the calling Lua runtime.


== Notes ==
== Notes ==
*
*

Revision as of 22:40, 18 October 2023

Console commands

Loads and runs lua text file asset from engine data.

require "file.lua"

Arguments

  • name - name and path of the file to be run

Associations

  • Is by default placed in the default Lua runtime.

Details

A global Lua runtime function that loads and runs verbatim a Lua code file in the current Lua runtime. No parameters are passed when run.

Will be loaded as a chunk and executed. The chunk will have no references to it such that the chunk should be garbage collected after being run.

Examples

Default values

From lua:

require 'frame.lua'
-- or
require('frame.lua')

From script in engine, in the 'global' contest:

lua require 'frame.lua'
// or
context lua
require 'frame.lua'
All of these will effectively run the Lua 'require' function in the current Lua runtime, load the script file from data, and load it and run it in the calling Lua runtime.

Notes