Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

conditional display text question

18 years ago

I was just wondering with the scripting, I read elsewhere in this forum how DISPLAYIF might be used, I was wondering if something like that is implemented yet, or it is done a different way?

I want to use scripting so that it displays text if a variable is between two numbers. Ie, if HOURS >6 AND HOURS < 11 display "It is morning." on the page.

At the moment, I'm just using the normal variable check, %%HOURS%=%6%It is morning.%% but writing it out seperately for each hour. It would be easier to write a single line that covers all those hours at once.

conditional display text question

18 years ago
You have to have scripting enabled.  Put this on the page script:

IF %HOUR > 6
IF %HOUR < 11
"I don't know how to display text, but it'd be displayed here."
ELSE
"It's not morning!"
END
ELSE
"It's not morning!"
END

conditional display text question

18 years ago

Lol, I've been programming for 22 years, but for some reason, it didn't occurr to me to use a nested loop! Ah well, didn't sleep much last night. Anyhow, mostly I needed to display text inside a script, so this solves all my problems! Thanks!

I had an idea of implementing a 24 hour clock into one of my stories, and each link uses a certain amount of time as the player does things. On location pages, it might give a different description of things according to wether it was day or night, and different things might happen at different times of the day, (like muggers in a dark alleyway in the middle of the night) so by checking what time it is, different text could be displayed on the same location page!

I don't know if anyone's done something like that yet, but if anyone's interested in putting a 24 hour clock into their stories, all I did was have a Global Link and Global Page script that has this:

IF %MINUTES >59 THEN
BEGIN
   %MINUTES := (%MINUTES-60)
   %HOURS := (%HOURS+1)
END

IF %HOURS >23 THEN
BEGIN
   %HOURS := (%HOURS-24)
END

Then add MINUTES and HOURS variables, and when someone clicks on a link on a page, have it add to one of those variables to make time pass when they perform that action. You could do all sorts of things with this, like having a murder mystery that has to be solved by the strike of midnight, where every minute of your investigation counts, to having someone fall asleep if they've been awake for too many hours without resting, or you can even add weather cycles, so that every couple hours, it might change from clear skies to rain storms. Lots of possibilities :)

At the top of each page, I have a short bit of text that shows the time:

The time is %%HOURS%%:%%MINUTES%<%10%0%%%%MINUTES%%.

(Added <if minutes less than 10 print "0"> otherwise it might say things like 8:1 instead of 8:01)

Anyhow, just thought I'd post my clock idea in case someone else finds it useful too :) You could even do a similar thing to have it cycle through the days of the week as well, or whatever.

conditional display text question

18 years ago

Doh! I just realised what you wrote: "I don't know how to display text, but it'd be displayed here."

I typed text into my script, inside " " but it comes up as an error, so I guess that's not how to do it. I know scripting is still being made, anyone know if printing text inside a script is done yet?

conditional display text question

18 years ago
that would be done in a page script

conditional display text question

18 years ago

I know to display text needs to be in a page script, but I still can't get it to display text. If I put anything between " " then the script error message says Did Not Expect "

If you've got it to display text in your scripts, could you perhaps insert a piece of your code here so we can see how to do it? Thanks!

conditional display text question

18 years ago

Oh im sorry, i havent read the thread at all, just that last post, so i thought you were just asking where to put it, anyways here is what you need to do:

$PAGETEXT = "text"

conditional display text question

18 years ago
actually... hold off on that for a sec, lemme just check something first...

conditional display text question

18 years ago

I tried it. It needs the colon -

$PAGETEXT := "this is a test"

and then it appears to work pretty well. Though, I then discovered that any text already in the normal page editor disappeared, to be replaced entirely by what was in the script, instead of 'inserting' the scripted text. I suppose this means the whole page has to be in the script if you want to use scripts to display text?

conditional display text question

18 years ago
yes that will happen because you use ":=" because that is "assigning" it that value. anyways, i will talk to alex and see what can be done...

conditional display text question

18 years ago

I guess, in addition to that, I tried placing in the script, $PAGETEXT := "The time is %%HOURS%%" and it didn't show the numerical value of the HOURS variable, but simply printed %%HOURS%% as text.

For now I'll just use the script to work with variables, then, and keep using the normal page editor to display the text.

conditional display text question

18 years ago

If you want to display %%HOURS%%, you need to display it as if you were writing in C++, i noticed you said you were programming for 22 years, so i suppose you know this:

cout "hello world, today is" >> {this woudl be the variable that stores the date}

alright, so its not perfect, anyways:

$PAGETEXT := "The Time is" + %HOURS

or

$PAGETEXT := "The time is" %HOURS

try one of those and by the way, i see you made reference to [displayif], that is something for the actual page description, not scripts, and will be implememnted soon, it is too replace the current syntax for manipulation variables on descriiption text, eg, we use (currently):

%%VARIABLE%=1%The variable is 1%%

too display 1 on the page IF the variable is 1, the display if will make it so it is much simpler...

conditional display text question

18 years ago

Ah! I understand now. And if I want to append more text onto the page in the script, I found I could just write:

$PAGETEXT := $PAGETEXT + "text to add to other text"

and that way it keeps any previous displayed text in the script instead of replacing it. Awesome - I can now do everything I wanted to do :) Thankyou for the help - much appreciated!

conditional display text question

18 years ago
no problem! please PM me if you need anything else and make sure (wow i feel like a tv ad) to read alex and my scripting articles for more information on scripting. I will post a link to my Intermediate Article because it is currently not accessible to normal users...

conditional display text question

18 years ago