Axe Software Forums
  Quest Developer Forum
  another scream for help


Author Topic:   another scream for help
Jim Jones posted 14-12-2002 02:34 GMT     
i am wondering how the library works... i am trying to make a file where it will acknowlage eat or drink...
MaDbRiT posted 14-12-2002 10:17 GMT          
Hi Jim

My library doesn't handle "eat" or "drink" at the moment, mainly because there is a very good example of how to code this in Alex's Quest manual (comes with Quest) and it is actually relatively easy to code.

However, if you are working from QDK rather than coding the old fashioned way, the explanation might not help that much - people like myself who have been coding for (AGHHH!) 25 years tend to assume a lot of prior knowledge sometimes.

Later today I will make up a small demo for you, using just QDK, showing an easy way to have your player take and eat a sandwich, you can then load this into QDK and see just what I did to make things work.

Looking to see "how others did it" is an essential part of learning to write code, which (although QDK tries its best to hide this fact from you) is going to be essential to get very far in writing adventure games - (To a basic level, you don't need to be a heavy duty programmer with Quest!)

Al

Jim Jones posted 14-12-2002 18:03 GMT          
okay then, i tryed making a library but it said something was wrong with it...
Computer Whizz posted 14-12-2002 23:48 GMT          
Libraries aren't anything like normal game files...

They have to be written (well - you could just cut & paste most of the stuff - but...) because it is in a different "format".

Computer Whizz

Jim Jones posted 15-12-2002 00:29 GMT          
That is pritty much what i did, i got most of the info from a page on this site
MaDbRiT posted 15-12-2002 09:35 GMT          
Hi again

Right, Firstly I suspect there are as many ways to make 'eat' work as a command as there are Quest coders, but here's ONE way of making a library that gives you 'eat' functionality.

Obviously there are two parts to this demo - so here's the ASL code as made in QDK

quote:

' "Food Example"
' Created with QDK Pro 3.12

!include <food.lib>

define game <Food Example>
asl-version <311>
start <kitchen>
game author <Al "MaDbRiT" Bampton>
game version <0.01>
game copyright <� 2002 ...>
game info <Just an example...>
end define

define synonyms
end define

define room <kitchen>
prefix <the>
look <The kitchen is clean and modern.>

define object <sandwich>
alt <cheese and pickle sandwich; cheese & pickle sandwich; cheese sandwich>
look msg <it's a cheese & pickle one - your favourite>
take
prefix <a>
type <edible>
end define

define object <soap>
alt <bar of perfumed soap; bar of soap; perfumed soap>
look msg <it's a bar of perfumed soap.>
take
prefix <a bar of>
end define

end define

define text <intro>
Adding "Edible" through a Library demo. Sandwich in this demo is edible, the bar of soap isn't. :-)
end define

define text <win>
Enter win text here
end define

define text <lose>
Enter lose text here
end define


Cut & paste the 'quoted' bit saving it as "food.asl"

O.K. now here is a very simple library, it provides a eat command, an eat action with default behaviour for non edible items, and an edible "type". The thing has a QDK interface too :-)
To use it you "include" the library from within QDK. then when making an object you want edible, tick the appropriate box on the object properties dialog - dead easy!

Here's the actual library, save this as "food.lib"

quote:

!library

!asl-version <311>

!addto game
command <eat #@object#> {
if type <#object#;edible> then doaction <#object#;eat>
else msg <You can't eat that!>
}
!end

define type <edible>
action <eat> {
msg <Mmm,that was very tasty!>
hide <$thisobject$>
}
end define

'====== Provide a QDK interface =======

!QDK
object <edibles>
type <Make this object edible; edible>
!end


And that basically is all there is to it!

Al