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...")
 
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:
== Examples ==
== Examples ==
=== Default values ===
=== Default values ===
From script in engine, in the 'global' contest:
From lua:
<lua>
require 'frame.lua'
-- or
require('frame.lua')
</lua>
From script in engine, in the 'global' context:
<kua>
<kua>
lua require 'frame.lua'
lua require 'frame.lua'
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 ==
*
*

Latest revision as of 22:41, 18 October 2023

Console commands

Loads and runs lua text file asset from engine data.

require "file.lua"

Arguments[edit]

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

Associations[edit]

  • Is by default placed in the default Lua runtime.

Details[edit]

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[edit]

Default values[edit]

From lua:

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

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

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[edit]