I have currently written a Twine passage (Sugarcube) which allows for a 2d6 dice roll and updates the player’s score accordingly.
Whatever changes I have tried, it’s currently possible for the player to roll the dice as many times as they like (thus giving them infinite opportunities to get the highest scores possible!)
Has anyone had any experience of writing dice-rolling macros that limits the player to just one dice roll? - My code contains variables such as:
<<if not $diceRolled>>
<<link “Roll the Dice”>> (etc)
And
<<set $diceRolled to true>>
Whatever I try the player can still roll multiple times
Just to be clear, the end-user can still alter such a dice roll by executing JavaScript like the following within their web-browser’s Console just before they select that link…
$(document).one(':passageinit', function (ev) {
SugarCube.State.variables.roll = 6;
});
Or if they know that the variable name doesn’t change, and that the maximum value that variable will contain is consistent, then their could execute JavaScript code like the following in that Console at the start of a playthrough…
$(document).on(':passageinit', function (ev) {
SugarCube.State.variables.roll = 6;
});
…and that variable will always equal that value after ever Passage Transition.
@TobiasRoadRunner
The simple fact is that you can’t stop the end-user from altering the outcomes, or as you put it “cheating”, as there are always ways around any efforts you take to do so.
And besides their own playthrough, who else are they affecting by doing such alterations?