Pascal Scripting Overview.
iP Pascal Scripting - Supported Functions and Features...
Standard Pascal Function definitions:
Function Abs(E : Extended) : Extended;
A:=Abs(-2); {A will equal 2}
A:=Abs(2); {A will equal 2}
C:=Chr(65); {C will equal 'A'}
C:=Chr(97); {C will equal 'a'}
S:='Hi There';
S2:=Copy(S,4,5); {S2 will equal 'There'}
E2:=Cos(100);{E will equal 0.8623 (the cosine of 100)}
S:=DateToStr(Date); {S would be the current date in string form}
S:=DateToStr(Date); {S would be the date in string form}
D:= DayOfWeek(Date); {D would be 4 if today was Wednesday (Sunday=1)}
Indx:=12;
Dec(Indx); {Indx would be 11}
Inc(Indx);{Indx would be 12 again}
DecodeDate(Date,Yr,Mn,Dy); {If today was 11/27/06 then Yr=6, Mn=11, Day=27}
DecodeTime(Now,Hr,Mn,Sc,Ms); {If it was 3:01:02.001 pm then Hr=15, Mn=1, Sc=2, Ms=1}
S:='The Big Bad Wolf';
Delete(S,9,4); {S would be 'The Big Wolf'}
Var
MyDate : TDateTime;
MyDate:=EncodeDate(1997,11,27);
S:=DateToStr(MyDate); {S would be '11/27/1997'}
Var
MyTime : TDateTime;
MyTime:=EncodeTime(15,0,0,0);
S:=TimeToStr(MyTime); {S would be '3:00:00 PM'}
Var
E : Real;
E:=12.4508;
S:=FloatToStr(E); {S would be '12.4508'}
E:=9 / 5;
S:=FloatToStr(E); {S would be '1.8'}
Var
MyDateTime : TDateTime;
MyDateTime:=StrToDate('11/27/06');
MyDateTime:=MyDateTime+StrToTime('12:45:10 pm');
S:=FormatDateTime('"Her birthday is on " dddd, mmmm d, yyyy, " at " hh:mm AM/PM', MyDateTime);
{S would be 'Her birthday is on Monday, November 27, 2006 at 12:45 PM'}
Var
AnArray : Array of integer;
AnArray[123]:=4;
S:=IntToStr(GetArrayLength(AnArray)); {S should equal '123'}
Indx:=12;
Inc(Indx); {Indx would be 13}
Dec(Indx); {Indx would be 12 again}
S:='The Big Wolf';
Insert('Bad ',S,9); {S would be 'The Big Bad Wolf';
I:=123;
S:=IntToStr(I);{S would be '123'}
S:='The Big Bad Wolf';
I:=Length(S); {I would be 16}
S:='The Big Bad Wolf';
S2:=Lowercase(S); {S2 would be 'the big bad wolf'}
S:='It is now '+TimeToStr(Now)+' on '+(DateToStr(Date)); {S would look like: 'It is now 12:01 PM on 11/27/06'}
I:=Ord('A'); {I would be 65}
S:='123';
S2:=Padl(S,12); {S2 would have 12 spaces before the 123}
S:='123';
S2:=Padr(S,12); {S2 would have 12 spaces after the 123}
S:='123';
S2:=Padz(S,12); {S2 would have 12 zeros before the 123}
S:=Copy(FloatToStr(pi),1,6); {S='3.1415'}
I:=Pos('Big','The Big Bad Wolf'); {I=9}
S:=Replicate('A',6); {S would be 'AAAAAA'}
I:=Round(Pi); {I would be 3}
I:=Round(3.6); {I would be 4}
S:='The Big Bad Wolf';
SetLength(S,7); {S would be 'The Big'}
Var
E : Real;
E:=Sin(12);
S:=Copy(FloatToStr(E),1,6);{S='0.536'}
Var
E : Real;
E:=Sqrt(9); {E would be 3.0}
S:='4567';
S2:=StrGet(S,3); {S2 would be '6'}
S:=StringOfChar('A',6); {S would be 'AAAAAA'}
Var
MyDate : TDateTime;
MyDate:=StrToDate('11/27/2006);
Var
MyDate : TDateTime;
MyDate:=StrToDate('11/27/2006);
S:='123';
I:=StrToInt(S); {I would be 123}
S:='hi there';
I:=StrToIntDef(S, 1); {I would be 1}
S:='123';
I:=StrToIntDef(S, 1); {I would be 123}
S:='The time is '+TimeToStr(Time);
S:=' This has a space in front and behind ';
S2:=Trim(S); {S2 would be 'This has a space in front and behind'}
Var
E : Real;
E:=2.34;
I:=Trunc(E); {I would be 2}
I2:=Round(E); {I2 would be 2}
E:=2.98;
I:=Trunc(E); {I would be 2}
I2:=Round(E); {I2 would be 3}
B:=TryEncodeDate(2006,11,27,MyDateTime); {B should be true}
B:=TryEncodeTime(15,10,01,00,MyDateTime); {B should be true}
S:='The Big Bad Wolf';
S2:=Uppercase(S); {S2 would be 'THE BIG BAD WOLF'}
iP specific Function definitions:
Procedure ActivateBrowser(BrowserNumber,X,Y,W,H : Integer; URL : String);
ActivateBrowser(1,0,0,320,200,'http://www.ipalaces.net'); {sets webspot #1 to 0,0,319,199 and loads up the iP web site}
If MyPropsNumber<16 then AddAVFrame; {adds a blank prop ('frame') to your av}
S:=Args[2]; {S now contains the 2nd word passed to the script}
ClearAVFrame(2); {clears the 2nd prop in your av}
ClearGlobalBoolean('Playing'); {removes the global boolean 'Playing' from the global boolean list}
ClearGlobalChar('KeyPressed'); {removes the global character 'KeyPressed' from the global char list}
ClearGlobalInteger('Score'); {removes the global Integer 'Score' from the global Integer list}
ClearGlobalLongInt('Round'); {removes the global LongInt 'Round' from the global LongInt list}
ClearGlobalReal('Total'); {removes the global Real 'Total' from the global Real list}
ClearGlobalString('Player'); {removes the global String 'Player' from the global string list}
ClearGlobalWord('Height'); {removes the global Word 'Height' from the global Word list}
ClearHighScores; {Clears the high scores structure}
ClearSprite(12); {removes the user's sprite #12 from view}
ClearSprites; {removes all of the user's sprites from view}
S:=ClientVersion; {S contains the version of the client that the user is using}
CreateSpriteByID('ABCD00123456789',4); {Assigns the .blb with hash 'ABCD00123456789' to blob #4}
CreateSpriteByName('ufo',3); {Assigns 'ufo.blb' to blob #3}
DeActivateBrowser(2); {Hides browser (web spot) #2}
DlButDontPlayMedia('applause.wav'); {downloads applause.wav from the server but does not play it}
Repeat
.... do some stuff ...
Until EscapeWasPressed;
S:=GetAVFrameIDHash(1); {S now holds the PropID for prop #1 of the user's av}
GetAVPixel(1,XX,YY,R,G,B,A); {R, G, B and A now contain the values of the pixel at XX, YY in prop 1 of the user's AV}
S:=GetBlobId('ufo.blb'); {opens 'ufo.blb' and reads its ID hash}
S:=GetByToken(I,'lives=',S2); {begins searching for 'Lives=' in S2 at position I returns the text between 'lives=' and the next space it encounters}
If GetGlobalBoolean('Playing')=False then SendTextToLog('Game Over'); {Retrieves the global boolean 'playing' and if it is false, says Game Over in the log.}
C:=GetGlobalChar('Keypressed'); {sets C to the value of the global char named 'Keypressed'}
MyScore:=GetGlobalInteger('Score'); {sets MyScore to the value of the global integer named 'Score'}
CurrentRound:=GetGlobalLongInt('Round'); {sets CurrentRound to the value of the global longint named 'Round'}
Total:=GetGlobalReal('Grand Total'); {sets Total to the value of the global real named 'Grand Total'}
S:=GetGlobalString('Player Name'); {Sets S to the value of the global string named 'Player Name');
N:=GetGlobalWord('NumPlayers'); {Sets N to the value of the global word named 'NumPlayers'}
S:=GetHighScoresName; {S holds the name of the game from the high scores structure}
I:=GetMaxPhraseRec('game phrases'); {I holds the value for the last record in the phrase file named 'game phrases' on the user's computer}
I:=GetMaxQuizRec('Turbulent Trivia'); {I holds the value for the last record in the quiz file named 'Turbulent Trivia' on the user's computer}
I:=GetMaxUserRec('mydata');{I holds the value for the last record in the user data file named 'Turbulent Trivia' on the user's computer}
mY:=GetMouseY; {mY holds the Y value for the mouse location at the moment}
mX:=GetMouseX; {mX holds the X value for the mouse location at the moment}
I:=GetRoomCount; {I holds the # of visitors to the room}
I:=GetUserByName('Dan'); {I holds the room user # for the user named 'Dan'}
S:= GetUserID ('Dan'); {S holds the ID hash for the user named 'Dan'}
S:=GetUserName(I); {S holds the name of room user # I}
XX:=GetUserX('Dan'); {XX holds the X location of the room user named 'Dan'}
YY:=GetUserY('Dan'); {YY holds the Y location of the room user named 'Dan'}
ZZ:=GetUserZ('Dan'); {ZZ holds the Z location of the room user named 'Dan'}
GoNaked; {Removes all the props from the user's AV}
GotoRoomNumber(0); {sends the user to room number 0 (usually the gate)}
GotoURLNumber(1); {Sends the user to the URL #1 as defined by the room they are in}
GotoURL('http://www.ipalaces.net'); {Sends the user to the iP web site}
If IAmStaff Then SendTextToLog('You are currently empowered');
If IsABuddy('Dan') then SendTextToLog('Dan is a buddy'); {checks against your defined buddies to see if 'Dan' is one of them}
SendTextToLog('The last room you were in was '+LastRoomName);
SendTextToLog('You just left '+LastServerName);
MoveMeTo(123,45); {Moves the user to 123 x 45 in the room}
If MyName='Dan' then SendTextToLog('Welcome Dan') else SendTextToLog('You are signed in as '+MyName);
SendTextToLog('The props I have on are: '+MyProps);
SendTextToLog('I have '+IntToStr(MyPropsNumber)+' props on');
If MyUserNumber=0 then SendTextToLog('I am the first person in the room');
NotifyAVChange; {sends a notice to the server that your AV has changed}
SendTextToLog('There are '+IntToStr(NumUsersInRoom)+' users in the room.')
SendTextToLog('There are '+IntToStr(NumUsersOnServer)+' users on the server.')
Page('Hi my name is '+MyName+' and I just arrived from '+LastServerName+' thanks for letting me visit'); {sends a page to the server and staff}
PauseFor(500); {pauses script execution for half a second (500 miliseconds)}
PlayMidi('YouWon.mid'); {Plays a midi file}
PlayMP3('HappyBirthday.mp3'); {if 'HappyBirthday.mp3' exists on the users computer in one of his defined mp3 folders, the mp3 will play for them ouside of iP in whichever program windows defaults to for mp3s}
PlayRandomMp3('beatles'); {if any mp3s exist on the users computer in one of their defined mp3 folders with 'beatles' in the name, then a random one of the so named mp3s will play for them ouside of iP in whichever program windows defaults to for mp3s}
PlayWav('youlost.wav'); {Plays a wav file}
PlayWAVLocal('youlost.wav'); {Plays a wav file locally so that only the user can hear it}
X:=RandomInt(12); {X will be a number from 0 to 11}
ReadAPhraseRec('Animals',RecNum,PS,HS,K,Points); {reads phrase record # RecNum from the 'Animals' phrase file.}
ReadAQuizRec('SuperTrivia',RecNum, Question, Answer1, Answer2, Answer3, Answer4, Qt,Points); {reads Quiz record # RecNum from 'SuperTrivia'}
ReadAUserRec('mydata',1,SN,SS,SD,L,Round,Rank,Team,Score); {Reads User Record # 1 from 'mydata'}
S:=ReadHighScores('SuperTrivia');
RequestHighScores('SuperTrivia');
RoomBrightness(255); {fully bright}
RoomBrightness(0); {totally dark}
SendTextToLog('You are now in '+RoomName);
SendTextToLog('This is room number '+IntToStr(RoomNumber));
RoomTalk('Hi '+MyName+' welcome'); {Makes the upper left corner of the room speak}
SaveAVFrameToPropSet(I); {Saves prop #I of your AV to your prop set}
If ScriptArgString='hippty hop' then HopABit; {Returns the value of the arguments passed to the script as a string}
SendTextToLog('My security level is '+IntToStr(SecLevel));
SendTextToLog('The bunnies are attacking, quick get the piggies with the bazookas!'); {Sends text to the log}
S:=ServerName; {returns the name of the server}
S:=ServerVersion; {Returns the version of the server}
SetAVPixel(1,XX,YY,R,G,B,A); {Sets the pixel at XX, YY in prop #1 to R,G,B, and A}
SetGlobalBoolean('Playing',True); {Sets 'Playing' to true}
SetGlobalChar('Keypressed','a'); {Sets 'Keypressed' to 'a'}
SetGlobalInteger('Score',12); {Sets 'Score' to 12}
SetGlobalLongInt('GrandTotal', 0); {sets 'GrandTotal' to 0}
SetGlobalReal('Half', 0.5); {Sets 'Half' to 0.5}
SetGlobalString('Player',MyName); {Sets 'Player' to the user's name}
SetGlobalWord('Level',1); {Sets 'Level' to 1}
SetHighScores('SuperTrivia',S); {Sets the High scores of 'SuperTrivia' to S}
SetMyZ(0); {Sets the user's Z to the lowest level}
SetMyZ(255); {Sets the user's Z to the highest level}
SetName(MyName+'(Winner)'); {Sets the user's name to their existing name plus '(Winner)'}
SetNameY(100); {Sets the nameY location of the user's av}
Setoffset(1,2,-34,0); {Adjusts where the image for spot state #2 of spot #1 will appear, moving it left by 34 pixels}
SetoffsetLocally(1,2,-34,0); {Adjusts where the image for spot state #2 of spot #1 will appear, moving it left by 34 pixels but only for this user}
SetRoomCount('Gate',1); {Sets the room counter for the room named 'Gate' to 1}
SetSpotDelaysLocally(S); {Sets the spot delays based on a formatted string: 'spot,state,delay|spot,state,delay|'}
SetSpotDelays(S); {Sets the spot delays based on a formatted string: 'spot,state,delay|spot,state,delay|'}
SetSpotDelay(1,2,100); {Sets spot 1's state 2 to a delay of 100}
SetSpotDelayLocal(2,3,40); {Sets spot 2's state 3 to a delay of 40}
SetSpots(S); {sets a series of spots to states based on a formatted string: 'SpotNumber,State|SpotNumber,State|SpotNumber,State|'}
SetSpotsLocally(S); {sets a series of spots to states based on a formatted string: 'SpotNumber,State|SpotNumber,State|SpotNumber,State|'}
SetSpotToState(2,24); {Sets Spot 2 to state 24}
SetSpotToStateLocally(1,12); {Sets Spot 1 to state 12}
SetSprite(12,3,100,200); {sets sprite #12 to Blob #3 and positions it at 100 x 200}
SetSprites(S);{format of S=SpriteNumber,SpriteDataNumber,X,Y,Z|SpriteNumber,SpriteDataNumber,X,Y,Z|...}
SetSticky(112,190); {Sets the sticky ballon talk location of the user}
SetTalk(112,45); {Sets the talk ballon location of the user}
SetThink(112,25); {Sets the think talk ballon location of the user}
Spoof('Dan','Do you have any cute single sisters?'); {Makes it appear as if 'Dan' asked if you have any cute single sisters}
SpoofL(123,450,'Hi Katie!'); {makes it appear locally as if someone spoke at 123 x 450 and said 'Hi Katie!');
SpoofM(123,450,'Hi Kim!'); {makes it appear as if someone spoke at 123 x 450 and said 'Hi Kim!');
I:=SpotHasWhatState(12); {sets I to the spot state # of spot # 12}
SpriteXYZ(1,4,34,123,128); {Sets sprite #1 to blob #4 and places it at 34 x 123 and in Z layer 128}
SpritesXYZ(S); {Sets a series of sprites based on a formatted string}{format of S=SpriteNumber,SpriteDataNumber,X,Y,Z|SpriteNumber,SpriteDataNumber,X,Y,Z|...}
StartVideo; {If the room has a video it makes the video start playing}
StopMid; {If a midi is playing it attempts to stop it}
StopVid; {if the room has a video playing it stops it}
StopWav; {If a wav is playing it stops it}
S:=TimeToString(Now); {Sets S equal to the time in string format}
Talk('Hi everyone, my name is '+MyName+' and its nice to meet you all'); {Makes your AV speak}
I:=UserUnderMouse; {if there is a user positioned below where your mouse is it returns their #}
WearAVMacro(1); {Places the F1 av macro on the user}
WearPropByID('ABCD12345608971'); {places a prop on the user based on its ID}
WearPropByName('large cat'); {places a prop on the user based on its name, it must reside in iP's main folder}
WearPropsByID(S); {Places a series of props on the user fomated like 'id|id2|id3|'}
WHISPERTO('Dan','Thats an UGLY cat!');
S:=WhoSpoke; {S is the name of the user that spoke, or otherwise triggered the script event}
S:=WhatTheySaid;{what the person said}
WriteAPhraseRec('MyPhrases',23,'Who sang the song "king tut"?','He was ONE wild and crazy guy!',1,10); {adds a phrase record to the 'MyPhrases' file}
WriteAQuizRec('SuperTrivia',RecNum,SQ,A1,A2,A3,A4,1,20); {adds a record to the 'SuperTrivia' file}
WriteAUserRec('MyData',RecNum,MyName,DateToString(Date),'Acrive',GameData,1,14,1,1,1340);
Room Script Only Commands:
Procedure BlendWithImage(ImgNum, X, Y : Integer; R, G, B, A : Byte);
BlendWithImage(0,XX,YY,R,G,B,A); {Blends a pixel of the value of R,G,B,A to the room image (ImgNum = 0 is the Room Image, ImgNum =1 and up are the spot images}
Procedure BlobToImage(0,1,XX,YY); {copys blob #1 to the room image at XX x YY}
ClearRoomSprite(1); {moves room sprite #1 off screen}
ClearRoomSpriteLocal(1); {moves room sprite #1 off screen for the local user only}
ClearRoomSprites; {Moves all room sprites off screen for all users}
ClearRoomSpritesLocal; {Moves all room sprites off screen for the local user only}
CreateRoomSpriteByID('ABCDEFG0103013',1); {Sets blob #1 to the blb with the ID hash of 'ABCDEFG0103013'}
CreateRoomSpriteByIDLocal('ABCDEFG0103013',1); {Sets blob #1 to the blb with the ID hash of 'ABCDEFG0103013'}
CreateRoomSpriteByName('ufo',1);{Sets blob #1 to 'ufo.blb'}
DrawLine(0,XX,YY,XX2,YY2,R,G,B,A); {draws a line on the room image}
DrawPolygon(0,XX,YY,S,R,G,B,A); {draws a polygon at XX, YY of color/alpha R,G,B,A format of the String: '1,1|12,123|43,144|100,87|32,24|' ('X,Y|X1,Y1|')}
DrawRectangle(XX,YY,XX2,YY2,R,G,B,A); {draws a rectangle at XX, YY of color/alpha R,G,B,A}
DrawString(0,S); {Draws to the room image based on a formated string: 'XX,YY,R,G,B,A|XX,YY,R,G,B,A|XX,YY,R,G,B,A|}
DrawToImage(0,XX,YY,R,G,B,A); {draws to the room image at XX,YY]
GetImagePixelRGB(0,XX,YY,R,G,B,A); {retrieves R, G, B, A for the pixel at XX, YY}
I:=GetJoyStickKey; {retrieves the last key pressed in the joystick control}
S:=GetLabelText(1); {retrieves the text of lable #1}
I:=GetRoomEvent; {retrieves the last room event number}
I:=GetRoomSpriteBlobNumber(1);{gets the blob # of sprite #1}
XX:=GetRoomSpriteX(1); {retrieves the X location of the sprite}
YY:=GetRoomSpriteY(1); {retrieves the Y location of the sprite}
ZZ:=GetRoomSpriteZ(1); {retrieves the Z location of the sprite}
HideLabel(1); {turns off visibility for label #1}
HideLabelLocal(1); {turns off visibility for label #1 locally}
ImagePixelToPropPixel(0,XX,YY,PX,PY); {copies the pixel from the image to prop #1 of the AV}
ImageRectToProp(0,X1,Y1,X2,Y2); {Copies from the image to prop#1of the av starting at 0,0 on the prop}
ImageRectToRoomBlob(0,1,XX,YY,XX2,YY2); {copies from an image to a blob}
ImageToClipboard(0); {Copies an image to the windows clipboard}
ImageToImage(0,X,Y,1,X1,Y1,X2,Y2); {copies from an image to another image}
JoyStickShiftKeyIsPressed:=JoyStickShift; {true if the Shift key is pressed in the joystick}
JoyStickCtrlKeyIsPressed:=JoyStickCtrl;{true if the Ctrl key is pressed in the joystick}
JoyStickAltKeyIsPressed:=JoyStickAlt;{true if the Alt key is pressed in the joystick}
aJoyStickKeyIsPressed:=JoyStickKeyPressed;{true if a key is pressed in the joystick}
ReleaseGlobal('Playing'); {removes any global variables named 'Playing'}
ReleaseAllGlobals; {removes all global variable definitions}
ReloadRoomImage; {reloads the room image for the local user}
ReloadSpotImage(1); {Reloads the spot image for the local user}
ReloadSpotImages; {Reloads all spot image for the local user}
RoomSpriteCollision(1,2); {does a more exact comparison between sprite#1 and sprite#2 to see if they are touching}
RoomSpriteRectCollision(1,2);{does a less exact comparison between sprite#1 and sprite#2 to see if their rectangles overlap}
RoomSpriteXYZ(1,3,XX,YY,ZZ); {positions Room Sprite #1 at XX, YY, ZZ using Room Blob #3}
RoomSpriteXYZLocal(1,3,XX,YY,ZZ); {positions Room Sprite #1 at XX, YY, ZZ using Room Blob #3 locally only}
RoomSpritesXYZ(S); {Positions a series of room sprites based on a formatted string: 'Spritenum,BlobNum,X,Y,Z|Spritenum2,BlobNum2,X2,Y2,Z|Spritenum3,BlobNum3,X3,Y3,Z|'}
RoomSpritesXYZLocal(S); {Positions a series of room sprites locally based on a formatted string: 'Spritenum,BlobNum,X,Y,Z|Spritenum2,BlobNum2,X2,Y2,Z|Spritenum3,BlobNum3,X3,Y3,Z|'}
SaveRoomBlob(1,'ufo.blb'); {saves room blob #1 as ufo.blb to the client's blobs folder}
SendData(S); {Sends ANY script defined string value, triggering REScript Data event}
ShowLabel(1); {Makes a label visible}
ShowLabelLocal(1); {Makes a label visible}
SetLabelRGBAZSizeLocal(1,255,255,0,255,0,13); {Makes label #1 yellow and 13 pts in size locally}
SetLabelRGBAZSize(1,255,255,0,255,0,13); {Makes label #1 yellow and 13 pts in size}
SetLabelTextLocal(1,'You won!'); {Sets label #1's text to 'You won!' locally}
SetLabelText(1,'You lost!'); {Sets label #1's text to 'You lost!'}
SetLabelURL(1,1); {Sets the target URL of label #1 to URL #1}
SetLabelURLLocal(1,1); {Sets the target URL of label #1 to URL #1 locally}
SetLabelXY(1,XX,YY); {Positions Label#1 at XX, YY}
SetLabelXYZ(1,XX,YY,ZZ); {Positions Label#1 at XX, YY, ZZ}
SetLabelXYZLocal(1,XX,YY,ZZ); {Positions Label#1 at XX, YY, ZZ locally}
Updated 8/17/06
Tutorials |
Home |