PDA

View Full Version : UserData



Ken L
December 5th, 2017, 22:22
Late yesterday, I had an issue with setting the token-field value in the combat tracker as it claimed I couldn't as it was 'user data'. The Token in question was from a map on which other tokens from the combat tracker existed. Note it didn't outright reject the token, but in token manager during the initialization, it vomited up a turd and broke both the ct_entry as well as the token on the image. Imagewindow already does this so I figured I'd follow in their footsteps and do the same (image.lua i believe).

There's very little on how FG classifies 'UserData' and even less on why it may reject data sources. What exactly is happening with this? I'd give a more through example but I currently can't and, when I get back I need to run a game. So I'm posting to see if I can perhaps get something to think about tomorrow.

Moon Wizard
December 6th, 2017, 05:15
User data is any custom data type in Lua, which is the basis for all FG data types in Lua. It sounds like something is not being passed as expected.

I wouldn’t be able to provide any input without seeing the code that is affected, along with any code that generates parameters processed by the code where it’s failing.

Regards,
JPG

Ken L
December 6th, 2017, 23:37
You were right on the money, it was a pretty silly mistake (pass ref vs pass val). Been working with one too many languages it seems.

The objective was to push a token of an NPC that was dying/dead/unconscious to the 'features_image', and to pull it back to the 'play_image' once it regained enough health. This allows me to use 'dead bodies as difficult terrain', a house rule for my chop-shop group. Prior I had to flip to the features layer and drop a blood stain or some odd, this automates the process, but it required cloning the token prototype, then reassigning the token references on the tracker to the new token and deleting the old as it flipped 'layers'.

Moon Wizard
December 6th, 2017, 23:47
Glad you figured it out. Thanks for letting me know.

Cheers,
JPG