Knowledgebase
Storm Palace Hosting > Storm Hosting Help Desk > Knowledgebase

Ask a question:


Cool Iptscrae Commands

Solution Here are some elegant commands that implement some basic functions:

Declare global variables:

{ GLOBAL } [ variable1 variable2 variable3 ] FOREACH



Declare global variables and set them to zero:

{ DUP GLOBAL 0 SWAP = } [ variable1 variable2 variable3 ] FOREACH



Set spots to zero:

{ 0 SWAP SETSPOTSTATE } [ <spot1_ID> <spot2_ID> <spotN_ID> ] FOREACH



Declare global spots (spots which can be referenced by a name rather than a number) and set them to state zero:

{ DUP GLOBAL 0 SWAP SETSPOTSTATE } [ spot1_name spot2_name spotN_name ] FOREACH



Execute a script for a number of key words:

{ text =
{ your function here } CHATSTR text SUBSTR IF
} [ "keyword1" "keyword2" "keywordN" ] FOREACH



Say a message at mousepos:

"@" MOUSEPOS SWAP ITOA "," & SWAP ITOA & & "Here is the message." & SAY



Check a variable to see if it is within limits. Replace variable_lower and variable_upper with the value of the limits or set their values prior to using this:

{ "True" LOGMSG } variable DUP variable_lower >= SWAP variable_upper <= AND IF



Check mousepos to see if it is within limits. Replace ylower, yupper, xlower and xupper with the value of the limits or set their values prior to using this:

MOUSEPOS DUP ylower >= SWAP yupper <= AND
SWAP DUP xlower >= SWAP xupper <= AND AND inlimit =



Get a random element in an array. This automatically adjusts to the length of the array:

[ 1 2 3 4 5 ] DUP LENGTH RANDOM GET randomelement =



Cycle spot states between zero and N-1. Used for most animations:

10 N =
ME GETSPOTSTATE 1 + N % ME SETSPOTSTATELOCAL ;cycle up
ME GETSPOTSTATE 1 - N + N % ME SETSPOTSTATELOCAL ;cycle down

10 N =
1 updown = ;1 for up, -1 for down
ME GETSPOTSTATE updown + N + N % ME SETSPOTSTATELOCAL ;cycle up or down

10 N =
ME GETSPOTSTATE 1 + DUP N / N * - ME SETSPOTSTATELOCAL ;another cycle up
ME GETSPOTSTATE DUP NOT N * + 1 - ME SETSPOTSTATELOCAL ;another cycle down



Cycle spot states between 1 and N. Used for an animation that can be turned off as state 0:

10 N =
ME GETSPOTSTATE N % 1 + ME SETSPOTSTATELOCAL ;cycle up
ME GETSPOTSTATE 2 - N + N % 1 + ME SETSPOTSTATELOCAL ;cycle down



Set a variable (truefalse) equal to true (1) or false (0) based on the relationship of two other variables:

othervariable1 othervariable2 == truefalse =
othervariable1 othervariable2 <= truefalse =
(etc.)



Count the number of words in a text string:

"[ " textstring & " ]" & STRTOATOM EXEC LENGTH count =



Get particular portions of a text string. The following example shows how to get the X, Y and text out of a SAYAT:

sayat_string "^([0-9]+),([0-9]+)(.*)$" GREPSTR POP
"$1" GREPSUB ATOI x =
"$2" GREPSUB ATOI y =
"$3" GREPSUB text =



Check to see if someone (by USERID) is still in the room. The following expressions are TRUE if the person is not in the room::

<userID> WHONAME "" == IF

<userID> WHONAME "." GREPSTR NOT IF





And a mundane instruction that is very helpful:

Convert DATETIME on Macs (negative number) to same value as PCs (positive number):

{ DATETIME 2085978496 + } DATETIME 0 < IF
 
Was this article helpful? yes / no
Article details
Article ID: 216
Category: Iptscrae Defined
Date added: 07-11-2011 20:06:19
Views: 457
Rating (Votes): Article not rated yet (0)

 
<< Go back

Powered by Help Desk Software HESK™