Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I load and execute a lua file from within another lua file

Tags:

lua

I have a lua script which is run using the command line interpreter, the script needs to load a table from a file. The table is stored like this:

create_object_action = {
    reflexive = true,
    which_base_type = 29,
    how_many_min = 1,
    how_many_range = 0,
    velocity_relative = false,
    direction_relative = true,
    random_distance = 0
}

How can I load the data in the table into the global namespace?

like image 588
GameFreak Avatar asked Oct 05 '09 18:10

GameFreak


People also ask

How do I open a Lua file in Lua?

To run a Lua scriptOpen the Lua Script Library through Prepare > Run Lua Script. Use the appearing dialog to load, save, and execute Lua scripts as well as to create new ones. Select the script to be run. Click Execute Script.

How do you call a function from another script in Lua?

If one script needs to explicitly call a function in another script, you can use Lua modules. Modules are scripts that return some value and allow other scripts to access that value.


1 Answers

dofile "mytables.lua"
like image 186
Warren Young Avatar answered Sep 19 '22 14:09

Warren Young