Reverse logic always works

rgaudet
02 Oct 2008, 20:50
The new guy is back with yet another problem. This time, my head is somewhat flatter from banging it against the wall. This time I'm going to use reverse logic. I'm going to 'assume' that if you guys show me how to do the easy stuff then I won't have any problems learning the hard stuff.

Here's my present problem. I have a knapsack sitting on a hill. When I pick up the knapsack my game score is supposed to increase by 3 points. But, of course it is not increasing. :evil: :evil:
Here's the logic I'm using:

When I 'gain' the knapsack I check to see if a flag 'packfound' is not set or on. If it is not on then I increment my game score by 3 points and then I turn on the flag 'packfound'. I've enclosed my code. Could someone be kind enough to help out.


' "The Enchanted Forest"
' Created with QDK Pro 4.03

!include <net.lib>
!include <stdverbs.lib>
!include <standard.lib>
!include <typelib.qlb>

define game <The Enchanted Forest>
asl-version <400>
gametype singleplayer
start <Enchanted Forest>
game author <Ron Gaudet>
game version <1.00 (Beta)>
game copyright <©2008 by Ron Gaudet [Freeware]>
game info <Created with QDK Pro 4.03>
default fontname <Fixedsys>
default fontsize <2>
startscript {
msg <|nThe 'Enchanted Forest' is a very enlarged and modernized version of the first game written for a computer. This game was known as "Adventure" and also as "Colossal Cave". The original game, the associated game creating software and numerous improvements were provided through the hard work and imaginative thinking of Will Crowther, Don Woods, David Platt, David Malmberg, Robert Masenten, David Kinder and many others. These people are certainly the pioneers of all computer gaming. Thanks all.|n|nI hope that (thanks to QDK) you enjoy what I believe to be the latest and greatest version of this adventure.|n |nSincerely,|n |n Ron Gaudet|n|n-- Press any key to continue. -- >
wait <>
clear
}
afterturn inc <turns>
command <>
command <>
command <>
command <>
verb <>
verb <>
verb <>
define variable <score>
type numeric
value <0>
display <score ! out of 1907 points>
end define
define variable <turns>
type numeric
value <0>
display nozero <turns !>
end define
end define

define options
debug on
panes on
abbreviations on
end define

define menu <Hint>
$Exploring local Area
end define

define room <Enchanted Forest>
prefix <the>
look <|nYou are standing in a clearing in a very large forest. Around you is a dense jumble of high, closely-spaced trees and large,thick bushes. There seems to be no direction in which you can travel. However, looks CAN be deceiving for somewhere, nearby, are two huge and complex cave networks where many have found great fortunes in treasure and gold, though it is rumored that some who enter the caves are never seen again. Your goal is to find, enter and explore the caves and to return as much treasure as possible to the safety of the 'pump-house': which you will find in the forest. If the treasure is left any place else above ground, it will surely be stolen by the forest creatures. The caves are dangerous, mysterious and magical places. You will face many puzzling and perilous challanges as you explore them. It is also rumored that the surrounding forest is enchanted and that many strange things happen here. Before trying to enter the caves, you should first explore the forest and try to find anything and everything that may be of help inside these caves.|n|nTo receive more instructions, at any time in the game, about how to explore the game areas, type 'help' and press 'enter'. To help solve some of the area's puzzles, please type 'hint' and press the 'Enter' key at any time during the game.|n|nTo begin your quest without further instructions, type 'start' (upper or lower case) and press the 'Enter' key.>
indescription <You are at>
command <start> {
clear
goto <High Hill>
}
end define

define room <High Hill>
look <|nYou are quickly engulfed in a thick cloud of dark green haze from which you are unable to see. You seem to be floating slowly through a long tunnel within the green cloud. After some time, the haze clears and you find yourself standing on a dirt road at the top of a very high hill. Around you spreads the large enchanted forest. As far as you can see, in any direction, the forest is surrounded by very high and steep mountains. From the top of the hill there are narrow paths heading in many different directions but they are all too overgrown to travel down. Your only choice of travel is the road leading down the hill and far to the east where you can barely see a small building.>
indescription <You are at the:>
east <End Of The Road>
down <End Of The Road>
place <the; end of the road>
script do <CountRooms>
action <>

