WatchNon-threaded

Forums » Advanced Editor Forum » Read Message

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

Can I use multiple variable values in scripts?

29 days ago

I'm trying to get a message to display differently depending on the value of a certain variable. The problem is, the variable I'm using for it I'm also using for something else, so I can't just have it change between numbers 1, 2, 3 and so on. What I'm wanting to know is if I can have the script detect variable values in-between numbers, like it will only display one message between values 1-6, and display a different message between values 7-9, and so on. Is it possible to do that using the "IF %SCORE =" stuff in the script? I could just make completely new variables or do something else, but it'll help out in the long-run if I can somehow use variable values between one-another in the script.

Can I use multiple variable values in scripts?

29 days ago

I think you are searching for something like this : 
IF %BLEEDING >= 100 AND %BLEEDING < 200  THEN
BEGIN
$PAGETEXT := $PAGETEXT +"You're bleeding."

END

Making it inline is a bit dirty so maybe translate it to a better looking temporary variable that just represent the output like :

- pagescript : assign temp variable with needed output (if 1-6:tempOutput = 1 elseif 7-9:tempOutput = 2 etc...)

- embedded script in page : if(tempOutput == 1) display1 ?elseif (tempOutput ==2) display2 etc. etc.

plus, it strips the business logic outside of the display layer, which is common good practice when coding scripting.

nb: I'm a newb too, so maybe there is a better way to do it.

 

Can I use multiple variable values in scripts?

29 days ago
IF %BLEEDING >= 100 AND %BLEEDING < 200 THEN
BEGIN
$PAGETEXT := $PAGETEXT +"You're bleeding."
END

Yeah, this is the simplest way if they're just tacking a line onto the end of the page, and to alter text within a passage you can use on page scripting. Although I don't think that lets you specify both greater than a number AND less than another, there's always the possibility of the original variable setting another when it's in a specific range and having the text depend on that one.

%%BLEEDING%<%4%blah blah your text%%
%%BLEEDING%>%3%blah blah%% and so on.

And so on. Just insert it directly into the main text box with the story and the text will only show up if whatever condition is met.

Can I use multiple variable values in scripts?

29 days ago

Something important to keep in mind with On-Page variables is the firing order of scripts.  $PAGETEXT is evaluated prior to the page script, so if you have %%BLEEDING%<%4%blah blah your text%%, etc. on your main page, that will be populated before any changes to the variable in the page script.

So if you have the above On-page variable, %BLEEDING is currently set to 3, but in the page script some function that increments it to 4, your page will still show the conditional statement for 3.  If you have the variable display option enabled, you'll be able to see the mismatch.

You can reference that in Scripting Code Reference for the firing order.

Can I use multiple variable values in scripts?

28 days ago
Yeah, important to note for someone new to the editor, you should only actually change the variables in the link scripts.

Can I use multiple variable values in scripts?

28 days ago

I agree with this 100%.

99.9% of the time, at least.  The 0.1% is not for the faint of heart.

Can I use multiple variable values in scripts?

28 days ago
What is the significance of "BEGIN" and "END?" Is it in reference to just text on the page, or does it mean "begin the following operation until reaching END?" Or is it something else?

Can I use multiple variable values in scripts?

27 days ago

BEGIN/END encapsulates your lines of script so that they will all be affected by the same conditional statement.  So:

IF %VARX = %VARY THEN

BEGIN

  %VARZ := %VARX + %VARY

 $PAGETEXT  :=  "Happy day."

END

is the same as

IF %VARX = %VARY THEN

 %VARZ := %VARX + %VARY

IF %VARX = %VARY THEN

 $PAGETEXT  :=  "Happy day."

but NOT the same as

IF %VARX = %VARY THEN

 %VARZ := %VARX + %VARY

 $PAGETEXT  :=  "Happy day."

In the last case, the $PAGETEXT will be set no matter what.

Can I use multiple variable values in scripts?

27 days ago
Thanks. So basically it operates like brackets.

Can I use multiple variable values in scripts?

27 days ago

Exactly.

Can I use multiple variable values in scripts?

28 days ago

There’s a bug that causes AND, OR, and NOT to fail unless you only use = or !=, so you’d actually need to replace that AND with a second IF statement as a workaround.

IF %BLEEDING >= 100 THEN
BEGIN
  IF %BLEEDING < 200 THEN
  BEGIN
    $PAGETEXT := $PAGETEXT +"You're bleeding."
  END
END

Can I use multiple variable values in scripts?

28 days ago

Alright, that worked exactly how I was wanting it to. Thanks for the help.