overriding global command
Farvardin
08 Jul 2004, 20:41Hello,
I'm trying to do something in my game :
I want to have a global "give" answer message, that can catch the action to give something to someone in particular.
It worked, but later I realized I needed to built a local "give" action for someone. But the global "give" command prevents me to do this :
I wanted something that could tell the local "give" command to override the global one. Is it possible ? I found a way to make my command work locally, but I had to adapt it to the global command, and I prefered to do it in the local command. Why ? This way if I want to give something else to an other character, I don't need to modify the global command. And I can also consider including all my glocal commands to a library I could re-use later for another game...
I'm trying to do something in my game :
I want to have a global "give" answer message, that can catch the action to give something to someone in particular.
It worked, but later I realized I needed to built a local "give" action for someone. But the global "give" command prevents me to do this :
Global command :
command <give #@thing# to #@destinataire#> {
if ( #destinataire# = Livolas ) then {
msg <Livolas thanks you for the #@thing#.>
lose <#@thing#>
hide <#@thing#>
}
else msg <This person doesn't want this item now.>
}
local command, into an object (a cat):
give <sweet> {
say <Rhooooo>
msg <The cat takes your sweet>
lose <sweet>
hide <sweet>
}
I wanted something that could tell the local "give" command to override the global one. Is it possible ? I found a way to make my command work locally, but I had to adapt it to the global command, and I prefered to do it in the local command. Why ? This way if I want to give something else to an other character, I don't need to modify the global command. And I can also consider including all my glocal commands to a library I could re-use later for another game...
command <give #@thing# to #@destinataire#> {
if ( #destinataire# = Livolas ) then {
msg <Livolas thanks you for the #@thing#.>
lose <#@thing#>
hide <#@thing#>
}
else {
if ( #destinataire# = cat ) and ( #@thing# = sweet ) then doaction <cat; give_sweet>
else msg <This person doesn't want this item now.>
}
}
and in the local object
action <give_sweet> do {
say <Rhooooo>
msg <The cat takes your sweet.>
lose <sweet>
hide <sweet>
}
Anonymous
09 Jul 2004, 06:05Hi Favardin
I think you are looking for 'the hard way' to do this! You really only need to code a command for the special case ('Livolas' in your example), and let Quest's built in commands take care of the rest.
However if you override a 'give' you DO need to check your player actually has the item he's trying to give away or you'll find he can give away stuff he hasn't even seen yet. let alone isn't holding! Oops!
I've coded up an example see below:
Notice I've coded the global catch all to only catch 'give' if it relates to Livolas - this is I think what you wanted to do
I also put the 'actions' inside a check that the player actually HAS the thng he's trying to give to Livolas, if he doesn't it just calls a regular Quest give (which says you haven't got that).
Done this way a local give in the 'boss' object isn't caught by the global command - I think this gives the effect you are after ..
Cut n paste this example and then run it - Take the widget (you can't give things you are not holding) and try giving it to either "geezer". You should find that it works as you require.
Hope this helps
Al (MaDbRiT)
I think you are looking for 'the hard way' to do this! You really only need to code a command for the special case ('Livolas' in your example), and let Quest's built in commands take care of the rest.
However if you override a 'give' you DO need to check your player actually has the item he's trying to give away or you'll find he can give away stuff he hasn't even seen yet. let alone isn't holding! Oops!
I've coded up an example see below:
Notice I've coded the global catch all to only catch 'give' if it relates to Livolas - this is I think what you wanted to do

Done this way a local give in the 'boss' object isn't caught by the global command - I think this gives the effect you are after ..
' Quest 3.5 ASL Template
define game <Game Name>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <Your Name>
game copyright <© 2004 ...>
game info <Enter any additional information about this game here.>
start <Start Room>
command <give #@thing# to Livolas> {
if ($locationof(#thing#)$ = inventory) then {
msg <Cheers dude, just what I always wanted!>
lose <#thing#>
hide <#thing#>
}
else exec <#quest.originalcommand#;normal>
}
end define
define room <Start Room>
look <Description Goes Here>
define object <widget>
look <a widget>
take
end define
define object <Livolas>
look <it's Livolas>
displaytype <geezer>
end define
define object <boss>
look <the Boss>
displaytype <geezer>
give <widget> {
msg <Why the hell would I want that - clear off!>
}
end define
end define
define text <intro>
Enter intro text here
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end define
Cut n paste this example and then run it - Take the widget (you can't give things you are not holding) and try giving it to either "geezer". You should find that it works as you require.
Hope this helps
Al (MaDbRiT)
Anonymous
09 Jul 2004, 11:43Thank you very much, it's what I wanted !
I needed to know " else exec <#quest.originalcommand#;normal>"
It's my fault, I should have read it in the manual, I looked in the index for "command" but couldn't find anything relevant. I really should read the manual completely, and it's a while I coded with asl...
thank you again. It's nice you didn't answered with "RTFM"
I needed to know " else exec <#quest.originalcommand#;normal>"
It's my fault, I should have read it in the manual, I looked in the index for "command" but couldn't find anything relevant. I really should read the manual completely, and it's a while I coded with asl...
thank you again. It's nice you didn't answered with "RTFM"
