look through (beginner)

Wilky
09 Oct 2011, 16:51
Is it possible to create a 'Look through' function for a window, keyhole, letterbox etc.? At present, I'm simply including it in the 'look' description... this is fine for a window but awkward on the others.

Also, I have a situation where the 'use object1 on object2' doesn't seem quite right... can I set up custom 'hit nail with hammer' or 'put egg in pan' commands? I have tried experimenting but to no avail.

Paul.

Alex
10 Oct 2011, 09:27
Just go the Verbs tab for your object and add "look through".

For "put egg in pan", this is handled automatically if you set up "pan" as a surface or container, and make the egg takeable.

For "hit nail with hammer", set up a command "hit #object1# with #object2#". See http://quest5.net/wiki/Custom_commands

Wilky
10 Oct 2011, 10:48
Many thanks, Alex.

Wilky
11 Oct 2011, 21:59
Okay, first two sorted, but creating a new command 'hit #object1# with #object2# is way beyond me!

I recall, in the mid-eighties, writing text adventure games, on the 'Speccie', with a program called 'PAWS', which had quite a powerful parser which allowed multiple commands to be incorporated into a single sentence. 'Get the apple, eat it, go north and thump goblin.' for instance. Back then, I had a very limited grasp of 'Basic' (even that's deserted me, now!) so the program must have been extremely user friendly for me to produce a finished game.

Now retired, and with my newly downloaded 'Quest 5', I'd looked forward to spending the winter months finding my way around it and knocking out a few simple plots for the grandchildren,

I've now found, after 10 or 12 days playing around with it, that Quest is far more flexible than I first imagined, provided you're capable of 'poking around' underneath the bonnet... but unfortunately, it seems I'm not. I can still produce the simple plots... with the emphasis on simple e.g. "Get apple.", "eat it", "go north", "thump goblin"... What I can't yet do is, "Bang head on wall"

At the moment, 'Quest', to me, is like a 'No. 7 Meccano' set... with all the parts in the box but the instructions for the more interesting projects, in Swahili. (C+ or whatever).

Have I got it all wrong?... has 'Quest' been created solely for the enjoyment of other computer programmers to the total exclusion of mere mortals?

Or, am I being unfair?... are you actually working towards a totally 'point and click' build, eventually?

Don't get me wrong!... I'm still enjoying the learning curve but it's so bloody frustrating having to "create this", "alter that"... just to tell my character to "hit nail with hammer" At present he's still having to "use hammer on nail"!

Okay... rant over! Back to it.

Regards,

Mister V. Meldrew.

Alex
12 Oct 2011, 08:20
You can type multiple commands on one line, but separated with full stops rather than commas.

You could just enter the pattern "hit nail with hammer", but that means it won't handle "hit the nail with hammer", or "look at nail. hit it with the hammer" etc.

You just need to add a new command, enter the pattern "hit #object1# with #object2#" (so it will match anything the player types of that form, e.g. "hit nail with hammer", "hit myself with fish"), then add the script that you'd like to run. In that script, add an "if" expression "object1 = nail and object2 = hammer". "Then:" will be the script to run in this case, and "Else:" should print a message like "You can't do that".

Like this:

hit.png


There are definitely ways that this could be made easier. Quest 5.0 was a complete rewrite of the system, so it's more like "New Quest 1.0" at the moment, so it will have a few rough edges.

How do you think the "hit X with Y" scenario could be made easier? One thought I have is to extend the current "verbs" system. It's easy to add "thump" as a verb to an object at the moment, so that mechanism would stay as a "one-object verb", then there would be a new way of adding a "two-object verb".

So you might edit the nail object, add a new "two-object verb" and type "hit" and "with". Then you would get an editor like the current "give" and "use" editor, where you could add "hammer" to the list of "other objects". What do you think?

Wilky
12 Oct 2011, 12:28
Absolutely spot on!... and so simple. I expected brackets, quotation marks, semi colons etc. within the expression.

Would the following be correct, then?
if object1 = nail and object1 = visible and object2 = hammer and object2 = carried then print "bang bang"

Or am I being a little too optimistic about it's simplicity?

Anyway... faith restored! Thanks for taking the time to set up that example, Alex.

Alex
12 Oct 2011, 13:36
Very close!

You don't need to check whether the objects are visible, because Quest does that for you - when the player types "use hammer on nail", or "use it on nail", or "use ham on na", Quest works out what object1 and object2 are, based on what's visible in the room. So if the nail is not visible, Quest won't run the command in the first place.

To see whether an object is being carried, you need to see if it's within the "player" object. To do this, you read object2's parent property. So the expression you need looks like this:


object1 = nail and object2 = hammer and object2.parent = player

Wilky
12 Oct 2011, 15:06
I have seen references to object.parent or similar in the tutorial but didn't know how to use in an expression.
Another small piece of the jigsaw clicks into place.
Alex, you are a gentleman!

Alex
12 Oct 2011, 17:10
Glad to be of service :)