Order loading script files
Posted: Thu Sep 18, 2014 2:35 am
I have a group of script files under a directory Lusternia in my mudlet editor.
I started grouping functions under separate tables, one to a script file. So I have defined a 'ui' script file and in it, I have set up a table like 'ui = ui or {}', then below it I have functions like 'function ui:init_gauges()' etc.
I have one script file, driven by an event, onPrompt. The driving function is called process_prompt(). In that function, I call a function potions:check_health(). When I wasn't seeing the expected action when first logging in to that Lusternia account, I checked errors. It was choking on the global variable 'potions' being null. potions is a table set up in a separate script file like my ui example above.
If I set the potions variable to nil, the go into the editor and resave the potions script file, everything functions as expected.
So I am assuming that potions is not known to the lua space at the time process_prompt() is initially loaded into the lua space. I've tried putting the potions script file at the top of the directory and the event script file at the bottom, but I still see the problem.
How do I overlay an order on loading. If these script files were separate lua files, I know I could use 'require'. Will that work within mudlet? Or do I need to maintain separate lua files in my current directory, outside of mudlet?
Thanks
I started grouping functions under separate tables, one to a script file. So I have defined a 'ui' script file and in it, I have set up a table like 'ui = ui or {}', then below it I have functions like 'function ui:init_gauges()' etc.
I have one script file, driven by an event, onPrompt. The driving function is called process_prompt(). In that function, I call a function potions:check_health(). When I wasn't seeing the expected action when first logging in to that Lusternia account, I checked errors. It was choking on the global variable 'potions' being null. potions is a table set up in a separate script file like my ui example above.
If I set the potions variable to nil, the go into the editor and resave the potions script file, everything functions as expected.
So I am assuming that potions is not known to the lua space at the time process_prompt() is initially loaded into the lua space. I've tried putting the potions script file at the top of the directory and the event script file at the bottom, but I still see the problem.
How do I overlay an order on loading. If these script files were separate lua files, I know I could use 'require'. Will that work within mudlet? Or do I need to maintain separate lua files in my current directory, outside of mudlet?
Thanks