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

[edit] New Events

[edit] ON COLORCHANGE

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

[edit] ON FACECHANGE

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

[edit] 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.

[edit] 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.

[edit] ON HTTPRECEIVED

This event will fire in the spot that a HTTPGET or HTTPPOST command had been called from when the content has been received successfully. 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 ""

[edit] ON HTTPSENDPROGRESS

This event fires everytime more data is sent from a http connection that had been initiated with HTTPPOST. Special variables BYTESSENT and BYTESLEFT are available.

[edit] ON HTTPRECEIVEPROGRESS

This event fires everytime new data is received from a http connection that had been initiated with HTTPGET or HTTPPOST. Special variables BYTESRECEIVED and TOTALBYTES are available.

[edit] 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.

[edit] 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.

[edit] ON IDLE

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

[edit] ON LOOSEPROPADDED

This event triggers when a loose prop is added to the room, special variable WHATPROP contains the props id.

[edit] ON LOOSEPROPMOVED

This event triggers when a loose prop is moved in the room, special variable WHATPROP contains the props id.

[edit] ON LOOSEPROPDELETED

This event triggers when a loose prop is removed from the room, special variable WHATPROP contains the props id.

[edit] ON MOUSEDRAG

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

[edit] ON MOUSEDOWN

This is the exact same as the ON SELECT event.

[edit] ON MOUSEMOVE

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

[edit] ON MOUSEUP

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

[edit] 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
}

[edit] ON ROLLOVER

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

Example:

ON ROLLOVER {
    1 ME SETSPOTSTATELOCAL ; Make button glow
}

[edit] ON ROLLOUT

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

Example:

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

[edit] 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.

[edit] ON ROOMREADY

This event will be fired once the background image for the current room has completed downloading 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. This event will trigger before ROOMLOAD only if the image is already downloaded.

Example:

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

[edit] ON SERVERMSG

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

Example:

ON SERVERMSG {
CHATSTR LOGMSG
}


[edit] 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
}

[edit] 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
}

[edit] 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
}

[edit] 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
}

[edit] ON WEBSTATUS

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

[edit] ON WEBTITLE

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

[edit] 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.

[edit] 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
}

[edit] New Commands

[edit] General Utility

[edit] 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

[edit] 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

[edit] 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

[edit] BITOR

Performs a bitwise Or comparison of two numbers.

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

[edit] 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.

[edit] 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.

[edit] BITXOR

Performs a bitwise Xor operation of two numbers.

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

[edit] 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

[edit] CLEARTOOLTIP

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

[edit] CLIENTID

This command returns a number unique to the user.

[edit] 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

[edit] ENCODEURL

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

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

Example:

USERNAME ENCODEURL SAY

[edit] 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

[edit] 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

[edit] HTTPGET

This command will download the specified url via HTTP protocol. If the recieved Content-Type is text/iptscrae 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

[edit] HTTPPOST

This command will upload post data to the specified url via HTTP protocol.

  • Parameters:
    • Mixed: If a string is passed in this parameter it will perform a application/x-www-form-urlencoded POST. If an array, hashtoken or filetoken is passed in this parameter it will perform a multipart/form-data POST. Strings, numbers and filetokens are allowed in the array or hashtoken that is passed in this parameter. Arrays are treated as key/pair values, the first element of an array will be treated as a key and the second will be treated as the value, and so on.
    • Url: The url that will handle the received http post data.

Example1:

#generates a multipart post (using an array is broken in PalaceChat 4.1.157 and older)
"" SELECTFILE file =
{
["myname" USERNAME "myfile" file] "some url" HTTPPOST
} file IF

Example2:

#generates a multipart post
"" SELECTFILE file =
{
file "some url" HTTPPOST
} file IF

Example3:

#generates a urlencoded post
"myname=jamie&mybordom=high" "some url" HTTPPOST

Example4:

#generates a multipart post
NEWHASH postdata =
USERNAME postdata "myname" PUT
CLIENTID postdata "userid" PUT
postdata "test.php" HTTPPOST

[edit] 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 }

[edit] 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

