user command and build-in command. What if there is none ?

Farvardin
29 Jul 2004, 22:55
A few days ago I asked about how to override a global command (made by me).
MaDbRiT kindly suggested to use the " exec <#quest.originalcommand#;normal> "
command. In the example it was for "give", which has a built in command. But the problem is many verbs don't have any built in command, so this code return an error ("I don't understand your command"...)

Is there an easy way to :

-> define a global behavior / command
ex :
command <read #@thing#> msg <There is nothing written on #quest.error.gender# #thing#.>

-> define a local command (inside a room / concerning an object)

define object <bed>
read <There is something engraved on it : "...etc.".>
end define

-> if the player uses the command for something relevant then it will execute the local command, if not, there will be the global command instead.

Alex
29 Jul 2004, 23:28
You can just set the command up in that room. Quest looks for command definitions in the current room first, so if you have one set up there then it will override an equivalent one defined for the game.

So you could set up an "eat" command in the define game block (or Game Properties window) which just said "You can't eat that".

Then in a room with an apple you could set up an "eat" command there to eat the apple. When the player is in this room, this form of the command will be executed instead of the global command.

Anonymous
30 Jul 2004, 10:22
ok...

so it will need more coding if I want to have a command related to an object (NPC for ex.) that can move from one place to an other one...

Alex
30 Jul 2004, 17:00
There are several other ways you could do it. You could just have your global command check for that object, e.g.

command <read #@thing#> if (#thing#=book) then ... else msg <You can't read that>

or use properties or actions e.g.

command <read #@thing#> if action <#thing#; read> doaction <#thing#; read> else msg <You can't read that.>

and then in your "book", "magazine" etc. definitions use

action <read> msg < ...... >

Farvardin
31 Jul 2004, 08:02
It's working as expected now, thank you very much for explaining it to me. This way I could continue writing my library.

btw, the correct command should be :

command <read #@thing#> if action <#thing#; read> then doaction <#thing#; read> else msg <You can't read that.>


(the 'then' was missing)