From PalaceChat
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
[edit] New Events
[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 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 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 IDLE
This event will be fired when the user is idle for 10 minutes.
[edit] ON MOUSEDRAG
This event will fire continuously as the user clicks and drags on a hotspot.
[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 hotspot's area.
[edit] 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.
[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 hotspot'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 hotspot'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
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
}
[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] CLEARTOOLTIP
This command will close the tooltip set by the SETTOOLTIP command.
[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 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
Example:
"http://pchat.org/api/headers.php" HTTPGET
[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] 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] 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] 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 back to default.
[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] 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] Room and Hotspot Commands
[edit] 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
[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] 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] 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 =
[edit] 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 =
[edit] 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 =
[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] 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 hotspot 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] REMOVEPIC
Removes a pic from the doors specified index. Also removes the image from ram, a good way to manage a large number of images.
- Parameters:
- index: Specifies which spotstate that the pictures in.
- SpotID: The ID of the hotspot that the picture is being removed from.
Example:
;removes the picture from the first spot in the door.
0 ME REMOVEPIC
[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] SETLOCLOCAL
This command sets the absolute position of a hotspot locally. It doesn't change the hotspot's location in the room definition on the server. When a user re-enters a room, all hotspot locations will be reset to their state as specified in the pserver.pat file.
- Parameters:
- X: The position for the picture on the x axis relative to the hotspot's location.
- Y: The position for the picture on the y axis relative to the hotspot'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 hotspot. The coordinates are relative to the location of the hotspot.
- Parameters:
- X: The position for the picture on the x axis relative to the hotspot's location.
- Y: The position for the picture on the y axis relative to the hotspot'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 you wish to modify.
Example:
;good practice to check IPTVERSION for the state parameter.
20 40 {-1} IPTVERSION 1 > IF ME SETPICLOCLOCAL
[edit] SETPICBRIGHTNESS
It will interpret the command and read the parameters off the stack, which means your scripts will not break, but the command doesn't actually do anything.
Changes the brightness of the picture associated with the specified state of the specified hotspot.
- 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 you wish to modify.
Example:
;sets the current state picture to be brighter than normal.
50 -1 ME SETPICBRIGHTNESS
[edit] SETPICOPACITY
Changes the opacity of the picture associated with the specified state of the specified hotspot.
- 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 you wish to modify.
Example:
;sets the current state picture to half opacity.
50 -1 ME SETPICOPACITY
[edit] SETPICSATURATION
It will interpret the command and read the parameters off the stack, which means your scripts will not break, but the command doesn't actually do anything.
Changes the color saturation of the picture associated with the specified state of the specified hotspot.
- 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 you wish to modify.
Example:
;sets the current state picture to greyscale.
0 -1 ME SETPICSATURATION
[edit] SETSPOTNAMELOCAL
Locally changes the name of the specified hotspot. 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] 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] 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
Was this article helpful?
yes /
no
<< Go back
Powered by Help Desk Software HESK™