Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Dice Rolling

5 years ago
I'm attempting to set up a stat rolling system based on tabletop RPGs, and I'm mostly there. The only issue right now is that I don't know how to get it to roll 4D6 and drop the lowest die.

4D6 - 1D6 rolls 4 dice, then rolls a fifth and subtracts that number from the total, which isn't what I'm looking for. The only way Ford or I could think of to do it would be to ID each die for each roll and make a bunch of if-then statements to determine the lowest. That would be an insane amount of new variables to add to the system and really impractical.

I've got it set at just 3D6 right now and have it set up so that everything can be rerolled, assigned, or reassigned properly, but I would like to make it 4D6 drop lowest if at all possible. Does anyone know how?

Dice Rolling

5 years ago
I've done something like what you described before, it is a lot of IF THEN but not too ridiculous and you can copy and paste one you set it up once.

Is there any reason the stats HAVE to work that way? The player could just be given their results and told to drop one for instance. You can assume they'll drop the lowest, but I'm not sure it would matter if they picked another one.

Dice Rolling

5 years ago
Right now all the rolling happens behind the scenes, so 6 stat rolls show up on the same page for the player to assign to their various character stats. I'd have to add six more pages of numbers and dice for that to work and I think that might be a bit too number-heavy for the average reader. I appreciate the suggestion though!

Dice Rolling

5 years ago
Indeed, there's no arrays in the scripting system, so this can be done, but it takes a little bit with lots of IF.THEN statements (unless Bradin jumps in here and makes us both look silly).

Instead, do you really have to SHOW them you did that? You could probably just use 3D6 + 3 to simulate dropping the lowest...

Dice Rolling

5 years ago
I tried that, but it would sometimes result in stats going all the way up to 21 which messes things up in the earlier sections of the game. Thanks for the suggestion though!

Dice Rolling

5 years ago
IF %die > 18 THEN %die := 18

Dice Rolling

5 years ago
Oh yeah, I didn't think of that ^_^

Dice Rolling

5 years ago
My advice to her when she asks me scripting questions is always "ask BD" and she complains but if I had the question and didn't know what to do I'd ask BD. Even if he doesn't give me a direct copy-paste answer (as he usually does because there's no need to explain most things to me) he'll say it's impossible or start me off with something towards what I need; for the latter, my next step is thinking about if it's even possible to do whatever it is.

More often than not, BD has a simple elegant solution that's better in some way to whatever I could come up with. I can get things working with some mental effort but it seems like he just has scripts lying around out of use that do exactly what needs to be done. Best general advice is to just ask BD second - that is, after one has thought and tried and knows what the question to ask is.

Also there's this: http://bradin.pw/cysscript/documentation/

Dice Rolling

5 years ago
I usually end up asking BD anyway but there's no sense in not asking the engineer sitting right next to me first. I get much quicker answers that way if you happen to have any.

Dice Rolling

5 years ago
"The only way Ford or I could think of to do it would be to ID each die for each roll and make a bunch of if-then statements to determine the lowest."

Or just %current, %low, and %total.

#Die 1
%current := 1d6
%total := %total + %current
%low := %current

#Die 2
%current := 1d6
%total := %total + %current
IF %low > %current THEN %low := %current

#Die 3
%current := 1d6
%total := %total + %current
IF %low > %current THEN %low := %current

#Die 4
%current := 1d6
%total := %total + %current
IF %low > %current THEN %low := %current

#Remove lowest die roll from total
%total := %total - %low

And there ya go.


Dice Rolling

5 years ago
Thanks Killa! I'll definitely try that.

Dice Rolling

5 years ago
BD answered in #dev. Pasting here for future peoples who may look at this thread.

%DIE1 := 1D4
%DIE2 := 1D4
%DIE3 := 1D4
%DIE4 := 1D4
%MIN := %DIE1
IF %MIN > %DIE2 THEN %MIN := %DIE2
IF %MIN > %DIE3 THEN %MIN := %DIE3
IF %MIN > %DIE4 THEN %MIN := %DIE4
%ROLL := %DIE1 + %DIE2 + %DIE3 + %DIE4 - %MIN

Dice Rolling

5 years ago
I mean... yeah, but that's the same amount of variables Leora said she wanted to avoid having.

Unless what she actually meant was just lowering the amount of code written.

Dice Rolling

5 years ago
I think it was just the billion IF THENs from checking them a different way she was trying to avoid.

Dice Rolling

5 years ago
Yeah, I thought it was kind of weird when she was saying four additional variables was an insane amount to add to the system.

But then I remembered she's dating Ford, so it checked out and I rolled with it.

Dice Rolling

5 years ago
I was thinking she wanted to display all the dice, so that might mean 4 dice x 6 stats, and that would be 24 variables and at least 18 IF statements...

Dice Rolling

5 years ago
Yeah I meant the IF THENS... My bad with the phrasing there. I still don't know a whole lot about scripting but I'm learning. Thank you guys for all your help!