Put thing in container
EagleWing
16 Sept 2004, 17:42I have a vending machine, which I have typed as container. I put the coin into the machine (reason for it being a container). It acknowledges that I have done so. (You put the Coin in the vending machine.) However, I wish this to be followed by a message to the effect that it has delivered a bar of chocolate (which has been hidden up to this point), and for the chocolate to become visible and available. Where I'm coming unstuck, I think, is that I can't use #quest.command# in a conditional statement. I've read and re-read the documentation for q3ext but haven't found the solution.
Sorry to be a nuisance but I need some help, please.
Frank
steve the gaming guy
16 Sept 2004, 19:58EagleWing wrote:This question is probably for Al (but no objections to others answering, of course).
I have a vending machine, which I have typed as container...
...I've read and re-read the documentation for q3ext but haven't found the solution.
This almost sounds related to the container/containable code in the typelib library by MaDbRiT...at least it seems close to what I read in the manual he supplied. Q3EXT is older than his typelib. Although, the way you worded your problem sounds like you're on the right track. Since I haven't fooled too much with containable objects yet, that's as far as my advice will go for now. So Al might suggest you download his typelib library.
steve
EagleWing
16 Sept 2004, 20:43Frank
steve the gaming guy
17 Sept 2004, 01:41steve
007bond
17 Sept 2004, 06:37To answer the original question:
First make sure you are using TypeLib.
Now, make the chocolate bar a containable too, and put it inside the vending machine.
Now, when the coin is inserted, remove the chocolate bar from the vending machine, and give it to the player.
Another way you can do this is when the player inserts a coin, remove the chocolate bar from the vending machine (its now in the small slot), and set a flag.
In the script for taking the chocolate bar, check if the flag is set, if not, don't let them take it.
Hope you can understand this, and glad I could help
PS: I'll eventually get round to uploading TypeLib to my website, but for now, you'll have to hunt for it.
MaDbRiT
17 Sept 2004, 08:43Message to 007Bond in particular.
please do not post a copy of my typelib to your website
The latest version of typelib that I have released for general usage is available from my website.
http://members.aol.com/agbampton/html/typelib.zip
I have made a point of uploading the last complete release this morning, so it really is the 'latest official release'.
If you want to link to my download page from your website, that's fine by me as that ensures there is only one version of typelib available at any time. This means if I tell someone to "download the latest release" I can be sure that they get the version I'm expecting - not an older copy uploaded to an unauthorised site by A.N. Other.
I'm ot trying to be 'precious' or 'awkward' here, just practical, it is simply much easier for me to support a lib I am the sole distributor of.
Message to Frank
The typelib code DOES cater for consequences resulting from putting a containable into a container, there's a special 'contained' action provided with each 'containable' for exactly that purpose.
If I may quote from my typelib.qlb "readme.txt":-
19-Sep-2002:
Beta version. TLTcontainable type modified to call an action
when a TLTcontainable becomes 'contained' (i.e. when object is
put into a container or given to a TLTactor). The action is
named 'contained' and the default is to simply print a message
saying 'O.K.'. This allows authors an easy way to extend the
functionality by replacing the 'contained' action with one of
their own.
This change was prompted by S.A. George, who pointed out that
although the library handled (say) putting a lit torch into a
barrel of black powder perfectly well up to the point of the
torch being moved and then reported as being in the barrel etc.
it required convoluted coding to make anything further happen
(an explosion in this case) as a result.
Following on the example above, adding a replacement 'contained'
action to the torch that checks its location and triggers an
explosion if it has been put into the barrel is now very simple.
My thanks to Ali (S.A. George) for the useful feedback.
I'm working at the moment, but I'll knock up a quick choccie bar demo in my lunch break if I have time.
Al (MaDbRiT)
MaDbRiT
17 Sept 2004, 09:53Found ten spare minutes to knock out a quick choccie bar demo...
You need to cut n paste the code below into a text editor and save it as (say) "choccie.asl". In order for the code to work you also need the version of typelib.qlb http://members.aol.com/agbampton/html/typelib.zip from my website.
' "Chocolate Machine Demo"
' Created with QDK 3.52
!include <Typelib.qlb>
define game <Chocolate Machine Demo>
asl-version <350>
gametype singleplayer
start <Cafeteria>
game author <MaDbRiT >
game version <.001>
game copyright <© 2004>
game info <Created with QDK 3.52.>
end define
define synonyms
end define
define room <Cafeteria>
prefix <the>
define object <machine>
alias <chocolate machine>
alt <vending machine; chocolate machine; machine>
look <it's a Nestle chocolate machine - your favourite brand.>
type <TLTobject>
type <TLTcontainer>
properties <not takeable; noTake=No chance - It probably weighs 400kilos - and it is bolted to the wall!; listHeader=the dispensing tray at the bottom contains >
end define
define object <coin>
alt <money>
look <its a 50 pence piece - just enough to buy a bar of chocolate.>
type <TLTobject>
type <TLTcontainable>
action <contained> {
hide <coin>
show <chocolate>
msg <The vending machine gives a 'kerchunk' and dispenses a bar of chocolate...>
}
end define
define object <chocolate>
look <Nestle Nutty-Fruit, your favourite!>
prefix <a bar of>
hidden
type <TLTobject>
type <TLTcontainable>
properties <isIn=machine>
end define
end define
define text <intro>
end define
define text <win>
end define
define text <lose>
end defineMake sure that typelib and the saved ASL file are in the same folder and this demo should be runnable - you can also open the ASL in QDK and see how I set it up.
The demo isn't fully "mug-trapped" - making sure any unexpected input is dealt with properly is down to you
Al (MaDbRiT)
Oh yeah - make sure your text editor doesn't line-wrap the longer lines in the code above - that really screws things up!
EagleWing
17 Sept 2004, 13:50It was Q3EXT that was causing me probs. Once Steve mentioned TypeLib, I downloaded it (from your Tips and Tricks page) and read all the documentation where I found the stuff about containables. After a while of fiddling about with it i managed to write some workable code. I was quite proud of the fact that I managed to write a workable Eat command as well.
' "The Tower"
' Created with QDK 3.52 - UNREGISTERED VERSION
!include <TypeLib.QLB>
define game <The Tower>
asl-version <350>
gametype singleplayer
start <Outside the Tower>
game author <Frank Lane>
game version <0.001>
game info <Created with QDK 3.52 - UNREGISTERED EVALUATION VERSION.>
default fontname <Comic Sans MS>
default fontsize <10>
startscript flag off <rats_fed>
command <eat #@foodthing#> if ( #@foodthing# = Bar of Cadbury's Chocolate ) and got <Bar of Cadbury's Chocolate> then {
msg <You eat the chocolate, despite its rather nasty appearance.|n The next moment you feel violently sick and throw up all over the floor.>
hide <Bar of Cadbury's Chocolate>
create object <sick; #quest.currentroom#>
}
else msg <I'm not sure what you want me to eat.>
end define
The actual choccy bar bit goes like this
define object <Coin>
alt <cash; money; dosh; dough; two bob>
look <It is an old coin from before decimalisation. It was a silver coin but is badly tarnished now.>
take
speak <I'd get seriously worried if I found myself talking to money.>
examine <It is worth two shillings. You vaguely remember that two shillings was the equivalent of 10p.>
prefix <the>
article <it>
gender <it>
hidden
invisible
type <TLTobject>
type <TLTcontainable>
action <contained> {
move <Bar of Cadbury's Chocolate; Cafeteria>
msg <There is a clunk and the bar of chocolate falls into the cup of the vending machine, bounces out and lands on the floor.>
show <Bar of Cadbury's Chocolate>
reveal <Bar of Cadbury's Chocolate>
}
end define
Which is quite similar to yours (though not so elegant and I have every intention of swiping bits of yours!!)
Anyway, thanks for the effort you put in and for all the help you've given me so far.
Frank
MaDbRiT
17 Sept 2004, 15:19thanks for the effort you put in and for all the help you've given me so far.
You're welcome - hopefully you'll find typelib to be a lot more useful (and easier to use) than Q3EXT... nice to see it being put to use.
Al (MaDbRiT)