WatchNon-threaded

Forums » Advanced Editor Forum » Read Message

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

Variable Sided Die

9 years ago

Just a quick question that I could most likely figure out myself but I'm way too lazy and I'm assuming somebody already knows the answer anyway - in scripting are you good to use 1D%VARIABLE, or %VARIABLED6? So let's just say the variable %COOL can be 1, 2 or 3, and you want to set something to have a random roll but with a better chance of success if %COOL is a larger number. So you'd go:

%VARIABLE := 1D%COOL

So if %COOL is 1, %VARIABLE can only be set to 1. If %COOL is 2, %VARIABLE has a random chance (1D2) of being set to 1 or 2. If %COOL is three, %VARIABLE has a random chance (1D3) of being set to 1, 2 or 3.

Anyway is this possible? It'd just save a lot of time if it is, that's all.

Variable Sided Die

9 years ago
Should be possible, test which one works and post the solution here.

Variable Sided Die

9 years ago
I wasn't able to get it to work. It wouldn't let me save the script, and kept coming up with an error that said something about not recognizing 'D'. So I guess it needs to have a number. I wish it was possible, though.

Variable Sided Die

9 years ago
a workaround would be to have the assignment in conditional statements

so like:

IF %COOL = 1 THEN
%VAR := 1D1
ELSE IF %Cool = 2 Then
%VAR := 1D2

etc..

Variable Sided Die

9 years ago

I figured something out too (which is very surprising considering I don't know anything about scripting) but it's not what you wanted, just something slightly different:

1. Make two variables, VARIABLE and COOL.

2. Make new link on page you want.

2. Go to the link you want to change the variables and press the := button. Put in %VARIABLE := %COOL + 1D2       (or whatever you want to put for the random number like, 3D2, 1D4, etc.)

3. Make sure it works.

 

This way makes it so whatever %COOL is, it would add in with %VARIABLE. Do you guys get where I'm coming from?

Variable Sided Die

9 years ago

Good on you for trying out scripting Fergie. The script you wrote actually works fine, but it doesn't capture what I'm trying to do - let's just say %COOL was 4 at the time and you had %VARIABLE := %COOL + 1D2, the only options you'd have for %VARIABLE are 5 (4 + 1) and 6 (4 + 2), meaning there wouldn't be an option for you to have 1, 2, 3 etc.

So yeah, your script isn't wrong, but it isn't a script that will perform what I'm looking for.

Variable Sided Die

9 years ago

I considered that and I could definitely do it, it's just that it'll take possibly unnecessary time to write out a segment of script for every possible value of %COOL, especially when the value of %COOL can be more than 100. Of course, if the 1D%COOL thing doesn't exist I can always write it out the long way, it's just a matter of "if there's a quicker way it'd be cool to know about it". Thanks for the response anyway!

Variable Sided Die

9 years ago
October, instead of setting cool to 1 or 2 or whatever, wherever you'd set it to that, just set it to 1d1 or 1d2.

Variable Sided Die

9 years ago
Then %VARIABLE := %COOL (or just use %COOL)

Variable Sided Die

9 years ago

I'll put it into more context here - like let's just say... uh, magic skill goes up as the story goes on, so instead of %COOL we've got %MAGICSKILL. At the end of the game, there's something you'll have to do - on the link that determines whether you do this action or not, if you have above 10 of %VARIABLE you succeed and if you have below/equal to 10 of %VARIABLE you fail. If %VARIABLE := 1D%MAGICSKILL, the higher magic skill you have the better chance you have of succeeding, but a higher magic skill will not necessarily guarantee that you succeed. Like a %MAGICSKILL of only 15 means you've only got a 1 in 3 chance of succeeding, but if you've got a magic skill of 40, you've got a 3 in 4 chance of succeeding.

With that being said, %COOL, or %MAGICSKILL, cannot be set to a random number because it reflects your choices throughout the game.

Variable Sided Die

9 years ago
DEFINE THE FOLLOWING VARIABLES
%MAGICSKILL
%VARIABLE
%TEMPMAGIK

IF %MAGICSKILL > 100 THEN
%TEMPMAGIK := 100

IF %MAGICSKILL < 101 THEN
%TEMPMAGIK := %MAGICSKILL

%VARIABLE := 1d105

IF %VARIABLE < %TEMPMAGIK THEN
BEGIN
***successs***
ELSE
***failure***
END

Can't remember the syntax for if clauses off the top of my head, but that's pretty close to it. That should do what you want it to do. Obviously replace the ***xxx***'s with whatever you want to happen.

Variable Sided Die

9 years ago

That's the perfect workaround! Thanks JJJ!

Variable Sided Die

9 years ago
Thanks dude. Best of luck.

Variable Sided Die

9 years ago

Now that I actually know how scripting works, thats genius.

Variable Sided Die

9 years ago
Thanks man.