[edit] 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

[edit] IPTVERSION

This command now returns 2 for both PalaceChat and OpenPalace.

Example:

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

[edit] ISFUNCTION

Checks if the passed string is the name of a existing iptscrae function.

  • Parameters:
    • FunctionName: the name of the function you're checking for.

Example:

ON SELECT {
{"beep is a function!" LOGMSG} "BEEP" ISFUNCTION IF
}

[edit] 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
}

[edit] ISSOUNDPLAYING

Checks if a sound is currently playing that had been played with the SOUND command.

Example:

{
"a sound is currently playing!" LOGMSG
} ISSOUNDPLAYING IF

[edit] 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

[edit] 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

[edit] PROMPT

Prompts the user with a custom question and allows the user to type in a response. The response is then pushed onto the stack when the user clicks Okay, if the user Cancels the response will be a blank string.

  • Parameters:
    • question: The question or statement to appear in the prompted window.
    • defaultResponse: The default value placed in the input text box.

Example:

"What is your name?" "John" PROMPT name =
{ "Hello " name & "." & LOCALMSG }
{ "You canceled." LOCALMSG } name "" != IFELSE

[edit] NBRSERVERUSERS

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

Example:

NBRSERVERUSERS ITOA SAY

[edit] 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

[edit] 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

[edit] 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

[edit] REGEXPREPLACE

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

[edit] REMOVEHEADER

Removes a specific http header from the headers for HTTPGET.

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

[edit] 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

[edit] 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

[edit] RESETHEADERS

Resets all http headers for HTTPGET and HTTPPOST back to default.

[edit] SELECTFILE

Prompts the user with a file browser window to select a file. The function will push a FileToken on the stack of the file the user chooses, zero will be pushed onto the stack if the user cancels. The filetoken can be used in the new HTTPPOST function for file uploads to web servers. The file name and file size can be retrieved from the filetoken, example provided below.

  • Parameters:
    • MimeType: A string that defines the allowed file types, a blank string means any file.

Example:

"image/*" SELECTFILE file =
{
file LOGMSG
file ATOI LOGMSG
} file IF

[edit] 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.

[edit] 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.

[edit] SETTOOLTIP

Opens a tooltip with the passed message.

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

Example:

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

[edit] SETUSERNAME

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

  • Parameters:
    • userName: The name to set.

Example:

"cool" SETUSERNAME

[edit] SOUNDOPEN

Pushes a sound variable onto the stack of the passed sound file.

  • Parameters
    • fileName: The exact filename of the sound.

Example:

"yes" SOUNDOPEN yes =

[edit] SOUNDPLAY

Plays a sound opened with SOUNDOPEN.

  • Parameters
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"yes" SOUNDOPEN snd1 =
snd1 SOUNDPLAY

[edit] SOUNDPAUSE

Pauses a sound opened with SOUNDOPEN.

  • Parameters
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"yes" SOUNDOPEN snd1 =
snd1 SOUNDPLAY
{snd1 SOUNDPAUSE} 10 TIMEREXEC

[edit] SOUNDSEEK

Seeks to the specified position in a sound opened by SOUNDOPEN.

  • Parameters
    • position: The position in milliseconds to seek to in the sound.
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"boom" SOUNDOPEN snd1 =
400 snd1 SOUNDSEEK
snd1 SOUNDPLAY

[edit] SOUNDSTOP

Stops any sound that was played with the original SOUND command.

[edit] SOUNDISPLAYING

Check to see if a sound opened with SOUNDOPEN is currently playing.

  • Parameters
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"boom" SOUNDOPEN snd1 =
snd1 SOUNDPLAY
{"is playing" SAY} snd1 SOUNDISPLAYING IF

[edit] SOUNDGETPOSITION

Get the current position in milliseconds from a sound opened with SOUNDOPEN

  • Parameters
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"boom" SOUNDOPEN snd1 =
snd1 SOUNDPLAY
{snd1 SOUNDGETPOSITION SAY} 10 TIMEREXEC

[edit] SOUNDLENGTH

