SPECIAL VARIABLES: Difference between revisions

From AddictHelp
Jump to navigation Jump to search
Kahlan (talk | contribs)
No edit summary
No edit summary
Line 2: Line 2:


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.
Line 22: Line 22:
       %somestring.contains(searchstring)%
       %somestring.contains(searchstring)%


3.  If you want to make sure there are no blank spaces at the front or end  
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:
    of the string, you can remove them by doing:
       set newstring %somestring.trim%
       set newstring %somestring.trim%


4.  If you want to know if a string is the abbreviation of another string  
4.  If you want to know if a string is the abbreviation of another string you can check by doing:
    you can check by doing:
       if (%somestring.isabbrev(north)%)
       if (%somestring.isabbrev(north)%)
         ...
         ...
       end
       end


5.  If you need just the first word in a sentence, you can retrieve it by  
5.  If you need just the first word in a sentence, you can retrieve it by doing:
    doing:
       set oneword %somestring.car%
       set oneword %somestring.car%



Revision as of 15:40, 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%