Repeating unwanted line -- sometimes

steve the gaming guy
02 Jan 2005, 03:03
Alex,

I've included a portion of the code in the game I'm working on and hopefully you can tell me what's happening. I apologize for the length of it but it's as short as I could get it for this question.

Basically, I have a room (mountain2) where the player gets hungry and after each turn, a statement is supposed to display at the end showing the player is hungry.

When "look" is typed, it displays the room description and the correct "hunger" line. But if you look at objects in the room such as "look at branch", it displays the description of the branch but then it displays the line that the player is hungry two times in a row. I don't understand why this is happening. If you have any thoughts, please let me know.


' "King's Quest V - text adventure"
' Created with QDK 3.53 - UNREGISTERED VERSION

!include <Typelib.qlb>

define game <King's Quest V - text adventure>
asl-version <350>
gametype singleplayer
start <mountain>
game author <Steve Lingle>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
startscript give <lamb1>
command <eat #@object#> {
if ( #object# = lamb1 ) then do <lamb> else msg <Graham does not want to eat the #@object#.>
}
define variable <hunger>
type numeric
value <5>
end define
end define

define synonyms
take = get
end define

define room <mountain>
prefix <the>
look <There is not much too see up in this part of the snow peaked mountains. The path leads on to the north.>
north <mountain2>
west <Town Path>
end define

define room <mountain2>
alias <mountain>
prefix <the>
look <There is not much too see up in this part of the snow peaked mountains. The path ends abruptly at the edge of the mountain.|nAbove on the side of a cliff, Graham can see a tree branch protruding from the snow covered plateau and a bit of rock jutting outwardly a few feet from the tree branch.|nJust above these seems to be a sturdy place to stand if there were only some way to reach it.>
south <mountain>
afterturn {
if got <lamb1> then flag on <hungry> else flag off <hungry>
if flag <hungry> then {
dec <hunger; 1>
msg <The height in altitude causes Graham to feel extreme hunger. He better find something to eat soon.|n>
if ( %hunger% = 0 ) then {
msg <Graham feels the final pain of hunger within him and he passes out.|n|nHe will soon perish before he regains consciousness.|n>
wait <press any key>
msg <If only Graham had found something to eat.|n|nhint - there are two items Graham could have eaten. One item is correct whereas Graham will only eat part of it and the remaining bit of food will be used elsewhere. The other item of food would be eaten by Graham completely thereby rendering a future puzzle without a solution.|nPlease play again, but choose wisely...|n>
wait <press any key>
playerlose
}
}
}

define object <branch>
alt <tree branch>
look <A tree branch protrudes out from the snow covered area above Graham.>
take msg <The tree branch is too high for Graham to reach by hand.|n>
prefix <the>
article <it>
end define

define object <rock2>
alias <rock>
alt <rock>
look <A piece of the mountain rock sticks out from the mountain side a few feet from the tree branch.>
take msg <The piece of rock is too high for Graham to reach by hand.|n>
prefix <the>
article <it>
end define

end define

define room <inven room>

define object <cloak>
look <A high-quality blue cloak is on display near the front of the Tailor's shop.>
take msg <You must speak with the sales clerk directly in order to purchase this cloak.>
examine <This blue cloak looks like it would keep its owner very warm in a cold place.>
prefix <a>
article <it>
gender <it>
drop nowhere
type <TLTobject>
type <TLTcoat>
properties <not takeable; noTake=You must speak with the sales clerk directly in order to purchase this cloak.; wearmessage=Graham puts on the blue cloak and feels much warmer.; unwearmessage=Graham takes off the cloak.>
action <take> msg <Graham must speak with the sales clerk directly about the cloak.|n>
end define

define object <lamb1>
alias <leg of lamb>
alt <leg; lamb>
look <The leg of lamb looks delicious.>
take {
msg <Graham takes the leg of lamb and closes the door to the pantry.>
give <lamb1>
inc <Score; 2>
}
prefix <the>
gender <it>
drop nowhere
end define

define object <lamb2>
alias <half leg of lamb>
alt <leg; half; lamb>
look <The leg of lamb looks delicious. Half of it has been eaten.>
prefix <the>
gender <it>
drop nowhere
end define

end define

define procedure <lamb>
if ( #object# = lamb1 ) and flag <hungry> then {
msg <Graham eats half of the leg of lamb but decides to save the other half for later.>
lose <lamb1>
move <lamb1; inven room>
give <lamb2>
flag off <hungry>
inc <Score; 2>
}
else msg <Graham is not hungry right now.>

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
Please try again. If you've saved the game, please restart by clicking "restart" in the lower righthand corner of the screen.
~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
end define

Alex
02 Jan 2005, 11:00
I'll take a look into this in more detail later (not sitting in front of a computer with Quest on it at the moment), but do you get the same problem if Typelib is not included?

steve the gaming guy
02 Jan 2005, 20:28
Alex wrote:I'll take a look into this in more detail later (not sitting in front of a computer with Quest on it at the moment), but do you get the same problem if Typelib is not included?

Hmm, I don't know. I was hoping it's not a typelib problem. I'll look into it though. I have typelib because two items in my game are to be worn and the setup works pretty good with that.
But again,...I'll look into it

thanks!

UPDATE

Drat, I guess it IS typelib. I'm not sure why that is the problem but I took it out and the lines no longer repeat. Oh well. I guess I'll just have to deal with it.