Still fuzzy on types
MerryCo
28 Aug 2007, 15:35I can take the following type
and assign that type to an object, say a couch. Now, is there any way to have a player type "sit on couch" and have it automatically come back with You sit on the couch without having to have a command <sit #@couch#> doaction <#couch#; sit>?
It would seem to me that assigning a type containing an action to an object would make this happen automagically.
define type <sittable>
action <sit> msg <You sit on $thisobjectname$.>
end defineand assign that type to an object, say a couch. Now, is there any way to have a player type "sit on couch" and have it automatically come back with You sit on the couch without having to have a command <sit #@couch#> doaction <#couch#; sit>?
It would seem to me that assigning a type containing an action to an object would make this happen automagically.
Cryophile
28 Aug 2007, 15:37An action is not a custom command. You can have the action run with a custom command, but there isn't a way around this as far as I can tell. Sorry for the lack of detail, but I'm at work.
paul_one
28 Aug 2007, 16:16You may put a verb together, which is basically put in the define game block;
This will either print out the property value sit if one exists, or do the action if one exists.. If neither property or action exist, then the script afterwards (in this case a message) is executed.
Quite useful, but I found a generalised command much nicer.
http://www.axeuk.com/phpBB2/viewtopic.php?t=1682
Here all defaults are in one place (which can be put into a procedure if you so wish), and it even handles commands which you might not want a default message to - but that you can add to any random object (like a command 'wizzywozzle' can be added to a 'fiddlywud' object without the need to mention it anywhere else other than the object - although it's not advisable to do so unless the player is likely to know how to 'wizzywoddle the fiddlywud').
EDIT
Updated the code now to reflect the advice below.
verb <sit on; sit : sit> msg <Damn!>This will either print out the property value sit if one exists, or do the action if one exists.. If neither property or action exist, then the script afterwards (in this case a message) is executed.
Quite useful, but I found a generalised command much nicer.
http://www.axeuk.com/phpBB2/viewtopic.php?t=1682
command <#t.command# #@object# with #@something#;_
#t.command# #@object# using #@something#;_
#t.command# #@object# on with #@something#;_
#t.command# #@object# on #@something#;_
#t.command# #@object# at #@something#;_
#t.command# #@object# into #@something#;_
#t.command# #@object# in #@something#;_
#t.command# on #@object# with #@something#;_
#t.command# on #@object#;_
#t.command# onto #@object#;_
#t.command# over #@object#;_
#t.command# up #@object#;_
#t.command# off #@object# with #@something#;_
#t.command# off #@object#;_
#t.command# #@object# on;_
#t.command# #@object# off with #@something#;_
#t.command# #@object# off;_
#t.command# #@object#> _
select case <#t.command#> {
case <break; smash; crush; climb; drink; sip; quaff; _
swig; eat; nibble; munch; scoff; consume; _
hit; jump; leap; kick; kill; murder; kiss; _
smooch; punch; pinch; sit; throw; turn> {
if action < #object#; #t.command# > then _
doaction <#object#; #t.command#> _
elseif property < #object#; #t.command# > then _
msg <$objectproperty(#object#;#t.command#)$> _
else _
select case <#t.command#> {
case <break; smash; crush> _
msg <You figure that breaking the #(quest.lastobject):alias# isn't the right thing to do.>
case <climb> _
msg <You can't climb the #(quest.lastobject):alias#>
case <drink; sip; quaff; swig> _
msg <You can't drink that.>
case <eat; nibble; munch; scoff; consume> _
msg <You don't want to eat that.>
case <hit; attack; hurt> {
msg <You decide hitting |xn>
if ( #(quest.lastobject):gender# = ! ) then _
msg <it |xn> _
else _
msg <#(quest.lastobject):gender# |xn>
msg <would be a bad choice.>
}
case <jump; leap> _
msg <You can't jump that!>
case <kick> _
msg <You don't have the courage to kick the #(quest.lastobject):alias#..>
case <kill; murder> _
if ( #(object):gender# = him ) or ( #(object):gender# = her ) then _
msg <You decide that killing #(object):gender# is the wrong thing to do..> _
else _
msg <Can you actually kill #(object):prefix# #(object):alias#!?>
case <kiss; smooch> _
msg <You stare, your eyes misted over as you play the kiss over in your mind..>
case <punch> _
msg <You imagine your fist flying through the air, and then reality snaps back into place..>
case <pinch> _
msg <You sqeeze your fingers together, but decide you look silly and immediately stop.>
case <sit> {
msg <You'd rather not sit on |xn>
if ( #(quest.lastobject):gender# = ! ) then _
msg <it.> _
else _
msg <#(quest.lastobject):gender#.>
}
case <throw> _
msg <You position yourself carefully, but then decide you'd rather not..>
case <turn> {
msg <You try to find a way to turn the #(quest.lastobject):alias#|xn>
if ( $instr(#quest.command#;_on)$ > 0 ) then _
msg < on|xn> _
elseif ( $instr(#quest.command#;_off)$ > 0 ) then _
msg < off|xn>
msg <, but can't quite figure out how you could.>
}
}
}
case else _
exec <#t.command# #object#;normal>
}Here all defaults are in one place (which can be put into a procedure if you so wish), and it even handles commands which you might not want a default message to - but that you can add to any random object (like a command 'wizzywozzle' can be added to a 'fiddlywud' object without the need to mention it anywhere else other than the object - although it's not advisable to do so unless the player is likely to know how to 'wizzywoddle the fiddlywud').
EDIT
Updated the code now to reflect the advice below.
MerryCo
28 Aug 2007, 19:18Here all defaults are in one place (which can be put into a procedure if you so wish), and it even handles commands which you might not want a default message to - but that you can add to any random object (like a command 'wizzywozzle' can be added to a 'fiddlywud' object without the need to mention it anywhere else other than the object - although it's not advisable to do so unless the player is likely to know how to 'wizzywoddle the fiddlywud').
Great stuff! Thanks for that!
Freak
29 Aug 2007, 17:29I'm not so impressed with that setup:
1) A verb which is only understood with one object is generally a really bad idea; if I try "wizzywozzle macguffin" and get a "not understood" response, I'm not going to try "wizzywozzling" anything else without real good reason.
2) There's a definite hole in the implementation; there's no check that the property is supposed to be an action property, so if the player can guess the internal name of a property, he can learn its value. (Workaround: put a space in the middle of the name of any non-action property.)
It also appears to be vulnerable to function-name injection, but I don't think you can avoid that in Quest.
1) A verb which is only understood with one object is generally a really bad idea; if I try "wizzywozzle macguffin" and get a "not understood" response, I'm not going to try "wizzywozzling" anything else without real good reason.
2) There's a definite hole in the implementation; there's no check that the property is supposed to be an action property, so if the player can guess the internal name of a property, he can learn its value. (Workaround: put a space in the middle of the name of any non-action property.)
It also appears to be vulnerable to function-name injection, but I don't think you can avoid that in Quest.
paul_one
29 Aug 2007, 17:50Yeah,
I really did it because I found that I was creating several commands and verbs all the same.
I hate repeating the same stuff over again when it's just easy to have it all in one place.
Yes, a player guessing a property "hotness" is fine - but you can also edit the ASL and turn debugging on.
If you're compiling then you're a bit better off - but if you put simple properties like "jump" then I'd say you would be a bit weird.
(expecting a command like "hotness jug" to return anything sensible is a bit far.. I suggest putting underlines in your properties - and perhaps using the instr() function to check for underlines in the command - or dots.)
And Freak, you are also right that the one action - wizzywozzling - for an object is fairly silly... But what about "throw", surely if you use it once then it's still a fairly common action. Same sith jump over, or kill, or destroy, etc. You may only use it once or twice, and there may be more then one action, jump, scratch, smash, wear, chew, tear, burn. Each of these would require setting up a verb or action only for using them once or twice.
I simply find my way of creating a generalized and central repository for alot of functionality quite nice.
- I get what you mean though, about getting a response where they cannot do an action (you don't know how to 'throw the cup'. .. you throw the can across the road...).
It was born purely from me trying to get verbs working how I wanted them to work, and not out of some need to have objects randomly show abilities to do actions without prior knowledge (which is why I'm adding into the list of commands, and will soo begin creating object types with actions).
I really did it because I found that I was creating several commands and verbs all the same.
I hate repeating the same stuff over again when it's just easy to have it all in one place.
Yes, a player guessing a property "hotness" is fine - but you can also edit the ASL and turn debugging on.
If you're compiling then you're a bit better off - but if you put simple properties like "jump" then I'd say you would be a bit weird.
(expecting a command like "hotness jug" to return anything sensible is a bit far.. I suggest putting underlines in your properties - and perhaps using the instr() function to check for underlines in the command - or dots.)
And Freak, you are also right that the one action - wizzywozzling - for an object is fairly silly... But what about "throw", surely if you use it once then it's still a fairly common action. Same sith jump over, or kill, or destroy, etc. You may only use it once or twice, and there may be more then one action, jump, scratch, smash, wear, chew, tear, burn. Each of these would require setting up a verb or action only for using them once or twice.
I simply find my way of creating a generalized and central repository for alot of functionality quite nice.
- I get what you mean though, about getting a response where they cannot do an action (you don't know how to 'throw the cup'. .. you throw the can across the road...).
It was born purely from me trying to get verbs working how I wanted them to work, and not out of some need to have objects randomly show abilities to do actions without prior knowledge (which is why I'm adding into the list of commands, and will soo begin creating object types with actions).
Freak
29 Aug 2007, 19:30I'm referring to things like a player seeing a safe, and trying "combination safe"
paul_one
29 Aug 2007, 23:40True, but if the player goes to that trouble to figure out the way your game works, he might as well have seen the combination in the raw code, or have actually read the writing on the wall which gives him the safe combination..
Hey - I'd expect to use a simple "unlock safe" to work if I've already seen the code somewhere, and not to have to type in the code itself... But perhaps that's just me.
I suppose you could simply put it into a select case statement, where all the known commands are executed while the unknown commands are simply exec-normal'd... But again, that's duplication of a whole list.
I will do this none-the-less, as it's both a good idea and more rigid.. My main aim was to add functionality and get this part working, rather then pin down that loose end (yes, I was aware to this prior to posting it).
Hey - I'd expect to use a simple "unlock safe" to work if I've already seen the code somewhere, and not to have to type in the code itself... But perhaps that's just me.
I suppose you could simply put it into a select case statement, where all the known commands are executed while the unknown commands are simply exec-normal'd... But again, that's duplication of a whole list.
I will do this none-the-less, as it's both a good idea and more rigid.. My main aim was to add functionality and get this part working, rather then pin down that loose end (yes, I was aware to this prior to posting it).
paul_one
30 Aug 2007, 16:49I've changed the code above so that only specific cases of #t.command# are run.