WatchNon-threaded

Forums » Advanced Editor Forum » Read Message

Talk about it. Ask for help on it. Compliment it.

Diceroll with variables?

11 days ago

Hello CYS, 

I was just wondering if it was possible to do a Diceroll with 2 different variables. A game I'm making depends on upgrades. The code I have right now is %MONEYGAIN := %MONEYGAIN + %WORKERSD%MAXCASH .

So if the max cash a worker can get is 4, and I have 5 workers, it would be a random value from 5 to 20. 

How do I make this possible?

 

Thanks

 

Diceroll with variables?

11 days ago
You only need to randomize the amount of cash they make, right?

I'd do something like

%CASHRNG := 1D4

%MONEYGAIN := %WORKERS * %CASHRNG

But that would mean each worker made the same amount that week. A dice roll for each worker would probably be tedious to set up, but I'm not really an expert on this stuff. My instinct would be to just do a second small dice roll and add it to the result for a bit more of a sense of randomness.

Diceroll with variables?

11 days ago

So... basically there's no way [yet] to do that, right? Oh well then, thanks for your help, I'll try that out.

Diceroll with variables?

11 days ago

I agree that it would be tedious to do that for all workers,

You could, though, create a page that does this for you(sort of like a function in coding), and modify the variable from the previous. 

 

 

Diceroll with variables?

11 days ago

Okay, I guess it's time to go to the feature wishing well then. Thanks for yours and mizal's help

Diceroll with variables?

11 days ago
IF %WORKERS = 1 THEN
%CASHRNG1 := 1D4
IF %WORKERS = 2 THEN
%CASHRNG2 := 1D4

And so on, then add it all together. You can even get really ridiculous and account for
IF %WORKERS = 1 AND
IF %MAXCASH = 4

if you really hate yourself.

But I'm usually in support of the smoke and mirrors approach of just fudging numbers in situations like this, if it will save you time you can use for the actual writing.

Diceroll with variables?

11 days ago
You may just want to tag @Killa_Robot, @BradinDvorak or @BerkaZerka for questions like this.

Diceroll with variables?

11 days ago

I am pretty sure that %WORKERSD%MAXCASH would generate a random number from 5(maxcash) to 4(workers) which is not really possible. If you want MONEYGAIN to be 5-20, then i suggest storing another variable which multiplies 4 maxcash and 5 workers(assuming that's what you want Nope), and then do %WORKERSD%VARIABLE, and assign that to MONEYGAIN.

 

EDIT: Mizal got the reply in before me :P

 

EDIT2: Shoot, I messed that logic up. Yeah, Mizal is right, and I think that you add a MINCASH, and then randomize it with MAXCASH, which could be something dealing with your workers...

Good Luck!

Diceroll with variables?

11 days ago
I think you're too focused on the math behind the answer rather than the goal. The goal at any given time is just "give me a value that is between these values".

Assuming you have a max number for num of workers and pay, just do one big 1dX and work backwards to make sure the number fits.

Diceroll with variables?

11 days ago

So... 1d1000 - (1000 - %MAXCASH) or something, right?

Well thanks for your help, I'll try that too

Diceroll with variables?

11 days ago
Well no you'd want to scale it.

1d1000 * (workers/max workers) * (earnings/max earnings)

Or something like that, with an addition check to make sure it meets the minimum amount (the die starts at 1, but if you have 3 workers the min is 3).

Diceroll with variables?

11 days ago

I've found kind of a rusty basic to build off of:

1D10000 * [(1/2 ^ %MAXCASH) * 10000]

Problem is, I don't know how to type exponents in the script

Diceroll with variables?

11 days ago
Don't use insainly large numbers, the system begins to choke-out with variable values greater than hundred thousands.

Diceroll with variables?

11 days ago
It worries me that you stumbled upon this lol.