As well as “on the previous page”, you can also use the random variable to immediately assign a non-random variable; after rolling but before you let the player do anything else, send it through a correspondence table and
*if roll=1
*set weapon “fish”
Or whatever you’re trying to do. Then refer only to the “weapon” variable from then on, so if “roll” gets re-randomized it doesn’t matter; it hasn’t been sent through the correspondence routine, so it won’t change “weapon”.
Err, pardon If I’m making an incredibly dumb observation,
but couldn’t one just do:
*create rolled "no"
Then several pages later:
if rolled = "no" [tab]*rand boop 6 98 [tab]*set rolled "yes"
and that would solve then entire problem? That’s pretty close to the code I used for my timer mod to deal with stats page’s issues.
You can create variables in places other than the startup page ?
But that can quickly get out of hand, no?
Anyway, good suggestion, I’ll give it a try.
Thank you.
EDIT: No, you can’t *create outside of startup.txt, but there’s no reason to create that variable outside of startup really. If you’re rolling several times on the same page, outside of the same *if block, then yes, it would get slightly out of hand since you’d need a separate variable to check by for each, however at the top of the page right after the roll you can do:
*set rolled "no"
and start again, though that won’t work for a setup like this:
*comment Page 1 *if rolled = "no" [tab]*rand boop 6 98 [tab]*set rolled "yes" *page_break *comment Page 2 *set rolled "no" *if rolled = "no" [tab]*rand snoot 6 98 [tab]*set rolled "yes"
Since the *set command is at the beginning of the page and will re*set when you come back from the stats screen.
Though I’m not sure as to why adding a simple clause in the JS of the scene file for most commands like so (though I’m pretty sure some of my syntax for (and understanding of) this is somewhat off):
this.ranonce; if(this.ranonce !== true){ /*The actual JS of the command*/ this.ranonce = true; }
is not already done, as from my point of view (which admittedly, is not encompassing of the entire operation of converting a js game to an app or the entirety of the functions in scene.js) this (or something like this) ought to solve the issue.
Hello! So, it turns out that I had this exact problem a while back, and although the only way to work around this problem seems to be separating the *rand from the results with a *page_break, with a bit of help I was able to solve the problem by setting up all of the *rand variables at the beginning of the game and labeling each differently. For example, *create X001, *create X002, ect. *rand X001 1 100, *rand X002 1 100, ect. Then at the point in the game it’s appropriate, I could, say, *if X004 > 50 -blah. *if X004 < 51 -noblah.
OK, thank you all for your help.
I don’t believe it would. The actual variable gets changed, whether or not it’s supposed to have hit that code. This is why it works to cheat at dice; without you replaying the “I re-roll my dice” paragraph, the actual roll changes.
Sort of.
If it’s a short-term variable, it’s a temp variable. It gets created at the top of the page with the *temp command, set at some point in that scene, and forgotten at the end of the scene.
So this is how you’d code
*if weapon="fish"
when the randomized things are numbers instead of text strings? What does the X stand for here?
But wouldn’t the *rand only reactivate if the if block’s condition is met? It’s not like just by being there that it’s executed after all, since it’s in an if block that has to be checked for either true/false first.
Ohh, I see what you’re saying - the *if statement would work like a *page_break or a variable reassignment to give a buffer between the code and the bug. Huh, you might’ve just found the best solution yet.
Someone have the time to go test this? Throw together a few lines of code with different variables, nest it in an *if, and see what happens?
Can confirm that it doesn’t work, though it ought to, for some reason going to the stats screen, even though the variable is saved in the stats (not temp) array, ignores the *set command entirely, as if it never happened and starts rolled back off at it’s original value.
EDIT: More info after some testing, it’s not heading to the stats screen that’s the problem, it coming BACK from it that resets things.
I work with a lot of *rand and the only really good solution I have found is to handle it is *page_break. I have a page just for all the rand rolls I need then some text then *page_break. So startup page then rand page then on to the game. Never have to call the random page again.