define object <knapsack>
alt <pack; backpack>
look <A knapsack is pack is a backpack. You can put things in it and wear it on your back in order to ease the load you are carrying.>
take
gain {
if not flag <packfound> then
inc <score; 3>
flag on <packfound>
}
speak <You must be kidding me!>
prefix <A>
displaytype <Object>
article <it>
gender <it>
container
open <With the pack open you can use it to carry many more thing.>
close
add
remove
type <wearable>
type <TLTobject>
type <TLTcontainer>
type <TLTcontainer>
type <TLTclosable>
type <TLTcoat>
properties <sizeLimit=100; weightLimit=100; sizeLimit=100; weightLimit=100>
action <>
end define

end define

define room <End Of The Road>
indescription <You are at the:>
west <High Hill>
script do <CountRooms>
end define

define room <inven room>
end define

define procedure <CountRooms>
if not property <#quest.currentroom#; entered> then {
inc <score; 1>
property <#quest.currentroom#; entered>
}
end define

paul_one
03 Oct 2008, 14:26
I suppose it could be due to the new line after the "then".

I'm also not 100% sure that the gain part is kicked off using the built-in take commands.

rgaudet
03 Oct 2008, 19:19
I moved the knapsack routine from 'gain' to 'take' and the score still doesn't increment. 'Tiss a mystery :?: I've attached the latest code.
 ' "The Enchanted Forest"
' Created with QDK Pro 4.03

!include <net.lib>
!include <stdverbs.lib>
!include <standard.lib>
!include <typelib.qlb>

define game <The Enchanted Forest>
asl-version <400>
gametype singleplayer
start <Enchanted Forest>
game author <Ron Gaudet>
game version <1.00 (Beta)>
game copyright <©2008 by Ron Gaudet [Freeware]>
game info <Created with QDK Pro 4.03>
default fontname <Fixedsys>
default fontsize <2>
startscript {
msg <|nThe 'Enchanted Forest' is a very enlarged and modernized version of the first game written for a computer. This game was known as "Adventure" and also as "Colossal Cave". The original game, the associated game creating software and numerous improvements were provided through the hard work and imaginative thinking of Will Crowther, Don Woods, David Platt, David Malmberg, Robert Masenten, David Kinder and many others. These people are certainly the pioneers of all computer gaming. Thanks all.|n|nI hope that (thanks to QDK) you enjoy what I believe to be the latest and greatest version of this adventure.|n |nSincerely,|n |n Ron Gaudet|n|n-- Press any key to continue. -- >
wait <>
clear
}
afterturn inc <turns>
command <>
command <>
command <>
command <>
verb <>
verb <>
verb <>
define variable <score>
type numeric
value <0>
display <score ! out of 1907 points>
end define
define variable <turns>
type numeric
value <0>
display nozero <turns !>
end define
end define

define options
debug on
panes on
abbreviations on
end define

define menu <Hint>
$Exploring local Area
end define

define room <Enchanted Forest>
prefix <the>
look <|nYou are standing in a clearing in a very large forest. Around you is a dense jumble of high, closely-spaced trees and large,thick bushes. There seems to be no direction in which you can travel. However, looks CAN be deceiving for somewhere, nearby, are two huge and complex cave networks where many have found great fortunes in treasure and gold, though it is rumored that some who enter the caves are never seen again. Your goal is to find, enter and explore the caves and to return as much treasure as possible to the safety of the 'pump-house': which you will find in the forest. If the treasure is left any place else above ground, it will surely be stolen by the forest creatures. The caves are dangerous, mysterious and magical places. You will face many puzzling and perilous challanges as you explore them. It is also rumored that the surrounding forest is enchanted and that many strange things happen here. Before trying to enter the caves, you should first explore the forest and try to find anything and everything that may be of help inside these caves.|n|nTo receive more instructions, at any time in the game, about how to explore the game areas, type 'help' and press 'enter'. To help solve some of the area's puzzles, please type 'hint' and press the 'Enter' key at any time during the game.|n|nTo begin your quest without further instructions, type 'start' (upper or lower case) and press the 'Enter' key.>
indescription <You are at>
command <start> {
clear
goto <High Hill>
}
end define

