PDA

View Full Version : Replacing script in layered setup



celestian
February 11th, 2017, 23:48
So I'm having an issue using "my" version of a script over a one in a layered ruleset (5e).

I'm trying to use my own "campaign\scripts\char_weapon.lua".

When I have the file in the directory and included in the base.xml I get the following error when I bootup FG using this ruleset.

Script Error: [string "campaign/scripts/char_weapon.lua"]:7: attempt to call global 'getDatabaseNode' (a nil value)

I'm probably missing some procedure here but I can't seem to figure it out.

I should mention this script (right now) is exactly like the one in the 5e ruleset. I just need to make some tweaks and this was my first step.

damned
February 12th, 2017, 00:22
You probably need to include it the same way its been included in 5e - you will need the windowclass with a merge=join statement.

celestian
February 12th, 2017, 04:45
You probably need to include it the same way its been included in 5e - you will need the windowclass with a merge=join statement.

The base.xml doesn't mention "char_weapon.lua" anywhere. Also checked that it wasn't in the CoreRPG ruleset.

I included the .xml file (and the <includefile source="campaign/record_char_weapon.xml" />) where the script was included.

Right now the changes I've made since work but I'd like to figure out what is up. I'm getting the impression somewhere FG is loading the 5e and the one I have both but I could be entirely wrong.

I'll do a search everything for "merge" to see if I can find something.

damned
February 12th, 2017, 04:53
char_weapon.lua is called by the windowclass char_weapon which is in the file campaign\record_char_weapon.xml
you will either replicate the entire window class or you will use a merge statement to only include the minimum required to ensure that the
<script file="campaign/scripts/char_weapon.lua" />
line is loaded. this will load after corerpg and after 5e have loaded so it will be using your versions.

I believe that you will get away with:

<windowclass name="char_weapon" merge="join">
<script file="campaign/scripts/char_weapon.lua" />
</windowclass>

depending on what else you have change in the lua...

celestian
February 12th, 2017, 07:12
char_weapon.lua is called by the windowclass char_weapon which is in the file campaign\record_char_weapon.xml
you will either replicate the entire window class or you will use a merge statement to only include the minimum required to ensure that the
<script file="campaign/scripts/char_weapon.lua" />
line is loaded. this will load after corerpg and after 5e have loaded so it will be using your versions.

I believe that you will get away with:

<windowclass name="char_weapon" merge="join">
<script file="campaign/scripts/char_weapon.lua" />
</windowclass>

depending on what else you have change in the lua...


Thanks for taking the time to look into the code/scripts and reply!

After you mentioned "merge" and "join" I found some examples and tried a few variations . One of which is the one you suggested above. I tried just adding the merge="join" (and keeping the xml in there as well) and it still caused the error. I then took your advice and trimmed down the class to just the above... it still has the error ;(

I'll keep poking around.

So, to rule out this was anything I was messing up I created a bare bones base.xml.



<importruleset source="CoreRPG" />
<importruleset source="5E" />

<includefile source="campaign/record_char_weapon.xml" />

<script name="CharWeapon" file="campaign/scripts/char_weapon.lua" />


and then copied the campaign/record_char_weapon.xml and campaign/scripts/char_weapon.lua from 5e into it and then modified the line in record_char_weapon.xml



<windowclass name="char_weapon" merge="join">


(and left the rest of the code, just added merge="join")

And the error is still popping up.

damned
February 12th, 2017, 08:12
Ok - are you creating a ruleset or an extension?
You dont importruleset in an extension you do that in a layered ruleset.

Why have you declared this script?
<script name="CharWeapon" file="campaign/scripts/char_weapon.lua" />
In the posts above we said you dont do that - thats not how the 5e ruleset calls this file - it calls it from within campaign/record_char_weapon.xml

I created the extension exactly as suggested above in post #4 and added a Debug.console("Hello Strahd"); line to the lua file and it executes as expected and no errors are generated.

celestian
February 12th, 2017, 17:05
Ok - are you creating a ruleset or an extension?
You dont importruleset in an extension you do that in a layered ruleset.

I'm making a layered ruleset.



Why have you declared this script?
<script name="CharWeapon" file="campaign/scripts/char_weapon.lua" />
In the posts above we said you dont do that - thats not how the 5e ruleset calls this file - it calls it from within campaign/record_char_weapon.xml

I created the extension exactly as suggested above in post #4 and added a Debug.console("Hello Strahd"); line to the lua file and it executes as expected and no errors are generated.

Woops, yeah that was something I tested previously and just copied into the test. Removing that cleared up the error ;)

Apologies for the run around. Still trying to get my footing on how things work in FG. Thank you for your help!