Re: how do I make an Object be in the player's inventory at start of game??


Tue, 5 Dec 1995 05:50:46 GMT

On 4 Dec 1995 21:32:50 GMT, jholder@nmsu.edu (John Holder) wrote:

>> Surely one doesn't need to declare a Class JellyBaby and enumerate each and
>> every jelly baby (all 30 of them!)? My husband, the systems programming guru,
>> doesn't think that would be so very inelegant, but what if the bag contains 75
>> objects, or 100? It gets rather unwieldy. Surely there's an elegant solution
>> to this?
well, I'm the one who started this, so I'll add something here. Someone
emailed me a really good solution to this: You don't give an exact amount
of objects at all, you just say there are 'jelly babies' but not an amount
and trap all of the actions (take/eat/give/drop etc) so as to give messages
and maybe set a flag or two for some of them (i.e. the guard is distracted
by the jelly baby on the ground and the player slips past him into the
prison, etc.) here is the code I was sent, I haven't tested it yet, but it
should work in theory:
----------- cut here -------------
Object bag "paper bag"
with name "paper" "bag",
description "An ordinary paper bag.",
before
[; Look, Examine: if (self has open) { "The paper bag is closed." }
"The paper bag is full of jelly babies.";
Insert: if (self has open) { "The paper bag is closed." }
"You don't really want to put anything into the bag of \
jelly babies.";
],
invent
[; if (inventory_stage==2)
print " (full of jelly babies)";
],
has openable container;
Nearby jelly_baby "jelly baby"
with name "jelly" "baby" "babies" "bean" "beans",
plural "jelly babies",
description "A kind of British jelly bean.",
before
[; Take: if (second = noun) { "You take a jelly baby out \
of the paper bag."; }
"You don't care to take the jelly baby back.";
Eat: "You eat a jelly baby. Not bad.";
Give: "You give a jelly baby to ", (the) noun,".";
Drop: "You drop a jelly baby onto the floor. It disappears.";
],
has scenery;
----------------cut here-----------------
well there it is, anyone know of a better way then this? I wanted
unlimited jelly babies/beans and this seems to do it...

Ron Nichols
demon@ih2000.net