define room <High Hill>
look <|nYou are quickly engulfed in a thick cloud of dark green haze from which you are unable to see. You seem to be floating slowly through a long tunnel within the green cloud. After some time, the haze clears and you find yourself standing on a dirt road at the top of a very high hill. Around you spreads the large enchanted forest. As far as you can see, in any direction, the forest is surrounded by very high and steep mountains. From the top of the hill there are narrow paths heading in many different directions but they are all too overgrown to travel down. Your only choice of travel is the road leading down the hill and far to the east where you can barely see a small building.>
indescription <You are at the:>
east <End Of The Road>
down <End Of The Road>
place <the; end of the road>
script do <CountRooms>
action <>
define object <knapsack>
alt <pack; backpack>
look <A knapsack is pack is a backpack. You can put things in it and wear it on your back in order to ease the load you are carrying.>
take {
if not flag <packfound> then {
inc <score; 3>
flag on <packfound>}
}
msg<>
speak <You must be kidding me!>
prefix <A>
displaytype <Object>
article <it>
gender <it>
container
open <With the pack open you can use it to carry many more thing.>
close
add
remove
type <wearable>
type <TLTobject>
type <TLTcontainer>
type <TLTcontainer>
type <TLTclosable>
type <TLTcoat>
properties <sizeLimit=100; weightLimit=100; sizeLimit=100; weightLimit=100>
action <>
action <>
end define

end define

define room <End Of The Road>
indescription <You are at the:>
west <High Hill>
script do <CountRooms>
end define

define room <inven room>
end define

define procedure <CountRooms>
if not property <#quest.currentroom#; entered> then {
inc <score; 1>
property <#quest.currentroom#; entered>
}
end define


paul_one
03 Oct 2008, 23:13
I see you're using Al's type library?

To my knowledge his library changes the way 'take' works.
That could be it.

rgaudet
04 Oct 2008, 20:36
ARG :twisted: ARG :twisted: This is making me quite unhappy. Depending upon whether I include typelib.qlb or do not include it, I can either add points to the game when I get the knapsack or I can wear the knapsack (show it is being worn). But I cannot do both at the same time. :twisted: I believe that the real problem is that, when I add the knapsack as an object to the game, I can show it as a container but I do not see any way to also give it the property of 'wearable' Perhaps, this version of Quest Pro just does not have the ability to do that :?:

Freak
04 Oct 2008, 23:28
Try putting in two "type <...>" lines.

Or make it wearable normally, and put code in the "afterturn" script that checks whether the player is holding the knapsack and packfound is off.

Or use a language like TADS or Inform, which can handle this without trouble.

MaDbRiT
05 Oct 2008, 08:59
Hi

I notice that you are including both 'net.lib' and my 'typelib' AND you're writing a game in Quest 4.x.

Typelib was intended (and only works properly) for single player games written in Quest 3.x. As far as I know (I've not done any Quest coding since 4.x came out for various reasons) Quest 4.x includes by default most of the functionality that was added to 3.5 by my 'Typelib.qlb' library.

I can tell you that a wearable, carryable haversack container was very easy to do in Q3.x using my typelib - that was one of the things I expressly wanted it to do - I assumed that Q4.x with its own container functionality rendered my typelib completely obsolete.

Maybe I'm wrong - but I have a bad feeling that having two different ways to implement carryable containers (the quest new default V4 way and my typelib's kludge for V3) at the same time is likely to make things at best hard to follow at worst impossibleto implement.

Al (DaMaDbRiT)

Alex
13 Oct 2008, 16:56
You could add a "wear" verb to an object, and that do whatever you want to do with it via script.

I could add support for wearing things to Quest, but what level of support would be useful? My thinking has always been that you can just add a command or verb pretty simply to add the ability to wear something, but does this mean some aspects of implementing clothing in a game are harder than they should be?

rgaudet
14 Oct 2008, 18:43
Alex:
I've only been using QDK Pro for a short time but I do like it very much. I can't imagine why it seems to be so hard to 'wear' things or to show them as being 'worn' when you take an inventory of what you're carrying (as AGT and MAGX do). I can also think of many things that should (or could) be worn. such items are a knapsack, pack, amulet, bracelet, protective cloak and so forth. I'm quite interested in this because I'm undertaking quite an extensive re-do of the old Adventure, Colossal Cave, Humongous Cave series. As I mentioned, AGT/MAGX and the like have no problems wearing things and adding points when objects are either carried or worn or you take them or wear them. This is in no way meant to belittle your skills and accomplishments with QDK. It's just that I've always liked the way these earlier games show objects as either being worn or carried when you take 'inventory'. I hope I got my point across without making this all too confusing.