Knowledgebase
Storm Palace Hosting > Storm Hosting Help Desk > Knowledgebase

Ask a question:


Updated Iptscrae Extentions

Solution Extended Iptscrae Scripting - PalaceChat

Extended Iptscrae Scripting

From PalaceChat

Jump to: navigation, search

This page documents all the new Iptscrae commands and events that are supported by PalaceChat. This documentation assumes you already have a general knowledge of the Iptscrae scripting language. If you do not already have a general understanding of the Iptscrae scripting language it is recommended you read through the original Iptscrae Scripting Manual

Contents

[] New Events

[] ON COLORCHANGE

This event will fire when a user changes their color. The special variable WHOCHANGE contains the users ID.

[] ON FACECHANGE

This event will fire when a user changes their face. The special variable WHOCHANGE contains the users ID.

[] ON FRAMECHANGE

This event will fire every time the frame changes for a animated gif that is in the current spot state. The special variable FRAME contains the index number.

[] ON HTTPERROR

This event will fire when a download error occurs after a HTTPGET command is issued. The special variable ERRORMSG contains the error message.

[] ON HTTPRECIEVED

This event will fire when a HTTPGET download has completed. Exclusive variables HEADERS, CONTENTS, FILENAME and TYPE are available for this event. HEADERS is the http recieved headers as a Hash element. FILENAME is the name of the file recieved. TYPE is the Content-Type recieved. CONTENTS is a Atomlist if TYPE = "text/iptscrae" but will be a string for all other content-type's.

Some received content types will be processed internally right after this event occurs. Types being iptscrae,images, and html. To prevent this from occurring you can set CONTENTS to ""

[] ON KEYDOWN

This event will fire when the user presses a key on the keyboard (other then a macro key and other then a face/color change key). This event will only fire when the enviornment is in focus and will NOT fire when typing into the chatfield. Special variable KEYSTR contains the key that was pressed. Setting KEYSTR to "" will hault the chatfield from gaining focus like it normally would when the user types into the enviornment.

[] ON KEYUP

This event will fire when the user releases a key on the keyboard (other then a macro key and other then a face/color change key). This event will only fire when the enviornment is in focus and will NOT fire when typing into the chatfield. Special variable KEYSTR contains the key that was pressed.

[] ON IDLE

This event will be fired when the user is idle for 10 minutes.

[] ON MOUSEDRAG

This event will fire continuously as the user clicks and drags on a hotspot.

[] ON MOUSEDOWN

This is the exact same as the ON SELECT event.

[] ON MOUSEMOVE

This event will be fired continuously as the user moves the mouse cursor over the hotspot's area.

[] ON MOUSEUP

This event will fire when a user clicks a hotspot after releasing their mouse button, if the mouse is still over the hotspot when the button is released.

[] ON NAMECHANGE

This event will fire when any user changes their username. Variable WHOCHANGE contains the ID of the user who has changed there name, and variable LASTNAME contains the name they had previous to the change.

Example:

ON NAMECHANGE {
LASTNAME " has changed his/her username to " & WHOCHANGE WHONAME & LOGMSG
}

[] ON ROLLOVER

This event will be fired when the user's mouse cursor enters the hotspot's area.

Example:

ON ROLLOVER {
    1 ME SETSPOTSTATELOCAL ; Make button glow
}

[] ON ROLLOUT

This event will be fired when the user's mouse cursor leaves the hotspot's area.

Example:

ON ROLLOUT {
    0 ME SETSPOTSTATELOCAL ; Make button return to normal
}

[] ON ROOMLOAD

This event will fire right before the room is rendered. It is useful for making local changes to whats displayed in the room in a seemless way.

[] ON ROOMREADY

IMPORTANT: This event is not yet implemented.

This event will be fired once all the images for the current room have been downloaded and processed. Any usage of the new ROOMWIDTH and ROOMHEIGHT commands should be in this event handler, as the actual room size is unknown until the background image has been processed.

Example:

ON ROOMREADY {
    "The room graphics have finished downloading." LOGMSG
    "This room is sized: " 
        ROOMWIDTH ITOA & "x" &
        ROOMHEIGHT ITOA & "." & LOGMSG
}


[] ON SERVERMSG

All messages except user chat and local messages will fire this event. Variable CHATSTR contains the message.

Example:

