PDA

View Full Version : Overwriting lua scripts in CoreRPG?



cscase
January 31st, 2014, 05:28
What is the best way to overwrite or alter a .lua in CoreRPG? I'm finding that, having included my own version of manager_options.lua and added it to base.xml, everything in my options dialog appears twice. It acts like both my script AND the one from Core are being used. Is that a bug, or am I just doing something wrong?

Thanks!

Moon Wizard
January 31st, 2014, 07:35
You shouldn't need to include your own version of manager_options.lua. It should just be a global script that you call to register options with. In CoreRPG, the option registrations for the base layer were moved to scripts/data_options_core.lua; to remove them from the OptionsManager script in case someone wanted to override.

To override a global script in Lua, you just make another script tag with the same global name.

Regards,
JPG

cscase
January 31st, 2014, 15:12
What I was trying to do was change the default setting for one of the options, and since a .lua file hasn't got a merge tag, I figured I would need to include a modified copy of the whole file. But even if I includes an exact copy of the file, with the same name and registered in my base.xml, it's clear that both scripts are being executed, since all of the options are doubled.I'm probably just being dense here. So then are the default options then pretty well set in stone in Core and can't be modified, only added to?

Trenloe
January 31st, 2014, 15:23
What I was trying to do was change the default setting for one of the options, and since a .lua file hasn't got a merge tag, I figured I would need to include a modified copy of the whole file. But even if I includes an exact copy of the file, with the same name and registered in my base.xml, it's clear that both scripts are being executed, since all of the options are doubled.I'm probably just being dense here. So then are the default options then pretty well set in stone in Core and can't be modified, only added to?
It sounds like have based your manager_options.lua file on an earlier release of the CoreRPG ruleset. As mentioned by Moon Wizard in post#2 the options are now in scripts/data_options_core.lua - if you still have the options code in your manager_options.lua then that is the reason for having double options as scripts/data_options_core.lua in CoreRPG is setting the options and then they are being set again in your manager_options.lua script.

I'd recommend having a look at scripts/data_options_core.lua and scripts/manager_options.lua in the latest version of CoreRPG (3.0.2) and try to work your new options into a new script called data_options_custom.lua (or a name specific to your ruleset) so that any options you have will not overwrite future CoreRPG options and you can add your own options knowing that you don't have to keep updating your .lua files with future releases of CoreRPG.

cscase
January 31st, 2014, 15:48
Ohhhhhh, okay - thanks for clarifying that, Trenloe. I see what you're saying. I'll dig around and see if I can figure out where I've missed the boat. Thanks all!

Trenloe
January 31st, 2014, 15:58
No worries - I was a little confused myself at first because the extracted form of the CoreRPG ruleset that I was looking at was older then the released 3.0.2 ruleset. I had to update to check... :)

cscase
February 1st, 2014, 02:01
Yep - this is exactly what was going on. I was looking at files from an older version of Core that I had extracted and didn't realize that stuff had moved. All good now. Thank you, gentlemen!