Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Conditional Text Display (variables)

10 years ago

So the reader plays my game and ends up with the following variable stats (choices and dice rolls influence these so they differ with every play):

A (warrior): 15

B (wizard): 21

C (assassin): 29 

Now they get to a page, a report card. I want to say "congratulations, you are now an assassin (or whichever one)" based on the HIGHEST variable stat (in this case C). How do I do this (e.g please give SCRIPT code or ONPAGE code??). How do I make the text on the page dependable on the HIGHEST stat?

Many thanks for any help! :)

Conditional Text Display (variables)

10 years ago

I honestly haven't messed with the advanced editor in the last few months, but there are two ways you can do this, I believe.

Firstly, you can go to the script of the page you are wanting this to appear on and input:

IF %STAT <= 15 THEN $PAGETEXT := $PAGETEXT + "warrior."

IF %STAT > 15 THEN IF %STAT <= 21 THEN $PAGETEXT := $PAGETEXT + "wizard."

IF %STAT > 21 THEN IF %STAT <= 29 THEN $PAGETEXT := $PAGETEXT + "Assassin."

Alternatively, you can use both scripts and on-screen to give you a little more control. Go to the link script that leads to the page on which you get your report card and input:

IF %STAT <= 15 THEN %CLASS := 1

IF %STAT > 15 THEN IF %STAT <= 21 THEN %CLASS := 2

IF %STAT > 21 THEN IF %STAT <= 29 THEN %CLASS :=3

Then, on the actual page where you get the report card, insert:

%%CLASS%=%1%Warrior%%%%CLASS%=%2%Wizard%%%%CLASS%=%3%Assassin%%

The latter method will allow you to have text after the declaration of the player's class.

Conditional Text Display (variables)

10 years ago

You're looking for somewhat of a max() function, then? Going off of what James said, you might want to have an additional variable %CLASS so you only need to run the calculation once. It prioritizes C, so if they're all equal, the player will be an assassin:

IF %A >= %B THEN IF %A >= %C THEN %CLASS := 1

IF %B >= %A THEN IF %B >= %C THEN %CLASS := 2

IF %C >= %A THEN IF %C >= %B THEN %CLASS := 3

Then you can just use the same on-page code James gave you:

%%CLASS%=%1%Warrior%%%%CLASS%=%2%Wizard%%%%CLASS%=%3%Assassin%%

Conditional Text Display (variables)

10 years ago
The generic way would be to do this:

%MAX := 0

IF %A > %MAX THEN %MAX := %A
IF %B > %MAX THEN %MAX := %B
IF %C > %MAX THEN %MAX := %C

IF %MAX = %A THEN %PAGETEXT := %PAGETEXT + "congratulations, you are now a warrior"
ELSE IF %MAX = %B THEN %PAGETEXT := %PAGETEXT + "congratulations, you are now a wizard"
ELSE IF %MAX = %C THEN %PAGETEXT := %PAGETEXT + "congratulations, you are now an assassin"

This is the most scalable way to find the max out of a set of numbers. It can be put in the page script. Bradin's way work fine as well, but will get more complex and harder to handle if there are more stats that you're checking.

Conditional Text Display (variables)

10 years ago

Thanks!