Get the length in milliseconds from a sound opened with SOUNDOPEN

  • Parameters
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"boom" SOUNDOPEN snd1 =
snd1 SOUNDLENGTH SAY

[edit] SOUNDPLAYFROM

Plays a sound from a specific position.

  • Parameters
    • position: the starting point where the sound should start playing from, in milliseconds.
    • soundVariable: a sound variable created by SOUNDOPEN.

Example:

"boom" SOUNDOPEN snd1 =
0 snd1 SOUNDPLAYFROM

[edit] 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

[edit] 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.

[edit] TEXTSPEECH

This command will speak the passed string.

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

Example:

"Hello world!" TEXTSPEECH

[edit] 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.

[edit] UPDATELATER

Tells PalaceChat to wait till the end of the script to do any drawing operations that may have otherwise happened durring the script. Useful for scripts that cause a lot of changes in the room but you want it to all appear to have changed all at once.

[edit] UPDATENOW

Only works if UPDATELATER was called previously in the script.

[edit] 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
}

[edit] 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
}

[edit] Room and spot Commands

[edit] ADDPIC

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

  • Parameters:
    • fileName: The file name or http url of the image.
    • SpotID: The ID of the spot that the picture is to be added to.

Example:

"awsome.png" ME ADDPIC

[edit] ADDPICNAME

Adds a newly specified picture to the door, automatically downloading the image if nessacery, with a parameter to specify the filename its to save as in the users media cache for that server.

  • Parameters:
    • fileName: The file name or http url of the image.
    • saveName: The file name for the image to be cached as on the users computer.
    • SpotID: The ID of the spot that the picture is to be added to.

Example:

"http://pchat.org/pics/pchat-logo3.png" ME ADDPIC

[edit] ADDSPOT

Adds a new spot to the room for the user pushing its spot id onto the stack.

  • Parameters:
    • pointsArray: the array of points as x y values, the values are relative to the spots x y location.
    • xLoc: Sets the x location of the spot.
    • yLoc: Sets the y location of the spot.

Example:

;adds a square spot to the room storing the new spots id in a variable
[65 -65 65 65 -65 65 -65 -65] 200 200 ADDSPOT spotid =

[edit] AUTOUSERLAYER

If on all users in the room will layer according to vertical position. In order for all users to see this change it must be placed in a room's spot.

  • Parameters:
    • on/off switch: 1 to turn on and 0 for off.

Example:

ON ROOMLOAD {
1 AUTOUSERLAYER
}

[edit] 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

[edit] FILEDATE

Returns the last modified date and time of a file by filename. Example result: Fri, 13 Apr 2012 22:52:15 GMT

  • Parameters:
    • fileName: The name of the file to get the last modified date and time from.

Example:

"clouds.gif" filename =
{
	filename FILEDATE SAY
} filename FILEEXISTS IF

[edit] FILEDELETE

Deletes a file that exists in the users local server media directory.

  • Parameters:
    • fileName: The name of the file to delete.

Example:

"example.jpg" FILEDELETE

[edit] 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

[edit] GETPICANGLE

Gets the angle of a picture in a spot.

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

[edit] GETPICDIMENSIONS

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

  • 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 spot 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 =

[edit] GETPICLOC

Pushes the x and y cordinates of the picture associated with the specified state of the specified spot. The values are relative to the spots 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 spot 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 =

[edit] GETSPOTLOC

Pushes the x and y cordinates of the specified spot.

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

Example:

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

[edit] GETSPOTPOINTS

Pushes an array of x y values representing the spots points onto the stack.

  • Parameters:
    • SpotID: The ID of the spot.

[edit] 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.

[edit] 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.

[edit] 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.

[edit] 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

[edit] 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
}

[edit] 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
}

[edit] 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
}

[edit] ISRIGHTCLICK

Detect if a click on a door is a right click.

Example:

ON SELECT {
	{
		"Right click." LOGMSG
	}
	{
		"Left click." LOGMSG
	} ISRIGHTCLICK IFELSE
}

[edit] INSERTPIC

