Engine:CLUA require

Revision as of 22:40, 18 October 2023 by Bear (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 script in engine, in the 'global' contest:

lua require 'frame.lua'
// or
context lua
require 'frame.lua'

From lua:

require 'frame.lua'
-- or
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