*rand help


#1

so im using an older model of choicescript for a school project in which I need to use the *rand, but it always sends me to college and the teacher asmy profession instead of going to nurse 50% of the time, help? here is the code for the college I have:
*temp percentage
*rand percentage 0 100
*if (percentage > 4)
*goto_scene college
*elseif (percentage < 3) and (percentage > 45)
*goto_scene unskilled
*elseif (percentage < 45)
*goto_scene highschool


#2

I’d change all of the *elseif 's to *if 's


#3

Can you explain with words what you’re trying to do. I can see what’s wrong, but trying to explain what you need to do is tricky.

Also for code on the forums do < pre> and < /pre> surrounding your code, but without that space.


#4

Switch the order about as it will always meet the first condition unless the result is 1-4.


#5

ill try that @Samuel_H_Young I’ve never used the *rand command as it is unstable so I try to stay away from it and haven’t coded much in a few months.


#6

*elseif (percentage < 3) and (percentage > 45)

For instance is impossible. It’s saying if the percentage is less than 3, well if it’s less than three it can’t be more than 45.

Also that first check says if the percentage is greater than four, well that makes *elseif (percentage < 45) only encompass 0, 1, 2, 3, since everything else is greater than 4.


#7

oops, I put the wrong <'s and >'s, lol thanks @FairyGodfeather


#8

that seemed to fix it! thank you guys! @Nocturnal_Stillness @FairyGodfeather and @Samuel_H_Young you guys awesome!


#9

@WiReDcHiMpAnZeE
“I’ve never used the *rand command as it is unstable”

There’s nothing wrong with it?
If you think there is, back it up with evidence and report it so it can be fixed.


#10

Glad I could help.


#11

I have used the *rand comand fairly heavely at times, always worked fine unless there was an error in my code. :slight_smile:


#12

@WiReDcHiMpAnZeE

Personally I’d code it like this…


*temp percentage
*rand percentage 0 100
*if (percentage > 45)
  *goto college
*elseif ((percentage < 45) and (percentage >4))
  *goto highschool
*else
  *goto unskilled


#13

@Nocturnal_Stillness And that’s why little errors are so easy to make. In this case it wouldn’t matter, but in some cases it would: What if the roll is 45?

@CJW The only thing I can think of is the fact you need to roll things before hand. Did they ever figure out what was causing genders to revert with Treasure Seekers of Lady Luck? I was wondering if there could be something there.


#14

Well spotted, Reaperoa. The else covers that 45, but it definitely shouldn’t. I suppose that’s one reason I generally don’t use else, just in case I’ve messed up somewhere. I’d rather have the error, than the unseen wrong result.


#15

@CJW before I left I remember someone who was a mod mentioning it was unstable, and I never really asked if it was fixed yet


#16

@Reaperoa
That’s not a problem with the command so much as the way the stat screen transition is handled, but they may have been what he meant.

In regards to LadyLuck - I would imagine so, but I haven’t heard anything or played it recently. I’m not sure if that would have been an issue with *rand though… As in theory it should have only needed to be used once at the very beginning of the game? :confused:

@WiReDcHiMpAnZeE
What exactly did they say? I’ve used it heavily and never had any problems (excluding the stat screen reroll).


#17

I don’t remember that was months ago, haha


#18

well i used heavily the rand command in mine and other games im coding i never had any issue using it. I just being careful if i want use it to switch gender, i just put a page_break after rol to avoid character change gender looking at stats. This way avoid of switch gender unspected.