Inserts a newly specified picture to the door in the specified index, automatically downloading the image if nessacery.

  • Parameters:
    • fileName: The file name of the image.
    • index: Specifies which spotstate
    • SpotID: The ID of the spot that the picture is to be added to.

Example:

;inserting a picture to the first spot state of the door
"awsome.png" 0 ME INSERTPIC

[edit] LOCINSPOT

Checks whether or not an X and Y coordinate is within a spot/door.

  • Parameters:
    • x: The x coordiante relative to the room.
    • y: The y coordiante relative to the room.
    • SpotID: The ID of the spot that you're checking if the xy is within.

Example:

{
"I'm within spot " ME & SAY
} POSX POSY ME LOCINSPOT

[edit] MEDIAADDRESS

Gets the http address of the media server of the current palace. Useful for scripts that require full http address to point to content.

[edit] NBRPICFRAMES

Get the number of frames of a gif animation picture thats in a spot.

  • Parameters:
    • state: Spot's state that the picture is in.
    • SpotID: The ID of the spot that the picture is in.

[edit] PAUSEPIC

Pauses a gif animation.

  • Parameters:
    • state: Spot's state that the picture is in.
    • SpotID: The ID of the spot that the picture is in.

[edit] REMOVEPIC

Removes a pic from the doors specified state. Also removes the image from ram, a good way to manage a large number of images.

  • Parameters:
    • state: Specifies which spotstate that the pictures in.
    • SpotID: The ID of the spot that the picture is being removed from.

Example:

;removes the picture from the first spot in the door.
0 ME REMOVEPIC

[edit] REMOVESPOT

Removes a spot from the room. Note: only removes spots that were created with the ADDSPOT command.

  • Parameters:
    • SpotID: The ID of the spot to remove.

[edit] RESUMEPIC

Resumes a gif animation after having used the PAUSEPIC function.

  • Parameters:
    • state: Spot's state that the picture is in.
    • SpotID: The ID of the spot that the picture is in.

[edit] ROOMPICNAME

Pushes the file name of the background image onto the stack.

Example:

ROOMPICNAME SAY

[edit] ROOMWIDTH

Pushes the width of the room's background image onto the stack. If the background image has not yet been loaded, it will push 512, the default room width, onto the stack.

Example:

;move the user to a random x position in the room.
ROOMWIDTH RANDOM POSY SETPOS

[edit] ROOMHEIGHT

Pushes the height of the room's background image onto the stack. If the background image has not yet been loaded, it will push 384, the default room height, onto the stack.

Example:

;move the user to a random y position in the room.
POSX ROOMHEIGHT RANDOM SETPOS

[edit] SETPICANGLE

Sets the 360 angle of a picture in a spot.

  • Parameters:
    • angle: the angle of the picture.
    • state: The spot state that the picture is in.
    • SpotID: The ID of the spot that the picture is in.

[edit] SETPICFRAME

Sets the current frame in a gif animation.

  • Parameters:
    • frameIndex: The frame index you wish to set the gif animation to.
    • state: The spot state that the picture is in.
    • SpotID: The ID of the spot that the picture is in.

[edit] SETLOCLOCAL

This command sets the absolute position of a spot locally. It doesn't change the spot's location in the room definition on the server. When a user re-enters the room all spot locations will be where they were originally.

  • Parameters:
    • X: The position for the picture on the x axis relative to the spot's location.
    • Y: The position for the picture on the y axis relative to the spot's location.
    • SpotID: The ID of the spot you wish to modify.

Example:

20 40 ME SETLOCLOCAL

[edit] SETPICLOCLOCAL

Changes the location of the picture associated with the specified state of the specified spot. The coordinates are relative to the location of the spot.

  • Parameters:
    • X: The position for the picture on the x axis relative to the spot's location.
    • Y: The position for the picture on the y axis relative to the spot's location.
    • state: The spot state that the picture is associated with, negative value will default it to the current state of the door. (this parameter is only available with IPTSCRAE version 2 and higher)
    • SpotID: The ID of the spot that the picture is in.

Example:

20 40 -1 ME SETPICLOCLOCAL

