This page explains how to set and modify the attributes and variables of a view.
(To show all known views, see the /sms list command)
All views have a predefined set of attributes which control some functionality of the view. The actual attributes supported depend on the view type - see View Types for documentation on each specific type. The following attributes are common to all views:
|access||Access control for the view, one of ANY, OWNER or GROUP (see Access Control)||ANY|
|item_justify||The item justification for this view - one of left, center, right or default. If set to default, the item_justify Configuration setting will be used.||default|
|owner||The name of the owning player.||Name of player who created the view, or [console] if created on the console.|
|title_justify||The title justification for this view - one of left, center, right or default. If set to default, the title_justify Configuration setting will be used.||default|
Inspecting View Attributes
To see the value of an attribute:
/sms view mymenu-1 owner mymenu-1.owner = desht
Modifying View Attributes
To change the value of an attribute:
/sms view mymenu-1 owner desht mymenu-1.owner = desht
To clear the value:
/sms view mymenu-1 owner ""
(however, note that empty owners are not allowed, so you will see an error from the above command)
View variables are new in v1.4.0. They are basically arbitrary data/value tags which can be attached to any view, and are stored per-view; each view has its own set of independent view variables.
Managing view variables is very much like managing attributes, but view variable names must start with a '$' sign. In addition the variable name must be all alphanumeric, containing only a-z, A-Z, 0-9 and _ (underscore) characters.
Reading, Setting & Deleting View Variables
Set the view variable '$varname' to 'value' on view mymenu-1:
/sms view mymenu-1 $varname value
Check the value of '$varname' on view mymenu-1:
/sms view mymenu-1 $varname
Delete the view variable '$varname' on view mymenu-1:
/sms view mymenu-1 -d $varname
Using View Variables
There are two useful ways to use view variables:
- In the title and menu item labels of the menu that owns the view
- As a substitution in command executed from the view
The syntax for both of the above is
<$v:cost=0>. Note that a default must be specified, in the case the variable doesn't exist in the view.
This is probably best explained a practical example - this uses command costs (see Command Parser) and a hypothetical /buyplot command which allows the player to buy the plot he's standing on for a certain sum of money:
/sms create buyplot "&1Cost: $<$v:cost=100>" /sms add buyplot "Buy Plot" "$E,<$v:cost=100> /buyplot" ...add three sign views on three different plots... /sms view buyplot-1 $cost 1000 /sms view buyplot-2 $cost 500 (not setting a $cost on buyplot-3)
Now the first plot will cost 1000, the second will cost 500, and the third will cost the default 100. A single menu entry allows the command to be run in three different ways, and you can easily add other views with their own cost!