ON SERVERMSG {
CHATSTR LOGMSG
}


[] ON STATECHANGE

This event will fire when a doors state is changed.

Example:

ON STATECHANGE {
ME GETSPOTSTATE newState =
"New state is: " newState ITOA & LOGMSG
"Previous state was: " LASTSTATE ITOA & LOGMSG
}

[] ON USERENTER

This event will fire when any user enters the room. Variable WHOENTER contains the ID of the user who has entered.

Example:

ON USERENTER {
"Hello " WHOENTER WHONAME & SAY
}

[] ON USERLEAVE

This event will fire when any user leaves the room. Variable WHOLEAVE contains the ID of the user who has left.

Example:

ON USERLEAVE {
"Hello " WHOLEAVE WHONAME & SAY
}

[] ON USERMOVE

This event will fire when any user moves. Variable WHOMOVE contains the ID of the user who has moved.

Example:

ON USERMOVE {
WHOMOVE WHOPOS y = x =
x ITOA " " & y ITOA & LOGMSG
}

[] ON WEBSTATUS

This event will fire in the door of a WEBEMBED when its status changes Special variable NEWSTATUS contains the new status string.

[] ON WEBTITLE

This event will fire in the door of a WEBEMBED when its title changes Special variable NEWTITLE contains the new title string.

[] ON WEBDOCBEGIN

This event will fire in the door of a WEBEMBED when a document is beginning to download. Special variable DOCURL contains the url string.

[] ON WEBDOCDONE

This event will fire in the door of a WEBEMBED when a document is finished downloading. Special variable DOCURL contains the url string.

Example:

ON WEBDOCDONE {
{
"The web page has finished loading!" LOGMSG
} ME WEBLOCATION DOCURL == IF
}

[] New Commands

[] General Utility

[] ADDHEADER

Add a custom header for the HTTPGET command.

  • Parameters:
    • headerName: The name of the header you wish to add.
    • headerValue: The value of the header you wish to add.

Example:

"name" USERNAME ADDHEADER

[] ALERTBOX

This command will open a popup box with a custom message.

  • Parameters:
    • message: The message to be displayed in the popup box.

Example:

"Hello world!" ALERTBOX

[] BITAND

Performs a bitwise And comparison of two numbers.

  • Parameters:
    • value1: the first number.
    • value2: the second number.

Example:

{"True story bro." SAY} 1 1 BITAND IF

[] BITOR

Performs a bitwise Or comparison of two numbers.

  • Parameters:
    • value1: the first number.
    • value2: the second number.

[] BITSHIFTLEFT

Performs a bitwise ShiftLeft operation on a number (shifting the bits by the amount specified).

  • Parameters:
    • aNumber: The value to be shifted.
    • shiftAmount: The amount to shift left by.

[] BITSHIFTRIGHT

Performs a bitwise ShiftRight operation on a number (shifting the bits by the amount specified).

  • Parameters:
    • aNumber: The value to be shifted.
    • shiftAmount: The amount to shift right by.

[] BITXOR

Performs a bitwise Xor operation of two numbers.

  • Parameters:
    • value1: the first number.
    • value2: the second number.

[] CHARTONUM

Returns as an number, the ASCII value for a character.

  • Parameters:
    • character: A string character.

Example:

;now ipt knows its abc's in numeric form!
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" abc =
abc STRLEN len =
{ abc i 1 SUBSTRING CHARTONUM ITOA logmsg i++}{len i >} WHILE

[] CLEARTOOLTIP

This command will close the tooltip set by the SETTOOLTIP command.

[] CONFIRMBOX

This command will open a popup box with a custom message and OK and Cancel button and return the result.

  • Parameters:
    • message: The message to be displayed in the popup box.

Example:

{"I pressed OK" SAY}
{"I pressed Cancel" SAY} "Do you want to continue?" CONFIRMBOX IFELSE

[] ENCODEURL

Useful for converting a string into a HTTP url safe encoding.

  • Parameters:
    • urlComponent: A string to be converted.

Example:

USERNAME ENCODEURL SAY

[] DECODEURL

Useful for converting a string from a HTTP url safe encoding.

  • Parameters:
    • urlComponent: A string to be converted.

Example:

"This%20is%20a%20test%21" DECODEURL SAY

[] HASHTOJSON