[edit] SETPICBRIGHTNESS

Changes the brightness of the picture associated with the specified state of the specified spot.

  • Parameters:
    • Brightness: The pictures brightness. Valid values range from -100 to 100. Default is 0
    • 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 spot that the picture is in.

Example:

;sets the current state picture to be brighter than normal.
50 -1 ME SETPICBRIGHTNESS

[edit] SETPICBLUR

Changes the blur radius of the picture associated with the specified state of the specified spot.
This function only works for Windows Vista and higher due to the fact that Microsoft GDIplus 1.1 is not available for older systems.

  • Parameters:
    • blurRadius: Valid values range from 0 to 2500. Default is 0
    • 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 spot that the picture is in.

Example:

50 -1 ME SETPICBLUR

[edit] SETPICCONTRAST

Changes the contrast of the picture associated with the specified state of the specified spot.

  • Parameters:
    • contrast: Valid values range from -100 to 1000. Default is 0
    • 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 spot that the picture is in.

Example:

-50 -1 ME SETPICCONTRAST

[edit] SETPICHUE

Changes the hue of the picture associated with the specified state of the specified spot.

  • Parameters:
    • hue: The pictures hue. Valid values range from -180 to 180. Default is 0
    • 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 spot that the picture is in.

Example:

100 -1 ME SETPICHUE

[edit] SETPICOPACITY

Changes the opacity of the picture associated with the specified state of the specified spot.

  • Parameters:
    • Opacity: The pictures opacity. Valid values range from 0 to 100. Default is 100
    • 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 spot that the picture is in.

Example:

;sets the current state picture to half opacity.
50 -1 ME SETPICOPACITY

[edit] SETPICSATURATION

Changes the color saturation of the picture associated with the specified state of the specified spot.

  • Parameters:
    • Saturation: The pictures color saturation. Valid values range from -10000 to 10000. Default is 100
    • 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 spot that the picture is in.

Example:

;sets the current state picture to greyscale.
0 -1 ME SETPICSATURATION

[edit] SETSPOTCLIP

Sets a spot to clip its current image.
the clipMode parameter can be a value from -2 to 2 the meanings are as follows:
0 means no clipping.
1 means the image in the spot cannot draw outside of the bounds of the spot.
2 means the same as 1 except that images from other spots cannot draw within the doors bounds.
-1 is the exact opposite of 1.
-2 is the exact opposite of 2.

  • Parameters:
    • clipMode: The mode in which the spot will clip images (described above).
    • spotId: The id of the spot.

Example:

ON SELECT {
1 ME SETSPOTCLIP
}

[edit] SETSPOTCURVE

Sets the spots curviness. Note: if the door is a perfect square the tension value of 100 will make it a perfect circle.

  • Parameters:
    • tension: The tension of the curviness for the doors border, tension of zero is default for all doors.
    • spotId: The id of the spot.

Example:

ON SELECT {
100 ME SETSPOTCURVE
}

[edit] SETSPOTNAMELOCAL

Locally changes the name of the specified spot. Only updates for the user who is running the script. You might use this to display the current score in a game. You can hide a spot name by setting it to the empty string ("")

Example:

SCORE GLOBAL
15 SPOTID =
"Your score is: " SCORE ITOA & SPOTID SETSPOTNAMELOCAL

[edit] SETSPOTOPTIONS

Sets the spots options, layer and type.

Valid option values:
Don't Move here = 2
Show Name = 8
Show Frame = 16
Shadow = 32

Valid layer values:
Door draws below all = 0
Door draws above props = 1
Door draws above name tags = 2
Door draws above all = 3

Valid type values:
Normal = 0
Passage = 1
Shutable Door = 2
Lockable Door = 3
Dead Bolt = 4
Nav Area = 5

  • Parameters:
    • options: Value for which options to be set as described above.
    • layer: Sets the layer at which the door and its contents will be drawn, normal layer is 0.
    • type: The type of door.
    • spotId: The id of the spot.

Example:

ON SELECT {
;sets the door to draw its frame and Don't move here options
;settings its layer at the bottom
;and sets its type to passage.
2 16 + 0 1 ME SETSPOTOPTIONS
}

[edit] SETSPOTPICMODE

Sets the mode for the spot that tells how pics should appear.
Values and their meanings:
0: the pictures will appear their default way, centered to the loc of the spot.
1: the pictures will appear starting from the top left of the pic at the loc of the spot.
2: the picture will sretch to the max width and height of the spot not respecting aspect ratio.
3: the same as 2 except uses high quality bicubic resizing.
4: the picture will be stretched and centered to the max width and height of the spot respecting aspect ratio.
5: the same as 4 except uses high quality bicubic resizing.

  • Parameters:
    • picMode: The pic mode.
    • spotId: The id of the spot.

Example:

ON SELECT {
;this example assumes a picture is in the spot
5 ME SETSPOTPICMODE
}

[edit] SETSPOTPOINTS

Sets all the points of a spot. You can specify from zero to as many points that you want the spot to have.

  • Parameters:
    • pointsArray: the array of points as x y values, the values are relative to the spots x y location.
    • xLoc: Sets the x location of the spot.
    • yLoc: Sets the y location of the spot.
    • spotId: The id of the spot.

Example:

;turns the spot into a small perfect square based off the spots location using GETSPOTLOC
ON SELECT {
[
15 -15
15 15
-15 15
-15 -15
] ME GETSPOTLOC ME SETSPOTPOINTS
}

[edit] SETSPOTSCRIPT

Used to set a script event for a spot. Useful for spots created with the ADDSPOT command.

  • Parameters:
    • atomlist: The atomlist script to be set for the spot.
    • eventName: The name of the event.
    • spotId: The id of the spot.

Example:

;create a new spot and sets the SELECT event script for the spot.
[65 -65 65 65 -65 65 -65 -65] 200 200 ADDSPOT spotid =
{"test" SAY} "SELECT" spotid SETSPOTSCRIPT

[edit] SETSPOTSTYLE

Sets the spots background color, border color and border size.
The easiest way to set the color parameters is to use a hex value in a string. Example: "&hFF00FF00"
The order that the color channels are in is Alpha, Red, Green, Blue (ARGB), so the example above creates a solid green.

  • Parameters:
    • backgroundColor: The color to be used for the spots background.
    • borderColor: The color to be used for the spots border.
    • borderSize: The size of the border. Valid values are from 0 and up. Default value is 1.
    • spotId: The id of the spot.

Example:

ON SELECT {
;sets the spot to have a semi transparent blue background color with a solid red 2 pixel border.
"&hCC0000FF" "&hFFFF0000" 2 ME SETSPOTSTYLE
}

[edit] SHOWAVATARS

Makes all avatars in the room visible again after a HIDEAVATARS command has hidden them.

Example:

ON SELECT {
    SHOWAVATARS
}

[edit] WEBEMBED

Embeds a web browser control into the spot specified loading the url passed. It will fill the area of the spot. Passing a empty string will remove the web object.

  • Parameters:
    • url: The url of the website you wish to display.
    • SpotID: The ID of the spot you wish to have the web control embedded.

Example:

"http://pchat.org" ME WEBEMBED

[edit] WEBLOCATION

Retrieve the current url of a WEBEMBED.

  • Parameters:
    • SpotID: The ID of the spot that the webembed is in.

Example:

ON WEBDOCDONE {
	{
		"The page is finished loading." LOGMSG
	} ME WEBLOCATION DOCURL == IF
}

[edit] WEBTITLE

Retrieve the current title of a WEBEMBED.

  • Parameters:
    • SpotID: The ID of the spot that the webembed is in.

Example:

;this examaple assumes a webembed is in the door that this script is in
ON ROLLOVER {
	ME WEBTITLE LOGMSG
}

[edit] WEBSCRIPT

Executes javascript of a webembed.

  • Parameters:
    • Script: The javascript to be executed.
    • SpotID: The ID of the spot that the webembed is in.

Example:

;this examaple assumes a webembed is in the door that this script is in
ON ROLLOVER {
	"alert('test')" ME WEBSCRIPT
}

[edit] Prop Commands

[edit] IMAGETOPROP

Imports a image as a prop that is stored locally on the users hard drive in the servers media folder. This command is only allowed to be used in room scripting.

  • Parameters:
    • fileName: The name of the image file.

Example:

"cool.png" IMAGETOPROP

[edit] LOADPROPS

Allows you to pre-load props in the background. This is probably most useful for game developers. This is especially important on OpenPalace, because with a web-based client, there is no way to keep props cached from one session to the next, so they must be loaded from the server every time.

Important: You may only load up to 500 props at a time with this command. Attempting to load more will cause an Iptscrae error.

Example:

[ 48329285 394829 -195839523 ] LOADPROPS

[edit] LOOSEPROP

Pushes the prop id of the loose prop by index.

Example:

;this example causes you to wear the last dropped loose prop.
0 LOOSEPROP propId =
propId DONPROP


[edit] LOOSEPROPIDX

Pushes the index of the loose prop by prop id onto the stack. If there are two or more loose props with the same id the index of the first one is pushed.

Example:

;this example asumes a prop with the id of 60035 is already a loose prop.
60035 LOOSEPROPIDX index =
index REMOVELOOSEPROP


[edit] LOOSEPROPPOS

Pushes the x and y cordinates of a loose prop by index onto the stack.

Example:

;this example logs the cordinates of the last dropped loose prop.
0 LOOSEPROPPOS y = x =
x ITOA " " & y ITOA & LOGMSG


[edit] MOVELOOSEPROP

Sets the location of a looseprop by index. The looseprop will not update its position until the server responds to the query.

  • Parameters:
    • X: The position for the loose prop on the x axis.
    • Y: The position for the loose prop on the y axis.
    • Index: The index of the looseprop within the room.

Example:

;move the last dropped looseprop to your mouse position.
MOUSEPOS 0 MOVELOOSEPROP


[edit] NBRLOOSEPROPS

Pushes the number of loose props onto the stack.

Example:

;this example logs the prop id's of all the loose props in the room.
{ i LOOSEPROP ITOA LOGMSG i++ }{ i NBRLOOSEPROPS <} WHILE


[edit] PROPDIMENSIONS

Pushes the width and height of a prop onto the stack.

Example:

;this example logs the width and height of a prop.
60035 PROPDIMENSIONS height = width =
width ITOA "x" & height ITOA & LOGMSG


[edit] PROPOFFSETS

Pushes the x and y offset of a prop relative to how it would appear on a user onto the stack.

Example:

;this example places a loose prop at your mouse position based on
;how it would appear on a user.
60035 PROPOFFSETS offy = offx =
MOUSEPOS y = x =
60035 x offx + y offy + ADDLOOSEPROP

[edit] REMOVELOOSEPROP

Removes of a looseprop by index. The looseprop will not be removed until the server responds to the query.

Example:

;remove the last dropped looseprop.
0 REMOVELOOSEPROP

[edit] Drawing Commands

[edit] OVAL

Draws a oval with the current pen and penfill settings.

  • Parameters:
    • X: The position for the oval on the x axis relative to the center of the oval.
    • Y: The position for the oval on the y axis relative to the center of the oval.
    • Width: The width of the oval
    • Height: The height of the oval.

Example:

;this example draws a large green oval across the room with
;50% opacity with a red border.
127 PENFILLOPACITY
0 255 0 PENFILLCOLOR
255 0 0 PENCOLOR
3 PENSIZE
ROOMWIDTH w = ROOMHEIGHT h =
w 2 / x =
h 2 / y =
x y w h OVAL

[edit] PENOPACITY

Sets the Opacity for drawn lines. Valid values range from 0 to 255. Be sure to set PENOPACITY back to 255 at the end of any script that uses it.

  • Parameters:
    • Opacity: The line opacity for lines, polygons and ovals.

Example:

