Jaxilon
September 21st, 2019, 20:08
I'm working on some updates for the GURPS ruleset and want to do some stuff when an item in the "inventory" window is changed for "equipped/carried/not carried".
I would like to hook the Event on the char_invlist.lua during the onCarriedChanged which seems logical to me.
I attempted to overlay this in my base.xml using:
<script name="CharInvList" file="campaign/scripts/char_invlist.lua" />
after copying the script to the campaign folder in GURPS.
On load of FG however I have problems:
Runtime Notice: Reloading ruleset
Script Error: [string "campaign/scripts/char_invlist.lua"]:25: attempt to call global 'getDatabaseNode' (a nil value)
Script Error: [string "campaign/scripts/char_invlist.lua"]:13: attempt to call global 'registerMenuItem' (a nil value)
Now, I could be doing something completely noob on this but somewhere in my reading I saw a note saying you can't always overlay certain codeblocks?? Thinking maybe that was it...
I then did my changes by over laying the code for "manager_char.lua" using:
<script name="CharManager" file="campaign/scripts/manager_char.lua" />
The only way I could see to hook the "equipped/carried/not carried" in this script is by putting my code in the "updateEncumbrance" code block.
It works!! But I don't like hooking it there as it is inefficient because every time ANY item is changed it goes through ALL the items to recalculate the Encumbrance.
So, my question is, can I over layer char_invlist.lua and/or is there a better way to capture this event so I can do my code?
Thanks in advance, I am quite new to LUA and moding in FG so I know there are holes in my understanding.
PS. Before anyone jumps me on it, I am running my changes through ronnke already, I just don't want to wear him out with my dumb questions and it seems unlikely I'm the first to run into this.)
Happy gaming!
I would like to hook the Event on the char_invlist.lua during the onCarriedChanged which seems logical to me.
I attempted to overlay this in my base.xml using:
<script name="CharInvList" file="campaign/scripts/char_invlist.lua" />
after copying the script to the campaign folder in GURPS.
On load of FG however I have problems:
Runtime Notice: Reloading ruleset
Script Error: [string "campaign/scripts/char_invlist.lua"]:25: attempt to call global 'getDatabaseNode' (a nil value)
Script Error: [string "campaign/scripts/char_invlist.lua"]:13: attempt to call global 'registerMenuItem' (a nil value)
Now, I could be doing something completely noob on this but somewhere in my reading I saw a note saying you can't always overlay certain codeblocks?? Thinking maybe that was it...
I then did my changes by over laying the code for "manager_char.lua" using:
<script name="CharManager" file="campaign/scripts/manager_char.lua" />
The only way I could see to hook the "equipped/carried/not carried" in this script is by putting my code in the "updateEncumbrance" code block.
It works!! But I don't like hooking it there as it is inefficient because every time ANY item is changed it goes through ALL the items to recalculate the Encumbrance.
So, my question is, can I over layer char_invlist.lua and/or is there a better way to capture this event so I can do my code?
Thanks in advance, I am quite new to LUA and moding in FG so I know there are holes in my understanding.
PS. Before anyone jumps me on it, I am running my changes through ronnke already, I just don't want to wear him out with my dumb questions and it seems unlikely I'm the first to run into this.)
Happy gaming!