-
March 24th, 2022, 10:22 #31
What helped me understand the flow of a role was to put a debug message into each function of a script, something like "Debug.chat("FN: performRoll in manager_action_check")". This way you can see how the roll will flow and which script is called at what point in time. From there it is much easier to see how variables/records like rRoll are passed through.
You mentioned somewhere local rRoll in your posts. Keep in mind that rRoll usually doesn't need to be declared in a subsequent function after function "performRoll" as it is defined there for the roll and than passed on.
-
March 27th, 2022, 22:37 #32
Eureaka! I'm only adding this hear so that is some other vacuum headed twit like me is wondering how this works they can get a shortcut version.
Lots of debugs once i figured out the flow.
I can't do hit locations at the moment (currently if I try to call a different processRoll for locations it continuously spams rolls, but this may be a logic issue and not a rolling issue), but I have managed to do the Criticals (success, failure, spell, unarmed) by monitoring the chat.
The process roll is called within the onRecieveMessageTrigger function I have (thank you Celestian for 'showing' me how to do that -- ie. Audio Overseer was a huge help there for the very basics) which is called in the onInit via ChatManager.registerReceiveMessageCallback(onRecei veMessageTrigger).
The same basic code to parse what type of critical it is is used in both onRecieve... and onRoll, but the message is completed in onRoll (which is called with ActionsManager.registerResultHandler("criticals", onRoll) ; on Receive just sniffs out as the above paragraph says, but the real nuts and bolts are done in onRoll -- getting the total, adding to the message etc.; which is what everyone was saying, but I wasn't really understanding.
Somethings I have to tweak/find out yet are:
setting the message from GM to the actual critter/player 'rolling' the dice -- I think I can find that in the combat actions
is it BAD to call the processRoll from a modified version of actions_combat (GURPS has _melee and _ranged, so I would have to call from both of them) in an extension?
why has humanity not made a brain interface with computers that we can just think what we want and they do it?Anybody want a peanut!
-
September 17th, 2022, 21:22 #33
Does aDice[] have a length function, so you can get the number of dice rolled?
I'd like to handle each individual die result in a roll, but will have no way of determining how many dice will be rolled...
-
September 17th, 2022, 22:26 #34
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 21,509
It’s just a Lua table. If a Lua table has integer indexes starting at 1, you can use #tablename to get the length; otherwise, you have to iterate over table using pairs function to count.
In this case, the dice table returned die shave numerical indexes (plus a couple other string indexes), so # operator should work.
Note that if you edit the dice table, you’ll have to make sure that it is still numerically ordered.
Regards,
JPG
-
September 17th, 2022, 22:33 #35
What would that syntax look like?
rRoll.aDice.#tablename ?
I tried table.maxn(rRoll), but it returned a value of 0...
table.getn(rRoll) also returns a value of 0...
Code:function KillDiceResult(rSource, rTarget, rRoll) local rMessage = ActionsManager.createActionMessage(rSource, rRoll); local nodeChar = rSource.sCreatureNode; -- Debug.chat("nodeChar: ", nodeChar); local sIcon; if rSource.sType == "npc" then sIcon = "portrait_gm_token"; else sIcon = DB.getValue(nodeChar .. ".token"); sIcon = string.gsub(sIcon, "token", "chat"); end rMessage.icon = sIcon; Debug.chat("# Dice: " .. table.getn(rRoll)); end
Last edited by bloodylemming; September 17th, 2022 at 23:01.
-
September 18th, 2022, 01:14 #36
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 21,509
#(rRoll.aDice)
JPG
-
September 18th, 2022, 01:53 #37
Thread Information
Users Browsing this Thread
There are currently 2 users browsing this thread. (0 members and 2 guests)
Bookmarks