;this example draws a line across the room with half opacity in the
;color red.
127 PENOPACITY 255 0 0 PENCOLOR 9 PENSIZE
0 0 ROOMWIDTH ROOMHEIGHT LINE
255 PENOPACITY
;be sure to reset the opacity to full after

[edit] PENFILLCOLOR

Sets the fill color for polygons and ovals. The parameters are identical to that of the function PENCOLOR. (red green blue)

Example:

;this example draws a large green oval across the room with 50% opacity
;with a red border.
127 PENFILLOPACITY
0 255 0 PENFILLCOLOR
255 0 0 PENCOLOR
3 PENSIZE
ROOMWIDTH w = ROOMHEIGHT h =
w 2 / x =
h 2 / y =
x y w h OVAL

[edit] PENFILLOPACITY

Sets the fill Opacity for polygons and ovals. Valid values range from 0 to 255. Setting PENFILLOPACITY to zero will turn fills off completely. The default value is zero.

  • Parameters:
    • Opacity: The fill opacity for polygons and ovals.

Example:

;this example draws a large green oval across the room with 50% opacity
;with a red border.
127 PENFILLOPACITY
0 255 0 PENFILLCOLOR
255 0 0 PENCOLOR
3 PENSIZE
ROOMWIDTH w = ROOMHEIGHT h =
w 2 / x =
h 2 / y =
x y w h OVAL

[edit] POLYGON

Draws a filled polygon if PENFILLOPACITY is not set to zero. Draws an array of lines if PENFILLOPACITY is zero.

  • Parameters:
    • Number Array: An array of x's and y's.

Example:

;draws a random color over the entire room with a semi translucent opacity.
0 PENOPACITY
PENFRONT
255 RANDOM 255 RANDOM 255 RANDOM PENCOLOR
180 PENFILLOPACITY
ROOMWIDTH x = ROOMHEIGHT y =
[0 0 0 y x y x 0] POLYGON


[edit] DRAWTEXT

Draws text at the x and y provided in the current penfont, pencolor and penopacity.

  • Parameters:
    • X: The position for the text on the x axis.
    • Y: The position for the text on the y axis.
    • Text: The string of text to be drawn.

Example:

;draws red text in the top left corner of the room.
"Arial" PENFONT
PENFRONT
255 0 0 PENCOLOR
255 PENOPACITY
"This is a test" 0 0 DRAWTEXT


[edit] PENFONT

Sets the font to be used in DRAWTEXT.

  • Parameters:
    • fontName: The exact name of the font to be used in quotes.

Example:

;draws red text in the top left corner of the room.
"Arial" PENFONT
PENFRONT
255 0 0 PENCOLOR
255 PENOPACITY
18 PENSIZE
"This is a test" 0 0 DRAWTEXT


[edit] PENBOLD

Turns bold on or off for DRAWTEXT.

  • Parameters:
    • number: 0 turns bold off, 1 turns bold on.

Example:

;draws bold red text in the top left corner of the room.
1 PENBOLD
"Arial" PENFONT
PENFRONT
255 0 0 PENCOLOR
255 PENOPACITY
18 PENSIZE
"This is a test" 0 0 DRAWTEXT


[edit] PENUNDERLINE

Turns underline on or off for DRAWTEXT.

  • Parameters:
    • number: 0 turns underline off, 1 turns underline on.

Example:

;draws bold red text in the top left corner of the room.
1 PENUNDERLINE
"Arial" PENFONT
PENFRONT
255 0 0 PENCOLOR
255 PENOPACITY
18 PENSIZE
"This is a test" 0 0 DRAWTEXT


[edit] PENITALIC

Turns penitalic on or off for DRAWTEXT.

  • Parameters:
    • number: 0 turns penitalic off, 1 turns penitalic on.

Example:

;draws bold red text in the top left corner of the room.
1 PENITALIC
"Arial" PENFONT
PENFRONT
255 0 0 PENCOLOR
255 PENOPACITY
18 PENSIZE
"This is a test" 0 0 DRAWTEXT


[edit] SHOWPAINT

Generates scripting based on paint currently drawn in the room. This command is just like the SHOWLOOSEPROPS command except for paint instead.

Personal tools