Converts a Hash element into a JSON string.

  • Parameters:
    • hashElement: The hash element to be converted into a json string.

Example:

NEWHASH myhash =
"foo" myhash "bar" PUT
myhash HASHTOJSON LOGMSG

[] HTTPGET

This command will download the passed url via HTTP protocol. If the recieved Content-Type is text/iptscrae or text/plain the downloaded contents will be executed as iptscrae (currently the only valid text encoding is utf-8). If the recieved Content-Type is text/html it will be rendered in a popup window. If the recieved Content-Type is image/* (meaning any image format) it will save (and reload that image if its filename is present in the room). The filename can be set by using the Content-Disposition header (ie. Content-Disposition: inline; filename="test.png"). If the HTTPGET command was executed via the Cyborg the image recieved will be imported as an Prop. The headers that are sent from the client are: Accept-Charset, Accept-Language, Accept-Encoding, User-Agent, Origin, Userkey, Referer

  • Parameters:
    • url: The request url.

Example:

"http://pchat.org/api/headers.php" HTTPGET

[] HTTPCANCEL

Used to cancel all HTTPGET requests. When executed in a cyborg script it will only cancel cyborg generated requests. When executed in a room script it will only cancel room generated requests.

Example:

ON LEAVE { HTTPCANCEL }

[] JSONTOHASH

Parses and converts a JSON string into a Hash element. You can then use the GET or PUT commands to read or write to the Hash storage. JSON is widely used across the web as a popular data feed format, in combination with HTTPGET iptscrae is now more powerful then ever.

  • Parameters:
    • jsonString: The JSON string to be parsed and converted into a hash element.

Example:

"{\"foo\":\"bar\"}" JSONTOHASH myhash =
myhash "foo" GET SAY

[] LOADWEBSITE

This command will load the website of the url passed in a popup window.

  • Parameters:
    • url: The website address to load in the popup.

Example:

"http://pchat.org" LOADWEBSITE

[] IPTVERSION

This command now returns 2 for both PalaceChat and OpenPalace.

Example:

{ "I'm using the latest version of iptscrae!" SAY } IPTVERSION 2 == IF

[] OPENPALACE

Pushes a 1 onto the stack if the user is using OpenPalace. On non-OpenPalace clients, it will be interpreted as an uninitialized variable, and will evaluate to 0 (zero.) You can use this function to detect OpenPalace and provide customized scripting for OpenPalace users.

Example:

{ "I'm using OpenPalace!" SAY }
{ "I'm not using OpenPalace!  :-(" SAY }
OPENPALACE IFELSE

[] PALACECHAT

Pushes the version number of the PalaceChat client onto the stack if the user is using PalaceChat. On non-PalaceChat clients, it will be interpreted as an uninitialized variable, and will evaluate to 0 (zero.) You can use this function to detect PalaceChat and provide customized scripting for PalaceChat users.

Example:

{ "I'm using PalaceChat!" SAY }
{ "I'm not using PalaceChat!  :-(" SAY }
PALACECHAT IFELSE

[] NBRSERVERUSERS

Pushes the number of users on the server onto the stack.

Example:

NBRSERVERUSERS ITOA SAY

[] NEWHASH

Creates a new blank hash element.

Example:

NEWHASH myhash =
NBRROOMUSERS ARRAY ary =
{i ROOMUSER WHONAME ary i PUT i++} ary FOREACH
ROOMNAME myhash "roomname" PUT
ary myhash "roomusers" PUT
myhash HASHTOJSON LOGMSG

[] NUMTOCHAR

Returns the character whose ASCII value is passed.

  • Parameters:
    • codePoint: The numeric value of the character.

Example:

;now ipt knows its abc's?
65 i =
{ i NUMTOCHAR logmsg i++}{91 i >} WHILE

[] REGEXP

This works just like the command GREPSTR except that it's patterns are not specially filtered for backwards compatibility with scripts written for p32 like GREPSTR is. It uses the PCRE library, 7.7

[] REGEXPREPLACE

This works just like the command GREPSUB except that it is not limited to only 10 matches.

[] REMOVEHEADER

Removes a specific http header from the headers for HTTPGET.

  • Parameters:
    • headerName: The name of the header to be removed.

[] REPLACE

Replaces the first occurrence of a string with another string.

  • Parameters:
    • oldString: The string to be replaced.
    • newString: The replacement string.
    • sourceString: The original string.

Example:

"I find this handy." source =
"it" "this" source REPLACE source =
source LOGMSG

[] REPLACEALL

Replaces all occurrence of a string with another string.

  • Parameters:
    • oldString: The string to be replaced.
    • newString: The replacement string.
    • sourceString: The original string.

Example:

"I think that I am obessed with PalaceChat." source =
"," " " source REPLACEALL source =
source LOGMSG

[] RESETHEADERS

Resets all http headers for HTTPGET back to default.

[] SETCURSOR

Sets the cursor to one of the standard predefined cursors. Valid values are from 1 through 15, any other value will reset it to default.

[] SETCURSORPIC

Sets the cursor to use a custom picture.

  • Parameters:
    • x: The x cordinate in the picture to use as the click area.
    • y: The y cordinate in the picture to use as the click area.
    • fileName: The file name of the picture to use.

[] SETTOOLTIP

Opens a tooltip with the passed message.

  • Parameters:
    • message: The message for the tool tip.

Example:

ON ROLLOVER { "cool" SETTOOLTIP }
ON ROLLOUT { CLEARTOOLTIP }

[] SETUSERNAME

This command sets your username (it does not save in preferences).

  • Parameters:
    • userName: The name to set.

Example:

"cool" SETUSERNAME

[] STOPALARM

This command haults an alarm that was generated in a specific spot. Meaning any SETALARM or ALARMEXEC will be canceled. It will not cancel room generated alarms if executed in a cyborg and will not cancel cyborg generated alarms if executed in a room script.

  • Parameters:
    • spotId: The spot id of the alarms that you want to cancel.

Example:

ME STOPALARM

[] STOPALARMS

This command haults all alarms. Meaning any SETALARM or ALARMEXEC or TIMEREXEC will be canceled. It will not cancel room generated alarms if executed in a cyborg and will not cancel cyborg generated alarms if executed in a room script.

[] TEXTSPEECH

This command will speak the passed string.

  • Parameters:
    • toSpeak: The string to be spoken.

Example:

"Hello world!" TEXTSPEECH

[] TIMEREXEC

This works just like the old command ALARMEXEC except that it uses the same context from which it was called in. Meaning local variables from the event from which it is called will be accessable in the timers atomlist making it so you don't have to use GLOBAL variables like you would have to in ALARMEXEC.

[] WHOCOLOR

Gets the facecolor of a the specified user.

  • Parameters:
    • userID: The ID of the user.

Example:

ON COLORCHANGE {
WHOCHANGE WHONAME " has changed their color to " & WHOCHANGE WHOCOLOR ITOA & LOGMSG
}

[] WHOFACE

Gets the facecolor of a the specified user.

  • Parameters:
    • userID: The ID of the user.

Example:

ON FACECHANGE {
WHOCHANGE WHONAME " has changed their face to " & WHOCHANGE WHOFACE ITOA & LOGMSG
}

[] Room and Hotspot Commands

[] ADDPIC

Adds a newly specified picture to the door, automatically downloading the image if nessacery.

  • Parameters:
    • fileName: The file name of the image.
    • SpotID: The ID of the hotspot that the picture is to be added to.

Example:

"awsome.png" ME ADDPIC

[] CACHESCRIPT

This command lets you create and store a iptscrae event which will not be removed from memory until you log off of the server. After being created the event will be used in every room you visit on the server. This command will not function for Cyborg scripting.

  • Parameters:
    • atomlist: The scripting to be executed in the event created.
    • eventName: The name of the event you wish to create.

Example:

{ROOMNAME SAY} "ENTER" CACHESCRIPT

[] FILEEXISTS

Checks if a file exists in the users local server media directory.

  • Parameters:
    • fileName: The name of the file to check for.

Example:

{"The file exists!" SAY}
{"The file doesn't exist." SAY} "clouds.gif" FILEEXISTS IFELSE

[] GETPICDIMENSIONS

Pushes the width and height of the picture associated with the specified state of the specified hotspot.

  • Parameters:
    • state: The spot state that the picture is associated with, negative value will default it to the current state of the door.
    • SpotID: The ID of the hotspot that the picture is in.

Example:

;this example gets the width and height of the current picture in
;the current door.
-1 ME GETPICDIMENSIONS height = width =

[] GETPICLOC

Pushes the x and y cordinates of the picture associated with the specified state of the specified hotspot. The values are relative to the hotspots x and y cordinates.

  • Parameters:
    • state: The spot state that the picture is associated with, negative value will default it to the current state of the door.
    • SpotID: The ID of the hotspot that the picture is in.

Example:

;this example gets the x and y of the current picture in the
;current door.
-1 ME GETPICLOC y = x =

[] GETSPOTLOC

Pushes the x and y cordinates of the specified hotspot.

  • Parameters:
    • SpotID: The ID of the hotspot that the picture is in.

Example:

;this example gets the x and y of the current hotspot.
ME GETSPOTLOC y = x =

[] GETPICBRIGHTNESS

This command returns the brightness value of a picture that was set with the SETPICBRIGHTNESS function.

  • Parameters:
    • state: The state of the spot id that the pic is in.
    • spotId: The id of the spot that the pic is in.

[] GETPICOPACITY

This command returns the opacity value of a picture that was set with the SETPICOPACITY function.

  • Parameters:
    • state: The state of the spot id that the pic is in.
    • spotId: The id of the spot that the pic is in.

[] GETPICSATURATION

This command returns the saturation value of a picture that was set with the SETPICSATURATION function.

  • Parameters:
    • state: The state of the spot id that the pic is in.
    • spotId: The id of the spot that the pic is in.

[] GETPICNAME

This command returns the file name of the picture of the passed spot id and state.

  • Parameters:
    • state: The state of the spot id you get the picture name from.
    • spotId: The id of the spot to get the picture name from.

Example:

;this example gets the file name of the picture of the current spot and state.
-1 ME GETPICNAME SAY

[] GETPICPIXEL

This command returns the value of a pixel of a picture that is in a spot.

  • Parameters:
    • x: The x cordinates of the pixel relative to the room.
    • y: The y cordinates of the pixel relative to the room.
    • state: The state of the spot that the pic is in.
    • spotId: The id of the spot that the pic is in.

Example:

;this example highlites a pic only if the cursor passes over a visible part of it
ON MOUSEMOVE {
;get the pixel of a pic at the current mouse position in the current spot and state.
;the pixel value returned is a 32bit integer (ABGR pixel format)
MOUSEPOS -1 ME GETPICPIXEL pixel =
;in order to isolate a color channel you must use BITSHIFTRIGHT
;shift 24 bits to the right to get alpha
pixel 24 BITSHIFTRIGHT alpha =
;now test wether the alpha value is a zero or not (zero meaning invisible pixel)
;and increase the pictures brightness if alpha is a non-zero value
{15 -1 ME SETPICBRIGHTNESS}
{0 -1 ME SETPICBRIGHTNESS} alpha IFELSE
}

[] HIDEAVATARS

Hides all avatars in the room. This could be useful for certain kinds of games. It only applies locally, for the user executing the script.

Example:

ON ENTER {
    HIDEAVATARS
}

[] IMAGETOMEDIA

Saves an image file in the media folder with the passed filename and image data. Generally only good for being used in the ON HTTPRECIEVED event. If used in the HTTPRECIEVED event you must set CONTENTS to "" to prevent the file from being saved twice.

  • Parameters:
    • fileName: The file name you wish to save the image as.
    • imageData: A string of raw image data.

Example:

ON HTTPRECIEVED {
{
"myimage.png" CONTENTS IMAGETOMEDIA
"" CONTENTS =
} TYPE "image/png" REGEXP IF
}

[] ISKEYDOWN

Detect if a specific key is currently pressed down by its keycode.

  • Parameters:
    • keyCode: The keycode to check for as a number.

Example:

ON KEYDOWN {
{"left arrow is being pressed" LOGMSG} 123 ISKEYDOWN IF
{"right arrow is being pressed" LOGMSG} 124 ISKEYDOWN IF
{"down arrow is being pressed" LOGMSG} 125 ISKEYDOWN IF
{"up arrow is being pressed" LOGMSG} 126 ISKEYDOWN IF
}

[] ISRI
 
Was this article helpful? yes / no

Article details
Article ID: 97
Category: Iptscrae Defined
Date added: 04-05-2011 01:12:29
Views: 2043
Rating (Votes): Article rated 5.0/5.0 (1)

 
<< Go back

Powered by Help Desk Software HESK™