|
Axe Software Forums
Quest Developer Forum Please help - changing object properties
|
Author | Topic: Please help - changing object properties |
Mega |
posted 07-10-2001 04:32 GMT
Here's my basic problem. I have a room in which I put a 'gate' object. I gave the 'gate' object an 'opened' property initialized to '0' (closed). I want the game to respond to the command 'open gate' with the following: if 'opened' = '0' (closed) then set 'opened' to '1' (open); else (if 'opened' started out as '1'(open)) print out "it's already opened!" I also want it to do the reverse for 'close gate'. However, when I start up the game and type 'open gate' twice, it says "the gate opens" both times, even though it should only say it the first time, and then tell me it's already opened when I try it again. However, when I try typing 'close gate' it tells me 'already closed', which is what it should do. What is going on? I think it has something to do with changing 'opened' from '0' to '1' and vice versa; this doesn't seem to be working right. What am I doing wrong? Also, this method was a second attempt at solving the problem. What I originally wanted to do was design an object type called 'openclose' that would apply the same principles as I stated above, and could apply to anything of the sort (a door, a cabinet, a treasure chest, etc). However, I couldn't get that working either. I'd prefer to use this method than the one above, so can someone please help me with that? Here's my code, by the way, if it helps. ' Created with QDK 3.02 define game <> define synonyms define room <outside gate> define object <gate> indescription <You are standing> define text <intro> end define define text <win> end define define text <lose> end define |
MaDbRiT |
posted 07-10-2001 09:33 GMT
Hi there, you have a few bits of incorrect syntax in your ASL - that's why it won't work as you expect. Rather than rewrite the whole thing the way I'd do it, here is an amended version of your posted code. This does work as you require :-)
quote: I too think this could be better accomplished by creating a type of object that can be opened or closed. If I have the time later today I will do that and post the code here :-) Hope this helps, Al |
MaDbRiT |
posted 07-10-2001 11:01 GMT
Earlier I wrote;
quote: I have used Mega's original code as a testbed and knocked out an 'openable' object type, the code follows shortly. The 'type' has open and close actions and deals properly with attempts to open already open objects etc. I also built in properties called 'opendesc' and 'closeddesc' - these should be used instead of setting a 'look' or 'description' tag for the openable object type. The correct decription is then provided automatically according to whether the object is closed or not :-) These properties replace the object's normal 'look' tag. If you don't provide the 'opendesc' or 'closeddesc' properties, the type creates an appropriate basic description for you and uses that. I've added a totally basic object called 'box' to Mega's code - just to demonstrate how an object behaves if just defined as type <openable> and left to use the defaults. I also extended Mega's 'Open' and 'Close' commands so that they tell the player he 'can't do that' if he tries to open or shut an object that DOESN'T have the appropriate actions defined. Here then is the code:
quote: I will slightly re-work this type and the related commands and include it into my forthcoming Quest Extensions library (q3extv2.qlb) So far that has over 20 object types defined in it :-) Any ideas for useful object types that I could add are welcome. Al |
Computer Whizz |
posted 07-10-2001 16:05 GMT
ummm.... Al, I just thought I'd better inform you of a slight bug which you have missed :
quote: that "closeddesc" should be "openeddesc".... that code took me a couple of moments to get around (I HATE object types!! :) ) but I then noticed this little error. I personally have no idea what object types you already have, and so can't think of what to suggest. Would you mind giving us a quick list?? Computer Whizz |
MaDbRiT |
posted 07-10-2001 18:23 GMT
Computer Whizz noticed:
quote: Well spotted C.W. In fact the code as given works anyway because I have provided both 'opendesc' and 'closeddesc' properties which is why I didn't pick it up when I knocked the type up - D'Oh :-)
quote: Do you? I LOVE them, they let me build objects that inherit functionality from others and make really useful specific types of object. I admit they are not always easy to follow or to code, but they are a powerful concept.
quote: Not at all, these types are all added (along with the commands needed to make them work) by my Quest 3 Extension library, which is now at 'beta 4' and is approaching the 1000 lines of code mark! What the types actually do takes a fair bit of explaining, but they are defined as. scenery * = The clothing type is never used directly, it is used to define 15 specific articles of clothing which can represent almost any garment with a little lateral thought. There's a lot of multiple usage, the 'human' type is also a 'container' type by default for instance. All of the associated commands and functionality these types suggest are in the lib. An example of how it works. In my demo of the lib I have a 'locker' which is 'scenery', 'openable' and a 'container' all at once. The locker is defined like this :-
quote: The 'scenery' means the locker is available for look and examine in the room, but not listed as an item and not take-able. It has an overrideable default response for attempts to do that. The 'container' means the locker has its own inventory, you can put other things into and take things out of it. Well you can when it is open thanks to it being an 'openable' too :-) The 'openable' means (literally) that the thing is openable! By default it starts off closed. Example. examining the locker will show the content only if the locker is open - get the idea? All of the commands and checking of what cannot be done / seen are provided by the lib. To get a working 'locker' there's nothing more to add to the definition I used above. The clothing type is very complex. Basically it understands the concept of clothing being worn in 'layers'. So if your player has on a jacket and shirt, he can't take the shirt off without removing the jacket first - can't put his socks on if he already has shoes on - you get the idea I'm sure. Obviously there are 'wear' and 'take off' commands in the lib to deal with this. To use the clothing - you just have to define it as a type. Everything else is dealt with by the lib. e.g. define object <parka> Is all you need for a 'fully working' jacket object that knows its place in the clothing layers :-) All the other types have similarly 'developed' behaviour, The human type is also a container and so on but as the manual explaing it all is 15 pages long I'll leave it at that for now. :-) I'm trying to build objects that are 'use out of the box' real world items here. Al |
Mega |
posted 08-10-2001 03:21 GMT
Thanx for all your help, guys! By the way Al, many thanx for the help with object types. I further modified your code to allow for the overwriting of the message printed in the 'open' and 'close' actions, as well as the 2 messages for 'look'. Here's my version: define game <> define synonyms define room <outside gate> define object <gate> end define ' This section defines the 'openable' type and provides open, close & look actions. action <open> { action <close> { action <look> { end define define text <intro> end define define text <win> end define define text <lose> end define |
MaDbRiT |
posted 08-10-2001 08:12 GMT
quote: Which is one of the things I did when I added the improved 'openable' type to my library too... LOL Actually in my lib it is a bit more complex because that provides 'container' objects, so the 'examine' messages are also tailored to provide different results for open / shut container objects - the contents are only described if a container is open ('container' and 'openable' are a most useful pairing of course)
Al |