![]() |
![]() ![]() ![]() ![]() ![]()
|
Author | Topic: Read command.... |
Computer Whizz |
![]() OK. Now I want the player to be able to "read" many objects. I want them to type read object. And the different object's will come up with different read answers. The one's that can't be read would come up with a simple message saying : "You look all over the brick and can't find anything to read!" or something like that. Now how would I go about coding it so that some pre-defined objects have pre-defined read "procedure's". I don't want to revert it to look, or other such stuff. I don't want to have room defined "read #obj#" commands. I don't want loads of IF's. Isn't there something in the define object block where I can just list a load of "msg <>"'s and have a procedure call it? Computer |
Luridii |
![]() Umm you could give each object a 'readable property' and also a readobj property eg. define object <Cookbook> define object <Picture Book> have an array such as set string <read[1]; lots of tasty recepies> in the game define block have a command command <read #obj#> if property <#obj#;readable> then msg <#read[$objectproperty(#obj#;read)$]#> else msg <You cannot read #obj#> i think that should work :) |
Computer Whizz |
![]() Well, it wouldn't like it too much if I started doing this: set string <read[1];You read the book.|nIt says "one day in the distant future one man will come forth to rule the land and all who walks on it. This person will be...."|nWhat a load of bull!|n You flick through some of the pages and notice that there is something stuck inside! give <feather> |n you recieved the feather!> Computer |
Luridii |
![]() i didnt realise you wanted to have things happen as well, as u just said a load of msgs :o |
Computer Whizz |
![]() Yes... it would have been an easy way to do messages.... but I do want events to happen! I'm going to scour the ASL-284 documents now!! Computer |
Computer Whizz |
![]() OK. I have just read that an object has an action <#action_name#> (script) feature there.... Can someone please explain how this works? thanx!! Computer |
Computer Whizz |
![]() Alex.... couldn't you add this "read" feature just like the "look" and "examine" part of the define object? This would be a welcome part to the object definition in my opinion! Computer |
MaDbRiT |
![]() Computer Whizz wrote:
quote: Adding stuff like a read feature is easy to do yourself. There's a cut, paste and run demo of how I'd do it in this posting! I'll modify this code and add it to my Quest 3 Extension library if anyone needs it. This code gives the author a 'readable' type to use, defaults for those items that are NOT defined as type <readable> a default message for readable items, (which can be overridden on an object by object basis) and will even allow 'reading' an item to optionally run other ASL code if needed. It makes use of Quest's 'type' and 'action' structures and I cranked it out in under 20 minutes so it may have a bug or two... but it should demonstrate my point O.K. Here's the code - it might wrap so you'll need to use common sense:
quote: Thats it - anyone feel this 'readable objects' code should be 'library-ised' and put into my forthcoming Quest Extension library please let me know. Any other suggestions will be listened to as well :-) Al |
Computer Whizz |
![]() Huh? I understand alot of it, but what is it with all this "nil" stuff? All you really need is something like one if, check if it's got the property readable. Then doaction >#object#; read>! Why all that extra complicated stuff? Computer |
MaDbRiT |
![]() C W wrote:
quote: It's there because the code doesn't just provide a message in response to 'read object.' The readaction=nil is a flag so that by default when an object is read only the 'readmessage' property is printed out. If you provide an individual object with an action called 'readaction' then that will override the default 'readaction' (which does nothing) in the type definition. If readaction is overridden then the code here will print out the readmessage appropriate to the object and then run the 'readaction' action provided by the author maybe that will open a door - causing dust to fly up - whatever. Essentially this is providing both a simple 'read' message and optionally an action that is triggered by the reading. The 'readaction = nil' is thus the flag for this optional functionality. I think that was what the original poster was after. :-) Look at the newspaper section of the code and you'll see that it has a 'readaction' property - When you read the newspaper you'll find Quest prints out the readmessage and then the informational message
quote: THAT is where you'd put whatever code you wanted to run when the newspaper is read. Splitting it like this means one can control the two events of reading and action triggered by reading independently - useful in a general purpose piece of code. Al |
Computer Whizz |
![]() AAAAhhhhh!!!! I see (barely!). I guess I was confused with all the glittery new code ![]() I'd have just used: But that's me I guess! Computer |
MaDbRiT |
![]() C. W. wrote:
quote:
It's coded in this (slightly obscure) way because of my 'library minded' attitude to code of a general purpose nature. Were that code parcelled into my forthcoming library an author would simply need to include the library and to get a 'readable' object use:-
quote: (That type <scenery> is for something provided by my new q3ext library - ignore it for the moment.) The 'tablet' object would automatically get the default 'boring to read' message and all other objects would get 'there's nothing to read' - with no further effort from the author. All other readable objects defined this way would benefit similarly. Now if the author has several other 'boring to read' objects - but wanted this specific tablet to present a different message when read - he could add something like:-
quote: To the code as shown above. That will override the message just for this object - others will still get the default as before. Later in the game he might find a spell book, he could code that like so:-
quote: This allows actions to be triggered by reading the object - and these can be controlled locally in the object definition so that the 'readable objects' code (which is written in a library) need never be changed. Again this extra functionality doesn't affect any other 'readable' objects defined - they still get default behaviour. I mention in my Q2 tutorial how writing code for libraries tends to cause complications for the library author in order to provide ease of use for the library user, this is a good example of what I meant. OTOH the author doesn't actually need to know how code actually works to use it and tailor it's behaviour, that is always one of the main aims of my libraries. Al |
MaDbRiT |
![]() Oh yeah... Discussing this 'readability' function has made me decide to rework it and build a 'readable' type into Q3EXT my Quest 3 Extension library - which is in beta at present. !Include <Q3EXT.QLB> will therefore effectively add a READ command to Quest's armoury - amongst other goodies ;-) Al |
Computer Whizz |
![]() COOL!!! I'll be waiting to get a look Your librarie's are always very vast in size!!! I'll have to pay more attention. Computer |
MaDbRiT |
![]() ARGGGHHHH!!!! WAY back in this thread i mentioned I'd cooked up the code example for readable objects in twenty minutes and it might have bugs - perhaps I ought to have given it half an hour :-( The code as given in this thread has an absolutely HUGE bug caused by sloppy coding on my part - the fact it 'seems to work' at all is purely good fortune. Never mind - a debugged version that works properly is now in my extension library "q3ext.qlb", which I hope to make available very soon. Al |
Computer Whizz |
![]() Well, it all seems WAY too complicated IMO! ![]() . . . My head hurts slightly as well, since I just got Visual C++ (6.0) and have been fooling around with it..... EEEERRRRRGGGGGHHHHHH!!!! ![]() I'll get VB6.0 installed soon...... that's a bit easier for me to understand!!! But right now, I've got to deal with my second HDD that is down to just 500-odd megs! Computer |
MaDbRiT |
![]() quote: If you think my little bit of ASL is 'way to complicated' - you are going to HATE MS c++ 6 with a vengeance - nothing is easy to do in C++ anyway and the MS version of C++ seems (IMHO) to set out to make C++ - (which is horrible to learn anyway) as hard as possible to grasp. I can write code using MS Visual C++, indeed I have to as part of my job, but using it is about as pleasant as having teeth extracted without anaesthetic. Personally unless I am actually forced to use it, I'd choose to use almost anything else in preference. Don't get me wrong, C++ is very very powerful, but unless you want to use it's low level power it is overkill. If your garden is overrun with weeds a little gardeners flame gun does a good job, learning to fly a jet strike aircraft so you can carry out a precision napalm bomb strike on the garden is effective for sure - but probably a little over the top. I almost always find I can do 95% of coding jobs as effectively and much more quickly with something other than the 'big gun' of C++. Off topic I know, sorry Alex! Al |
Computer Whizz |
![]() Well....... we should move this into the chat room...... but since I only have a few words to say, I'll say them here, any other discussion (on my part) will be moved into the chat room! Yes, having a look at their "Hello World" programme..... YEEEESSHHH!!! Right now I've been trying to find out how do operate the button's, ect... I'll just go and put my tail between my legs now :) Computer |