Building: Actions
Actions
Actions are special commands defined in %action_whatever
magic objects and stored on disk in their own files. You can stat these objects (eg. stat %action_stab
) too see the attributes that define them, and edit them using standard editting commands like chstr
or using webmake.
To create a new, empty action, use createaction whatever
, where "whatever" is the name of your new action. This will create a new action object with no action definitions and saves it to disk.
Action Types
An action has one or more supported types:
Type | Usage | Example |
---|---|---|
untargetted | Used without any arguments | smile |
targetted | Used with a single argument which must be a player or mobile | hug muon |
object targetted | Used with a single argument which must be a concrete, inanimate object | hide sofa |
prop | Used with two arguments and a prepostion | point stick at ffilc |
text | Used with a text argument that may be of any length | mutter whatever |
targetted text | Used with a specially indicated person and a text argument of any length | sing gareth> hush, nobber |
Action strings
Each action type is associated with one or more strings.
(base) | For simple actions, you can use one string to be shown to the actor, the audience and the target (if any) | %1 smile%[s] at %a. |
self | A string shown to the actor | You think you are tutting... |
target | A string shown only to the target of targetted and prop actions | %#a nod%<s> and smile%<s> at you. They must be absolutely fascinated! |
others | A string show to anyone who can see the actor | %#a order's a straitjacket for %[a]. |
preposition | For prop targetted actions, the preposition that must be used | with |
error | For text and targetted text actions, the string shown when arguments are missing | Sing what? |
If the base attribute is used (eg. action.targetted
) it will be used for all required action strings (eg. self, target and others). Specific attributes (eg. self) can be used to override this behaviour.
To make an action actually do something, first you need to set some strings on it:
Attribute | Purpose |
---|---|
action.untargetted | Defines an untargetted action |
action.untargetted.self | |
action.untargetted.others | |
action.targetted | Defines an action targetted at a person |
action.targetted.self | |
action.targetted.target | |
action.targetted.others | |
action.object_targetted | Defines an action targetted at an object |
action.object_targetted.self | |
action.object_targetted.others | |
action.prop_targetted | Defines an action targetted at a person, using a prop object |
action.prop_targetted.self | |
action.prop_targetted.target | |
action.prop_targetted.others | |
action.text | Defines a text action |
action.text.self | |
action.text.others | |
action.text.error | The error message displayed when using a text action without supplying any text |
action.alias | An alternative name for the action which the mud's parser will accept |
action.minlen | The shortest abbreviation of the action name that the mud will accept |
action.commline_safe | If this action is used on a commline, ignore any lua and just use the plain action strings |
Lua action gotchas:
- Lua actions which do not return strings, but instead do their own output, do not interact nicely with other action systems. They will not trigger action-related traps, for example.
- Action triggered traps (before_act_in, mounted_act, before_act_held) are all triggered after lua action handling, and in order. The first action trap to return 1 "wins", and no further action traps will be fired (eg, action traps on a mount will prevent action traps on held items from firing.)
- Lua actions which deal with their own messaging instead of returning strings must have
action.commline_safe
set to0
. If you don't, they will work in very strange ways when used over a commline.
Special Actions
If you set use.sleeping to 1 on an action object, people will be able to use it even when asleep. Obviously this isn't appropriate for most actions, but stuff like snore has it.
If you set use.the_voices to 1, if you use that action inside another player, they'll get special messaging that tells them that a voice inside their head is performing that action. Again, this doesn't make sense for all actions... anything with a somatic component (eg, pointing, hugging) woudl look silly. Vocal components only (such as laughter, or singing).
Action Contexts
If you want to let a normal verb be used like an action on a commline, you can make an action magicobject with the same name (eg. to give the push verb an action context, create the action magicobject %action_push. Set the action.override property on the new magicobject to stop it being turnged into a full action (because this will interfere with the real command). The command can then be fed to the actions command, or used after a # on a commline, and will show the action you've just defined. None of the normal verb logic will be triggered.
Currently, you can't use createaction to create override action objects... you must create the action file on disk first. This will be rectified in due course.
If you want to let a lua verb be used on a commline like an action, this is much easier. Just set action.* properties on it as if it were a normal action object, and everything else will just work.