-
December 1st, 2014, 03:29 #21
Doh! What does that even mean! My head hurts....
Ok - searching for actioninit reveals - base.xml
Code:<script name="ActionInit" file="scripts/manager_action_init.lua" />
with 2 results
Code:<!-- Begin Init Roll --> <template name="number_charinit"> <number_chartotal> <rollable /> <displaysign /> <tooltip><text>Initiative. Double Click to Roll. 2d10+Speed. Highest Initiative Acts First.</text></tooltip> <modifiersize>mini</modifiersize> <description textres="initiative" /> <modifierfield>initiative.temporary</modifierfield> <source><name>initiative.misc</name><op>+</op></source> <script> function action(draginfo) local rActor = ActorManager.getActor("pc", window.getDatabaseNode()); ActionInit.performRoll(draginfo, rActor); return true; end function onDragStart(button, x, y, draginfo) return action(draginfo); end function onDoubleClick(x,y) return action(); end </script> </number_chartotal> </template> <!-- End Init Roll -->
Code:<template name="number_charinit"> <number_chartotal> <rollable /> <displaysign /> <modifiersize>mini</modifiersize> <description textres="initiative" /> <modifierfield>initiative.temporary</modifierfield> <source><name>initiative.misc</name><op>+</op></source> <script> function action(draginfo) local rActor = ActorManager.getActor("pc", window.getDatabaseNode()); ActionInit.performRoll(draginfo, rActor); return true; end function onDragStart(button, x, y, draginfo) return action(draginfo); end function onDoubleClick(x,y) return action(); end </script> </number_chartotal> </template>
but back on track - I believe that that syntax should execute the whole function which includes the lines:
Code:local sSpeed = DB.getValue(nodeActor, "abilities.speed.temp", 0) Debug.console("sSpeed = " .. sSpeed);
Code:function performRoll(draginfo, rActor, bSecretRoll) local rRoll = {}; rRoll.sType = "init"; rRoll.sDesc = "[INIT 2d10 + Speed - Armour Penalty] result "; rRoll.bSecret = bSecretRoll; -- Determine the die to use rRoll.aDice = { "d10","d10" }; -- Determine the modifier to use for this roll local sSpeed = DB.getValue(nodeActor, "abilities.speed.temp", 0) Debug.console("sSpeed = " .. sSpeed); local nSpeed = tonumber("sSpeed"); Debug.console("nSpeed = " .. nSpeed); rRoll.nMod = nSpeed; local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor); if nodeActor then if sActorType == "pc" then rRoll.nMod = DB.getValue(nodeActor, "initiative.total", 0); else rRoll.nMod = DB.getValue(nodeActor, "init", 0); end end ActionsManager.performAction(draginfo, rActor, rRoll); end
-
December 1st, 2014, 03:46 #22
i lied.
one of these changes has caused the debug to go off...
Code:Runtime Notice: s'L53: sSpeed = 0' Runtime Notice: s'L55: nSpeed = ' | nil
-
December 1st, 2014, 04:06 #23
nodeActor doesn't exist at the point you're trying to use it. You need to code after it is created: local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
December 1st, 2014, 06:07 #24
Wow. So that *did* make sense.
Why was I running it where I was running it? I wanted to modify nMod and thought that was the best spot.
After making the change I have gone back and ripped out a bunch of changes in that file and simplified it.
Code:function performRoll(draginfo, rActor, bSecretRoll) local rRoll = {}; rRoll.sType = "init"; rRoll.sDesc = "[INIT 2d10 + Speed - Armour Penalty] result "; rRoll.bSecret = bSecretRoll; -- Determine the die to use rRoll.aDice = { "d10","d10" }; -- Determine the modifier to use for this roll rRoll.nMod = 0; local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor); -- Determine the modifier to use for this roll local nSpeed = DB.getValue(nodeActor, "abilities.speed.temp", 0); Debug.console("nSpeed = " .. nSpeed); if nodeActor then if sActorType == "pc" then -- rRoll.nMod = DB.getValue(nodeActor, "initiative.total", 0); rRoll.nMod = DB.getValue(nodeActor, "abilities.speed.temp", 0); else rRoll.nMod = DB.getValue(nodeActor, "init", 0); end end ActionsManager.performAction(draginfo, rActor, rRoll); end
-
December 1st, 2014, 06:24 #25
but of course... this leads on to at least one more question...
I need to add a secondary modifier to this - Ive added the current speed value (abilities.speed.temp) but I also need to detract the current armour penalty value (ac.totals.penalty).
Grabbing that should be straight forward now...
Code:local nPenalty = DB.getValue(nodeActor, "ac.totals.penalty", 0); Debug.console("nPenalty = " .. nPenalty);
Taking a punt here...
Code:if nodeActor then if sActorType == "pc" then -- rRoll.nMod = DB.getValue(nodeActor, "initiative.total", 0); rRoll.nMod = nSpeed - nPenalty; else rRoll.nMod = DB.getValue(nodeActor, "init", 0); end end
Now to work out how to replicate this to the other new fields in the Combat Tracker... END WNDS AR...
Attachment 8186
-
December 1st, 2014, 15:37 #26
As mentioned in post#10 above, the best way to do this is to use the the linkPCFields() function tied with <number_ct_crosslink> controls - see the C&C files ct\scripts\ct_entry.lua and ct\ct_host.xml, respectively.
One line from the linkPCFields() function is:
hp.setLink(nodeChar.createChild("hp.total", "number"));
This is of the form: <control name>.setLink(nodeChar.createChild("<charsheet DB field>", "number"));
<charsheet DB field> is the database field in the <charsheet><id-XXXXX> character sheet entry in the campaign database.
The control has to be of type <number_ct_crosslink> and this has been defined in ct_host.xml as:
Code:<number_ct_crosslink name="hp"> <anchored to="rightanchor" width="30" height="20"> <top /> <right anchor="left" relation="relative" offset="-10" /> </anchored> <tabtarget prev="initresult" next="hptemp" /> <script> function update() window.onHealthChanged(); end </script> </number_ct_crosslink>
Follow the syntax used in the C&C ruleset for similar fields in the combat tracker.
Note: Use the above <number_ct_crosslink> controls only in the ct_host.xml file, for the PC side, use <number_ct_static>, for example from the C&C ct_client.xml:
Code:<number_ct_static name="hp"> <anchored to="rightanchor" width="30" height="20"> <top /> <right anchor="left" relation="relative" offset="-10" /> </anchored> <script> function onValueChanged() window.onHealthChanged(); end </script> </number_ct_static>
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks