MeepoSose
September 4th, 2009, 16:58
I am having a problem sharing info from a global script.
I am trying to create a bunch of lookup values I can share across all scripts. I added the following line to the extension.xml file under the <base> element:
<script name="Lookups" file="scripts/global_lookups.lua" />
I declare a bunch of tables inside that file as global variables (i.e., not prefaced with "local <variablename>" and then I try to reference them from another script. I always seem to get an error about attempting to index a nil value. The lua references I saw online indicate this should work but maybe this is a known limitation on the implementation of lua within FG. Anyone know?
print(Lookups.myVariable); returns a nil attempting to index global "Lookups"
Other things I tried with similar results are
dofile("global_lookups.lua");
require("global_lookups.lua");
module("global_lookups.lua");
within the onInit function of my calling script. For each of those attempts, it doesn't recognize "dofile", "require" or "module."
I am trying to create a bunch of lookup values I can share across all scripts. I added the following line to the extension.xml file under the <base> element:
<script name="Lookups" file="scripts/global_lookups.lua" />
I declare a bunch of tables inside that file as global variables (i.e., not prefaced with "local <variablename>" and then I try to reference them from another script. I always seem to get an error about attempting to index a nil value. The lua references I saw online indicate this should work but maybe this is a known limitation on the implementation of lua within FG. Anyone know?
print(Lookups.myVariable); returns a nil attempting to index global "Lookups"
Other things I tried with similar results are
dofile("global_lookups.lua");
require("global_lookups.lua");
module("global_lookups.lua");
within the onInit function of my calling script. For each of those attempts, it doesn't recognize "dofile", "require" or "module."