Page 1 of 1

Order loading script files

Posted: Thu Sep 18, 2014 2:35 am
by Slayd
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

Re: Order loading script files

Posted: Fri Sep 19, 2014 8:18 am
by Slayd
I found my original problem.

The potions file had an error so it never was loaded. It was trying to use a value that hadn't been set yet; the problem only occurred when I first logged in so I assumed it might be a loading order problem.

So, bottom line, I don't need to have a specific load order on the scripts. I assume it just runs top to bottom as depicted in the editor.

Re: Order loading script files

Posted: Fri Sep 19, 2014 10:12 am
by phasma
Use pcall(). Saves so much hassle and headache when dealing with things like this.

Re: Order loading script files

Posted: Mon Apr 20, 2015 10:00 am
by rihmjihm
There was as PKGBUILD in AUR comments for mudlet-git which uses the latest git sources. Have to note that for me it acted really strange (had missing half of the line when copying to minconsole and such).
Also now that I know which distro are you using, I know why generic instaler won't work for you. Will write about it in that previous thread.

Re: Order loading script files

Posted: Mon Apr 20, 2015 10:02 am
by rihmjihm
hello everyone I'm having trouble working out how to send multiple affliction names from my curing table so far i can get the script to send sip unravel guilt if i'm afflicted with that but not for multiple afflictions such as if i'm afflicted with guilt and mindhaze i can't seem to figure out how to get it to send sip unravel guilt mindhaze here is the script i have any help would be appreciated and hopefully that's enough info