beforeturn override bug?

Freak
28 Feb 2007, 01:02
I was using a test case, and discovered that "beforeturn override msg <in beforeturn>" in a room gives an error. Is that just Quest 4 or was that the behavior in prior versions?

Alex
28 Feb 2007, 11:53
What error do you get?

It works for me:


define game <test>
asl-version <400>
start <room>
beforeturn msg <global beforeturn>
end define

define room <room>
north <room2>
beforeturn override msg <in beforeturn>
end define

define room <room2>
south <room>
end define


gives:


You are in room.
You can go north.

> look
in beforeturn
You are in room.
You can go north.

> north
in beforeturn
You are in room2.
You can go south.

> look
global beforeturn
You are in room2.
You can go south.

> south
global beforeturn
You are in room.
You can go north.

Freak
28 Feb 2007, 13:09
Ah. "beforeturn override" only works if in the first "beforeturn" line. That's annoying.

Alex
28 Feb 2007, 13:57
What do you mean by the first beforeturn line?

Freak
28 Feb 2007, 14:14
define game <test>
asl-version <390>
start <room>
beforeturn msg <global beforeturn>
end define

define room <room>
north <room2>
beforeturn msg <in beforeturn 1>
beforeturn override msg <in beforeturn override 2>
beforeturn msg <in beforeturn 3>
end define

define room <room2>
south <room>
end define


You can go north.

> l
in beforeturn 1
in beforeturn 3
global beforeturn
You are in room.
You can go north.

> n
in beforeturn 1
in beforeturn 3
global beforeturn
You are in room2.
You can go south.

> l
global beforeturn
You are in room2.
You can go south.

> s
global beforeturn
You are in room.
You can go north.



INIT: Quest 4.0 Beta 3 (build 4.0.51)
INIT: Opening file C:\Documents and Settings\Home\My Documents\rmworld2.asl on 2/28/2007 at 8:06:27 AM
INIT: Finished loading file.
ERROR: Unrecognized keyword. Line reads: 'override msg <in beforeturn override 2>'
ERROR: Unrecognized keyword. Line reads: 'override msg <in beforeturn override 2>'


Comment out beforeturn 1 and it works fine. (I was using an older version of Quest, so I had to lower the asl-version.)

paul_one
28 Feb 2007, 14:17
try:
beforeturn override {
msg <code goes here>
msg <and here>
msg <and also here!>
}

Freak
28 Feb 2007, 14:32
I'm not interested in writing Quest games. I'm trying to write a program that runs them, and to do that, I need to know exactly what the correct behavior is.

Alex
28 Feb 2007, 14:52
Generally there shouldn't be multiple "beforeturn" tags in a room.

Also I notice that you're still using 4.0 Beta 3 - I'd recommend upgrading to the final release, especially as I think Beta 3 expires today!

Freak
28 Feb 2007, 15:10
It doesn't matter whether there "should be X" or "shouldn't be X"; in the absence of a formal specification, Quest is defined by its implementation, so what matters is "X is legal", "X is illegal", and "behavior of legal behavior X".

Since having multiple beforeturn tags is legal, I need to know what the correct behavior of that case is.

Freak
01 Mar 2007, 02:11
I'm curious: How is the beforeturn script stored internally? I can see plenty of ways to implement it, but none match the behaviors of:

1) If multiple beforeturn tags are listed, all are run.
2) "beforeturn override" only works with the first tag.
3) It was not explicitly designed to allow multiple tags.

Alex
01 Mar 2007, 14:23
Each room has one "beforeturn" script stored. When multiple "beforeturn" tags are specified, they are added to the room's "beforeturn" script.

If "override" is the first keyword in the script, Quest knows not to run the game's "beforeturn" script.

Because Quest only looks for "override" in the first keyword of the script, if you specify multiple "beforeturn" tags in a room, the "override" must be in the first tag if you want to use it.

Freak
01 Mar 2007, 14:52
So if you had code that adds multiple lines to the beforeturn script (instead of replacing it), why were you surprised by my mention of "first beforeturn line"?

Alex
01 Mar 2007, 15:59
I was just clarifying what you meant, since I'm not aware of any games actually using multiple "beforeturn" lines (since most games are created in QDK). Additionally I didn't check how it was handled until your question about how it is stored prompted me to look at the code.

Freak
01 Mar 2007, 16:37
Would multiple beforeturns be handled internally as a single newline separated string (as are functions / procedures), and that the various "run script" routine will handle such a string as a multiline script?

I'd been assuming (considering the way Quest deinlines braces) that "script properties" had to be a single line string, and that functions / procedures were handled as an array of single line strings.

(Also, this forum keeps accusing me of being a spambot whenever I post.)

Alex
01 Mar 2007, 17:35
Yes, multiple beforeturns are handled internally as a single newline separated string.

The "run script" routine handles multiline scripts - it just runs each script line in turn (it doesn't need to worry about there potentially being nested script blocks as these will have been taken care of when Quest initially loaded the file and they were converted into intprocs).

Freak
01 Mar 2007, 17:50
The conversion to intprocs is what I meant by deinlining.