SPECIAL VARIABLES: Difference between revisions

From AddictHelp
Jump to navigation Jump to search
Kahlan (talk | contribs)
New page: For details on how to use variables, please see the schelp for VARIABLES. Special variables are as follows: ================================= self - the mob, item, or room running the scr...
 
Kahlan (talk | contribs)
No edit summary
Line 3: Line 3:
Special variables are as follows:
Special variables are as follows:
=================================
=================================
self - the mob, item, or room running the script.  Normal fields may also
self - the mob, item, or room running the script.  Normal fields may also
      be used.
        be used.
random - This variable returns a number between 1 and the field value.
random - This variable returns a number between 1 and the field value.
      For example, %random.10% would be a value between 1 and 10.
        For example, %random.10% would be a value between 1 and 10.
      Also, for random, there is an option for %random.char% that will
        Also, for random, there is an option for %random.char% that will
      return a random character in the room the script is being run in.
        return a random character in the room the script is being run in.
people - this variable returns a random person in a room vnum that you
people - this variable returns a random person in a room vnum that you
      specify.  i.e. %people.3001% will return a random person sitting
        specify.  i.e. %people.3001% will return a random person sitting
      in room 3001.
        in room 3001.


Special Notes on any variable that is a string (not a number).  They have 6
Special Notes on any variable that is a string (not a number).  They have 6

Revision as of 10:56, 20 November 2008

For details on how to use variables, please see the schelp for VARIABLES.

Special variables are as follows:

=====================
self - the mob, item, or room running the script.  Normal fields may also
       be used.
random - This variable returns a number between 1 and the field value.
       For example, %random.10% would be a value between 1 and 10.
       Also, for random, there is an option for %random.char% that will
       return a random character in the room the script is being run in.
people - this variable returns a random person in a room vnum that you
       specify.  i.e. %people.3001% will return a random person sitting
       in room 3001.

Special Notes on any variable that is a string (not a number). They have 6 special abilities to allow you to efficiently handle strings.

1. First, you can retrieve the length of a string by using:

      %somestring.strlen%

2. You can see if a string contains another string by doing:

      %somestring.contains(searchstring)%

3. If you want to make sure there are no blank spaces at the front or end

   of the string, you can remove them by doing:
      set newstring %somestring.trim%

4. If you want to know if a string is the abbreviation of another string

   you can check by doing:
      if (%somestring.isabbrev(north)%)
        ...
      end

5. If you need just the first word in a sentence, you can retrieve it by

   doing:
      set oneword %somestring.car%

6. And finally, to get a string, without the first word, you would do:

      set setstring %somestring.cdr%