Question about MaDbRiT’s library and containers.

Anonymous
10 Feb 2004, 20:29
I had a part in my game where if you put something in the fire it would be consumed. The code looked something like this:




' "test1"
' Created with QDK Pro 3.51

define game <test1>
asl-version <350>
gametype singleplayer
start <living room>
game info <Created with QDK Pro 3.51>
end define

define synonyms
end define

define room <living room>
command <put papers in fireplace> {
msg <You put the papers in the fireplace and they are quickly consumed.>
hide <papers>
}

define object <papers>
look <Personal papers that you don't want anyone to see.>
take
end define

define object <Fireplace>
look <An elegant looking fireplace with a fire blazing.>
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define



Very simple and works just fine. However if I want to use MaDbRiT’s typelib it won’t work. The command won’t do anything unless I define the papers as “containable” and the fireplace as a “container”, in which case it just puts the papers in the fireplace. How can I get the script to work? Keep in mind that I may want to be able to put the papers in another “container” without having the same effect.

Anonymous
11 Feb 2004, 08:36


Very simple and works just fine. However if I want to use MaDbRiT’s typelib it won’t work. The command won’t do anything unless I define the papers as “containable” and the fireplace as a “container”, in which case it just puts the papers in the fireplace. How can I get the script to work? Keep in mind that I may want to be able to put the papers in another “container” without having the same effect



Because the command you need to use is EXACTLY the one required for containers, using typelib does indeed hi-jack your 'put in' command and place the paper 'containable' into the fireplace containable as you might reasonably expect it to do.

However I provided an extra 'contained' action for exactly this sort of thing. All you need to do is add a script to the paper's 'contained' action that checks for the fireplace and acts accordingly. You then no longer need your 'special' put in command at all.

The finished code will look something like this...



' "test1"
' Created with QDK Pro 3.51

!include <Typelib.qlb>

define game <test1>
asl-version <350>
gametype singleplayer
start <living room>
game info <Created with QDK Pro 3.51>
end define

define synonyms
end define

define room <living room>
look <living room>

define object <papers>
look <Personal papers that you don't want anyone to see.>
take
type <TLTobject>
type <TLTcontainable>
action <contained> if ( #papers:isIn# = fireplace ) then {
msg <The papers burst into flames and are quickly consumed.>
hide <papers>
}
else msg <O.K.>
end define

define object <Fireplace>
look <An elegant looking fireplace with a fire blazing.>
type <TLTcontainer>
end define

define object <briefcase>
look <Your flashy leather briefcase.>
take
type <TLTobject>
type <TLTcontainer>
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define


I added the briefcase to show how you can use the default 'containers' functions alongside the special 'action' coded to destroy the papers.

You can cut and paste the above example into a text file, save it as 'fireplace.asl' or something such, then load that into QDK to see how I did it.

The above was done entirely from QDK.

Al (MaDbRiT)

Anonymous
11 Feb 2004, 19:22
Perfect! I didn’t think of using the “isIn” property like that. Thanks very much