Szaal
406
Ah, I see.
Well, a pro tip for everyone reading this.
Conditional check on choice #options require parentheses, no matter what.
*choice
*selectable_if (condition) #option
is valid, while
*choice
*selectable_if condition #option
is not. Be mindful especially if you’re using single boolean variable or multiple conditions. Also applies to standard *if.
However, you can do *if condition if (no pun intended) it’s for normal passage.
7 Likes
Didn’t even think of that, but since I always use parenthesis even on single variables as a matter of standard I never had trouble with choice conditions.
Gower
408
And therefore, you have to do
*choice
*selectable_if (not (condition)) #option
To get a “not” condition in a selectable_if. Just as a matter of general interest.
At least, I think so.
4 Likes
A quick question: can you successfully call a temp var that was declared in scene A, while in subroutine in scene B? And as an aside, do vars that were randomed in scene A retain their values in memory after the same gosub_scene? Or is it null return/reroll?
Szaal
410
If the definition is correct,
temporaries won’t be removed/deleted until you leave the scene it’s created. *gosub isn’t a “scene-leaving” action as you’re essentially keeping the scene in background, opening the sub-scene.
Then yes, you should be able to call the variable, as long as they don’t share a same name. I never tested this, though, as I never done recalling temps on other scene; *params exists.
Also yes to second question; they retain the randomized value (as long as the *return doesn’t put it through another *rand)
1 Like
Palm meets face. Guess who forgot about *params completely and thought to reinvent the bicycle. Thank you!
1 Like
Quick question for I am noob. *line_break doesn’t seem to be workings anymore?
In the early stages of my coding I like to use a lot of *goto’s and whenever I try to line break now it won’t do it. Regardless of whether or not I put it after the choice dialogue, or right before the new dialog under the *label.
1 Like
Try using [n/] instead. I believe it does the same thing.
1 Like
It has been a long time since I had to create a new stat screen. How do I code it when the variable isn’t going to show the same as what I call it in code? For example, to get the variable flex to show as Flexibility?
The stat_chart vars you mean here?
*stat_chart
text flex Flexibility
percent char Charisma
opposed_pair dec
Deceitful
Honest
^basic 3 examples. Text, % bar and opposed pair.
1 Like
Is there any way to get a gaussian random number - i.e. a random number, but from a gaussian distribution so you have more chance of central numbers occurring than the extremes; rather than just “*rand [var] x y” which has an equal chance of numbers x to y.
edit: the only way i could think of doing something even remotely similar it is bodging something like:
*rand var 1 10
*if var < 5
*set var + 1
*if var > 5
*set var - 1
which just shifts the extremes towards the middle rather crudely & also means numbers 1 and 10 can never occur. not very satisfactory.
Expand the range to 0 → 11
You can further split the conditionals to refine the result (0->2 do this, 2->5 do that etc).
1 Like
yah i thought about that but then the probabilities are just 1 in 12 for var to = 1-4 and 6-10 and 1 in 4 for var to = 5; which i think is further from what i want than 0 in 10 for 1 and 2, 1 in 10 for 2-4 and 6-9 and 3 in 10 for 5…if that makes sense.
really what i want is like a 1 in 30 chance of rolling a 1 or 10, a 1 in 20 of rolling a 2 or 9, a 1 in 10 chance or rolling a 3 or 8 etc
1 Like
Szaal
419
I imagine you would have to code the function itself, although I’m not sure CS understands pi or number e. Should probably define those to several decimals.
Szaal
420
*create pi 3.14159265359
*create e 2.71828
*create gauss 0
*create mean 0
*create
Whoops. Editing.
In the mean time, I think one way you can simulate a gaussian PDF is by brute-forcing your dice into a histogram of the PDF. Consider a d6.
*rand dieroll 1 20
*if dieroll <= 2
*set dieroll 1
*elseif (dieroll > 2) and (dieroll <= 5)
*set dieroll 2
*elseif (dieroll > 5) and (dieroll <= 10)
*set dieroll 3
*elseif (dieroll > 10) and (dieroll <= 15)
*set dieroll 4
*elseif (dieroll > 15) and (dieroll <= 18)
*set dieroll 5
*else
*set dieroll 6
By all means, this is something I simply made up in mind. I’m not sure if the PDF has the variance you like, but you get the gist.
P.S. In case anyone is wondering why I would go out of my way to code a silly thing to simulate mathematics thing, it’s because I’m learning this very topic on uni rn.
4 Likes
Such a brute force method would be good enough for me, thanks; I might use this sparingly!
2 Likes
system
Closed
422
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
Okay, so when I am doing a dieroller but want to add a stat to the result, how would that look in code form? I basically want it to be *set randroll +(Reaction) but somehow I expect it is not that easy.
Yeah, I guess I should probably open a thread if I want people to use it. Definitely an important part of the plan.
2 Likes