PDA

View Full Version : Table values sometimes a string



frostbyte000jm
September 8th, 2020, 21:15
I was working on some dice last night and this was an issue I was running into. I am attaching an extension that works with MoreCore (it isn't specific to MoreCore it is just the easiest extension I could make to show my problem).

If you load the extension and make a roll from a character sheet of "/dice_mod" and "/dice_mod2" and look at the results in the console window you may see what is the problem.

What is happening?
My code on both of these dice are very simple.

/dice_mod
In performAction() I have a table "aRoll" in aRoll I have some numbers, strings, and booleans.
I then do a very simple for loop where I add dice to aRoll.aDice

I then do a Debug.console check and these are still numbers, booleans, and strings.

It then performs ActionsManager.performAction() and my onLanded() function does another Debug.console check.

What happens is when I do the console check after onLanded() the bools are empty, the numbers are strings, and the strings are fine.

/dice_mod2
This coded the same, the only difference is I do not load dice into aRoll.aDice.

My onLanded() does NOT lose the numbers and bools.


Now that I know this is a thing, I can easily work with it, but anyone know why this is a thing?

copy paste of test:
/dice_mod
Runtime Notice: s'*** performAction() ***'
Runtime Notice: s'draginfo: ' | nil | s' rActor: ' | { s'sType' = s'pc', s'sCreatureNode' = s'charsheet.id-00001', s'sCTNode' = s'combattracker.list.id-00001', s'sName' = s'Character Sheet' } | s' sParams:' | s' dice_mod'
Runtime Notice: s'*** End performAction() ***'
Runtime Notice: s'aRoll.nExplodeValue' | #0
Runtime Notice: s'aRoll.nCapHits' | #9999
Runtime Notice: s'aRoll.nGlitchValue' | #1
Runtime Notice: s'aRoll.bTest' | bFALSE
Runtime Notice: s'aRoll.bTest2' | bTRUE
Runtime Notice: s'aRoll.sStringTest' | s'I am a String'
Runtime Notice: s'*** onLanded(rSource, rTarget, rRoll) ***'
Runtime Notice: s'rRoll.nExplodeValue' | s'0'
Runtime Notice: s'rRoll.nCapHits' | s'9999'
Runtime Notice: s'rRoll.nGlitchValue' | s'1'
Runtime Notice: s'rRoll.bTest' | s''
Runtime Notice: s'rRoll.bTest2' | s''
Runtime Notice: s'rRoll.sStringTest' | s'I am a String'

/dice_mod2
Runtime Notice: s'*** performAction() ***'
Runtime Notice: s'draginfo: ' | nil | s' rActor: ' | { s'sType' = s'pc', s'sCreatureNode' = s'charsheet.id-00001', s'sCTNode' = s'combattracker.list.id-00001', s'sName' = s'Character Sheet' } | s' sParams:' | s' dice_mod2'
Runtime Notice: s'*** End performAction() ***'
Runtime Notice: s'aRoll.nExplodeValue' | #0
Runtime Notice: s'aRoll.nCapHits' | #9999
Runtime Notice: s'aRoll.nGlitchValue' | #1
Runtime Notice: s'aRoll.bTest' | bFALSE
Runtime Notice: s'aRoll.bTest2' | bTRUE
Runtime Notice: s'aRoll.sStringTest' | s'I am a String'
Runtime Notice: s'*** onLanded(rSource, rTarget, rRoll) ***'
Runtime Notice: s'rRoll.nExplodeValue' | #0
Runtime Notice: s'rRoll.nCapHits' | #9999
Runtime Notice: s'rRoll.nGlitchValue' | #1
Runtime Notice: s'rRoll.bTest' | bFALSE
Runtime Notice: s'rRoll.bTest2' | bTRUE
Runtime Notice: s'rRoll.sStringTest' | s'I am a String'

Moon Wizard
September 10th, 2020, 00:28
The ActionsManager helper script uses the getMetaData/setMetaData functions in the roll object to store the data, which only accepts key-value pairs of strings.
When your /dice_mod script is run, then the dice are rolled, the meta-data is attached, and the roll data is rebuilt from the saved meta-data.
When your /dice_mod2 script is run, then the ActionsManager helper script notes that there are no dice; so it short circuits directly to resolution without having to pass the information to the main client.

When assigning data to the "roll" structure/table that you want to read back; make sure to use strings or numbers.

Regards,
JPG

frostbyte000jm
September 10th, 2020, 00:38
The ActionsManager helper script uses the getMetaData/setMetaData functions in the roll object to store the data, which only accepts key-value pairs of strings.
When your /dice_mod script is run, then the dice are rolled, the meta-data is attached, and the roll data is rebuilt from the saved meta-data.
When your /dice_mod2 script is run, then the ActionsManager helper script notes that there are no dice; so it short circuits directly to resolution without having to pass the information to the main client.

When assigning data to the "roll" structure/table that you want to read back; make sure to use strings or numbers.

Regards,
JPG

This makes a lot of sense. Thank you.

I am going to have another, but I need to build a test to make sure it wasn't something I did.