Hallo,
You can retrieve and store the dice value from the gadget's wave state
like so:
var tempState = wave.getState();
var tempDiceValue = tempState.get("dice"); // gets the dice
value
if (! tempDiceValue) { // check we don't already have a value
set
var tempRollValue = Math.floor(Math.random()*6);
tempState.submitValue("dice", tempRollValue); // stores
dice value!
}
>From my understanding of your problem, you shouldn't need to worry
about concurrent users - but normally you would store values with
names that include the Viewer ID (e.g. instead of "vote" it would be
"vote"+wave.getViewer().getId()) and then you can loop through all the
values since they are all unique, one per user.
If you want to delete a value, call: tempState.submitValue("dice",
null);
For more details:
http://code.google.com/apis/wave/extensions/gadgets/reference.html
On Nov 5, 9:41 pm, Steven Melendez <[email protected]> wrote:
> Hi,
>
> I have a gadget as a dice roller (http://www.stevenkmelendez.net/
> wavediceroller.xml). It works fine to roll dice. However, if I leave
> the wave and reenter it, all the dice rolling gadgets go to their
> original form (with no dice roll information retained). How do I keep
> that information available AND if possible disable the gadget
> functions so it can't be 'rerolled'.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Wave API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-wave-api?hl=en
-~----------~----~----~----~------~----~------~--~---