Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Checking for a certain chapter?

9 years ago

I have a global script that appends a couple of lines of text to every page, but there are a few places where I'd like it to not show up. To simplify things I want to put all those special case pages in one chapter and then have the script check that the player isn't anywhere in there before showing the message. I'm just not sure what the actual syntax would be for checking chapters instead of pages. I thought I read about something similar here recently which is what gave me the idea for how to handle this, but I can't find it now. 

Checking for a certain chapter?

9 years ago

There is a system variable called $CHAPTERID. The reference sheet also suggests that $DEST also works for chapters if you use @C instead of @P.

You may try this in a global link script:

IF $DEST = @C3 THEN %SHOWMESSAGE := 1
ELSE %SHOWMESSAGE := 0

After that, I would put this in the global page script:

IF %SHOWMESSAGE := 1 THEN $PAGETEXT := $PAGETEXT + "..."

Checking for a certain chapter?

9 years ago
It's definitely better to just use $CHAPTERID.

IF $CHAPTERID = 3 THEN %SHOWMESSAGE := 1
ELSE %SHOWMESSAGE := 0

You can do the check in the global page script with the message code as well.

Checking for a certain chapter?

9 years ago

So far I tried this in the global page script:

IF %TIME > 12
AND
$CHAPTERID = 1
THEN
$PAGETEXT := $PAGETEXT + "Night has fallen."

 

It worked before I added the chapterid bit, but now it's broken. (even though it still validates)

I'm astoundingly hopeless at scripting. Eh, I'll mess with it more in a little while.

Checking for a certain chapter?

9 years ago

IF %TIME > 12 THEN
IF $CHAPTERID = 1 THEN
$PAGETEXT := $PAGETEXT + "Night has fallen."

Checking for a certain chapter?

9 years ago

I'd already tried that, it gives an error.

Checking for a certain chapter?

9 years ago

What type of error does it give? Also, check if you have actually set anything for the variable %TIME.

Checking for a certain chapter?

9 years ago

It just doesn't like the IF in front of TIME

It's the AND that's the issue, I've never really messed with scripting much so I didn't realize it was broken.  TIME works fine otherwise and so does checking for the chapter, it's just combining the two that's impossible.

I'll just go in later and take out the global script and have it check for TIME on the important links manually, I guess. I'd cry at the time wasted except I've probably spent more than that just trying to figure this out already...

Checking for a certain chapter?

9 years ago

Are you sure the code below does work?

IF %TIME > 10 THEN
IF $CHAPTERID = 1 THEN 
$PAGETEXT := $PAGETEXT + "Night has fallen."

I just created a testing game, and it worked perfectly for me.

Checking for a certain chapter?

9 years ago

Yes! That did it!

Every other time I'd tried having two IFs in a row I'd get an error.  This looks like it'll stand in for AND perfectly in any situation though. Thanks!

Checking for a certain chapter?

9 years ago

I don't get it. It didn't work when you tried Jame's answer? It's almost exactly the same as mine, except, I switched out the number 12 with 10 instead. Can you provide an example of how you use IF statements in rows?

Checking for a certain chapter?

9 years ago

Looking at it again now I think I just misread his. It won't accept the second IF if you're using AND, that was the original problem I was running into. What I tried at first was:

IF %TIME > 10 AND
IF $CHAPTERID = 1 THEN 
$PAGETEXT := $PAGETEXT + "Night has fallen."

And it wouldn't validate until I removed it, and after that it looked like it was working but wouldn't show the text.

Checking for a certain chapter?

9 years ago

So, yes. Just replace all AND with THEN, and you're all set.

Checking for a certain chapter?

9 years ago

Okay, this is just weird.


IF $CHAPTERID = 1
THEN
$PAGETEXT := $PAGETEXT + "blah blah."

That works fine on it's own, it's just when I try and combine it with anything else it breaks something. Do I have a mistake with the AND part somehow?

Checking for a certain chapter?

9 years ago

The AND statement in conditionals doesn't work correctly. I'm not entirely sure why.

Checking for a certain chapter?

9 years ago

Well that sucks. :/

I wish I'd know that earlier. It's going to be really limiting, too.

Checking for a certain chapter?

9 years ago
Not really. Just gotta be more creative.

Checking for a certain chapter?

9 years ago

IF %TIME > 12 THEN %MEASURE := %MEASURE + 1
IF $CHAPTERID =1 THEN %MEASURE := %MEASURE + 1

IF %MEASURE = 2 THEN %SHOWMESSAGE := 1
ELSE %SHOWMESSAGE := 0

%MEASURE := 0

(Edit: Yes, I know she figured it out, but this is how you could do it without using my aforementioned method and without using the broken AND statement)