prev | toc | next
 

2.1.3 Data Types and Setting Properties

In the vast majority of cases, props can be correctly set by players and wizards with the @set command, as described above. However, in rare cases the `data type' of a property needs special handling, and a different command is needed: @propset.

Data handled by the MUCK server is `typed', as it is in many computer languages, including C (the language the server program is written in) and MUF (one of the two programming languages available on MUCKs). The server handles different types of data, and most operations require a specific type of data. In this context, the relevant types are `string', `dbref', `integer', and `float'. (There is also a fifth data type: `lock', which is discussed in Section 2.3. Type `float' is only available on MUCK versions 6.0 or higher.)

A string is a series of zero or more characters (a zero-length string is called a `null string'). A dbref is a database reference number. An integer is a whole number. A float is a floating point decimal number. These values can look the same but have different types. The type of a datum is determined when it is stored. The string of numeral characters "123", the #dbref 123, and the integer 123, and the float 123.0 are four different values.

The @set command always stores property data as a string. The following three commands store information in three different properties, but it's the same value in each case: a string composed of the characters `1', `2', and `3'.

====================================
> @set me = my_favorite_dbref:123
  Propery set.
> @set me = my_favorite_integer:123
  Property set.
> @set me = my_favorite_string:123
  Property set.
====================================

If you typed these commands, and then did ex me = /, you would see the three properties, each prefaced by str, meaning `this data is stored as a string'.

====================================
> ex me = /
  str /my_favorite_dbref:123
  str /my_favorite_integer:123
  str /my_favorite_string:123
====================================

Programs and commands often store data as dbrefs or integers rather than strings; occasionally, players will want or need to do so as well. The command for doing this is @propset, syntax @propset <object> = <data type> : <[path/]property> : <value>. The following three commands store information in three different properties, and although they look similar, it's a different value in each case: a dbref, an integer, and a string respectively.

====================================
> @propset me = dbref:my_favorite_dbref:#123
  Property set.
> @propset me = int:my_favorite_integer:123
  Property set.
> @propset me = str:my_favorite_string:123
  Property set.
====================================

(Type `float' has been omitted from this example: at the time of this writing, @propset does not handle floating point numbers.)

If you typed these commands, and then did ex me = /, you would see the three properties, prefaced by ref, int, and str respectively, with each preface showing the type of the data stored in the property.

====================================
> ex me = /
  ref /my_favorite_dbref:Hortense(#123PBJ)
  int /my_favorite_integer:123
  str /my_favorite_string:123
====================================

Tip: there is also a server shortcut for setting properties with values of type integer: put a ^ carot before the number.

====================================
> @set me = lucky_number:^5
  Property set.
> ex me = lucky_number
  int /lucky_number:5
====================================

prev | toc | top | next