SPECIAL VARIABLES: Difference between revisions

From AddictHelp
Jump to navigation Jump to search
No edit summary
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. For example,  
  random - This variable returns a number between 1 and the field value.
          '''%random.10%''' would be a value between 1 and 10. Also, for random, there is an  
        For example, %random.10% would be a value between 1 and 10.
          option for %random.char% that will return a random character in the room the  
        Also, for random, there is an option for %random.char% that will
          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 specify.   
  people - this variable returns a random person in a room vnum that you
          i.e. '''%people.3001%''' will return a random person sitting in room 3001.
        specify.  i.e. %people.3001% will return a random person sitting
dice  - performs a "dice roll", i.e. if you want 5 rolls of a 6 sided die, you would
        in room 3001.
          put: '''%dice.5d6%'''


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

Latest revision as of 03:11, 4 December 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.
dice   - performs a "dice roll", i.e. if you want 5 rolls of a 6 sided die, you would 
         put: %dice.5d6%

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%