I am trying to put a Dice Tray into two modules. The graphics work but not the reported text. Instead of writing the correct number in the text line with some dice I get the previous number rolled. Instead of writing a very long request here I have put it in a folder in Dropbox at
The document is in both Word and RTF. Both are the same.
I haven’t actually looked at the module yet (won’t have time for a few days, probably), but my first guess is that you have the dice roll and the report triggering off the same Key Command, and they don’t consistently fire in the correct order. If that’s the case, try using a Trigger Action to ensure the roll occurs, then the report action.
If that’s not it, I’ll try to take a look later this week.
I agree with jr except they do fire in the same order. It happens to be backwards for you. Before trying the trigger, try moving the report trait up and down in the piece’s trait list.
Is it the module Dice Tray with Re Roll.vmod? When I open it, the first thing I see is
Bad Data in Module: Source: 2d10.png Error: Image not found
That would be a problem. Remember to add the image to the module.
It also points to the source of your problem, I think. If your property name starts with a digit - e.g., 2d6, then you need to get the property value with something like GetProperty or GetString. Instead of saying
{"Die roll is "+2d6_result}
you would do
{Die roll is "+GetString("2d6_result")}
in say a ReportTrait. The reason being that before the die roll is made, and before the property has been evaluted, the internal BeanShell interpreter will see 2d6_result as an (invalid) number constant. Once the property has been evaluated once, it is known, and property is properly retrieved.
Prompted by
I think the above analysis isn’t entirely problem - how ever, your flow is
Press 2d6 sends commnand 2d6
Picked up by two pieces (in random order - I think). Each piece does
Black does TriggerTrait w/command 2d6
Pick random layer LayerTrait command Roll Black 1
Put inside tray SendToLocation command Black1 Roll
Store random layer number in global property GlobalPropertyTrait command Black1, property Black1
White does TriggerTrait w/command 2d6
Pick random layer LayerTrait command Roll White 1
Put inside tray SendToLocation command White1 Roll
Store random layer number in global property GlobalPropertyTrait command White1, property White1
Report result by ReportTrait reacting to command White1
As I see it, there’s several problems here. First off, you do not know which of the two pieces, Black1 and White1, will be triggered first, and there’s not reason to think Black1 will be set before the command White1 is fired. You need some way of synchronizing the commands being execute.
So here’s what I would do.
First off, I would probably make the tray a Zone with an irregular grid and define Regions where each die will end up. E.g., the region Black1InTray for the first black die, White1InTray for first white die, etc. Then you SendtoTraits can simply set Region={BasicName+"InTray"}. In fact, you could put the SendtoTrait into a prototype
Define Black1 and White1 pieces more or less the same
Add PrototypeTrait with name = Die prototype
Define LayerTrait
Name: Roll
Images: [white_1,png,white_2.png,...] and [black_1.png,black_2.png,...]
Randomize: randomLayer
Define GlobalPropertyTrait
Action:
Key: postResult
Type: DIRECT
Expression: {Roll_level}
Property: White1_result and Black1_result, respectively
The point is that the hidden piece 2d6_roller will take care of the synchronization because takeResult will not be executed before both rollWhite1 and rollBlack1 have finished.
Also, you do not need NonRectangularTrait - your images are rectangular. That trait should really only be used for circles, hexes, triangles, …, or some other crazy shapes.
If you define all the dice you need, say 5 d6’: Black1, White1, Red1, Green1, Blue1, then you easily make new die-rolls by adding more hidden pieces and MassHotkeys like the ones above. Of course, if you need more than one die roll in the tray at the same time, you may need to make additional dice pieces.
WRT to colour: Yes - just use regular HTML mark-up in the ReportTrait. E.g.,
Thank you for your very quick replies.
With regard to
Bad Data in Module: Source: 2d10.png Error: Image not found
The Dice Tray in Game of Drones had several kinds of dice D6, D8, D10, D12 and D20. I did not use the D10 routines in the module but they were copied over when I added Dice Tray to Tarawa. As not used the image did not get over written.
The NonRectangularTrait is there because it was in the original Game of Drones and I did not know why and so left it in.
There is a lot for me in your replies for me to understand. This module is the first one I have used Trigger Action in. I am in that position of copying code when I do not fully understand how it works.
There is a lot in your replies for me to study and understand. Back to the reference manual.