Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Random variables and scores

11 years ago

Hi guys, I'm back! So, I'm a bit stuck in what I've been working on. Basically it's a game that involves a lot of gambling and will probably be very tricky to script. What I'm trying to do is come up with a random variable that can effect a score or something like that.

Say for instance, a dice is being rolled and you have to guess what the outcome will be, so you have to pick a number between 1 and 6. You click 3. It takes you to a new page that says, "The dice is rolled and the result is..." Then it shows a random number between 1 and 6.

The tricky bit is though, I need to script it so that if the dice landed on 3, you win money, but if the dice landed on any other number, you loose money. Any one know if this is possible?

Random variables and scores

11 years ago

I know it's possible (BZ did a hybridised version for me) but I don't know how. I think they explained it in one of the threads though. I'll search,

Random variables and scores

11 years ago

Thanks Aman! Glad to see your mustache is looking glorious as ever ^_^

Random variables and scores

11 years ago

 

%variable := 1D7
IF %variable = 1 THEN %Money := +1
IF %variable > 1 THEN %ROLE2 := -1
 
i think that's how you'd do it. 
 

 

Random variables and scores

11 years ago

Thanks Aman! Now I just have to see if I remember how variables work cheeky

Random variables and scores

11 years ago

Lets just hope I gave you the right script. :P

Random variables and scores

11 years ago

... I don't. Does what you just said need an actual variable or is it just scripting? I swear I used to know loads of things about Advanced Editing but now I've gone and forgotten it all cheeky

Random variables and scores

11 years ago

I know you need to post the script in the scripting link on the editor. Also, I don't know if my script works. Let me change some of it.

Random variables and scores

11 years ago

 

 
 
%variable := 1D7
IF %variable = 1 THEN %Money := +1
IF %variable != 1 THEN %ROLE2 := -1
 
that is more likely to work(I think. I'm garbage with scripting)

Random variables and scores

11 years ago

And yeah, it requires too make a variable ^_^

Random variables and scores

11 years ago

Lol, sorry I'm dumb. I annoying 'cos I remember how to script on the regular pages and stuff but I didn't even know that you could script variables cheeky

Random variables and scores

11 years ago

On Link Script ':=' of a Link labeled "I Choose 3" ___

%ROLL := 1D6
IF %ROLL = 3 THEN
BEGIN
%MONEY := %MONEY + 100
$DEST := @P22
END

IF %ROLL != 3 THEN
BEGIN
%MONEY := %MONEY - 50
IF %MONEY < 1 THEN
%MONEY := 0
$DEST := @P11
END

(Where p.22 is you win & p.11 is you lose)

 

Random variables and scores

11 years ago

Meh, close enough, :(

Random variables and scores

11 years ago

Okay, am just trying to figure out what that all means... does the ! before the three mean if the roll isn't a three?

Random variables and scores

11 years ago

Yep If (not 3) :)

Random variables and scores

11 years ago

Yeah, whatever you guys are telling me to do I must be missing something because it just shows up as text written on the page. Keep in mind I'm very, very dumb so there's probably something really obvious I was supposed to do that I haven't done yet. Also hi BZ! ^v^

Random variables and scores

11 years ago

... Like I know you don't want to be patronizing but it'd really be awesome if you just talk to me like I'm an idiot. Like... First click "Make a new game." Now choose "Advanced Editor." Then enable all of the advanced settings in the advanced editor... Make a variable. Name it 'Bob'. cheeky

Random variables and scores

11 years ago

Are you sure you're putting the code into the   "  :=" to the left of your link? And you also have too put something in the source itself...

Random variables and scores

11 years ago

Yeah, see that's why I suck at this, I have no idea what you're talking about cheeky

Random variables and scores

11 years ago

Your average page:

http://s1311.photobucket.com/user/AmanCYS/media/image_zps92328948.jpg.html?sort=3&o=0

 

This is what I'm talking about,  ' :=':

http://s1311.photobucket.com/user/AmanCYS/media/image_zps4f351d62.jpg.html?sort=3&o=1

Random variables and scores

11 years ago

Ahh okay... Yeah, don't think I've ever used Link text before. Will have to go read stuff cheeky

Random variables and scores

11 years ago

Okay, I think I figured some of it out now... If I haven't I'll come back and annoy you some more cheeky

Random variables and scores

11 years ago

I have no idea about your question but: WELCOME BACK!

Random variables and scores

11 years ago

Thank you! Is great to be back! Sorry I disappeared off the face of the earth and all. cheeky

Random variables and scores

11 years ago

It is worth mentioning that to see the := symbol, you have to go into Story Properties and enable all the Advanced Editing Features (just take the highest of each : Variables, Items, & Scripting).

Random variables and scores

11 years ago

Hahaha, yeah ;)

Random variables and scores

11 years ago

In each link of the guessing page set the link script to set %GUESS (a variable) equal to the link number.

Then, ON THE PAGE WHERE THE RESULT IS SHOWN, you set the random variable to a random number, between 1 and 6. Then do a check to see if %RANDOMVARIABLE = %GUESS, and give money accordingly.

%RANDOMVARIABLE := 1D6

IF %RANDOMVARIABLE = %GUESS THEN
%MONEY := %MONEY + 2
ELSE
%MONEY := %MONEY -2

^Script on the ending page. You'd also need scripting to show what the answer was and what they guessed.

You rolled the dice and the result is....%%RANDOMVARIABLE%%

You Guessed %%GUESS%%

^ What you would write on the actual page (not page script) to reveal the result and the guess.

You actually don't even need to use link scripting for this way. You can do variable changes with links without scripting.