Pascal Scripting Overview.
iP Pascal Scripting - Examples...
Program DateTimeExample;
Var
S, S1 : String;
begin
{Time, Date, and Now are all basically interchangable.}
{They all return a DateTime value.}
S1:=DateToStr(Now);
Case DayOfWeek(Date) of
1 : S:='Sunday';
2 : S:='Monday';
3 : S:='Tuesday';
4 : S:='Wednesday';
5 : S:='Thursday';
6 : S:='Friday';
7 : S:='Saturday';
Else S:='Noneday';
End; {Case}
Talk(S+' '+S1+' '+TimeToString(Time));
end.
Program iPSpecificsDemo1;
Var
S : String;
begin
{This demo shows how to use the following items:
MyName, RoomName, RoomNumber, ServerName, NumUsersInRoom, NumUsersOnServer.}
{iP allows you to get your name, the server name,
and the name of the room you are in..}
S:='My name is '+MyName;
S:=S+' and I am in '+RoomName;
S:=S+' at '+Servername;
{the above three lines could all be in one line like so:
S:='My name is '+MyName+' and I am in '+RoomName+' at '+Servername;
Or even part of the Talk() line below like so:
Talk('My name is '+MyName+' and I am in '+RoomName+' at '+Servername);}
Talk(S);
{You can also get the # of users in the room or server.}
Talk('There are '+IntToStr(NumUsersInRoom)+' people in this room and '+IntToStr(NumUsersOnServer)+' on the server.');
Talk(RoomName+' is room number '+IntToStr(RoomNumber)+'.');
end.
Program iPSpecificsDemo2;
Var
S : String;
I : Integer;
begin
{This demo shows how to use the following items:
GetMouseX, GetMouseY, SendTextToLog, PauseFor.}
SendTextToLog('Start');
For I:=1 to 25 do
Begin
PauseFor(300);{this adds a slight delay (300ms) durring which
the normal flow of the program should continue.}
S:='The mouse is at ';
S:=S+IntToStr(GetMouseX)+',';
S:=S+IntToStr(GetMouseY);
SendTextToLog(S);
End;
end.
Program iPSpecificsDemo3;
Var
S, S2 : String;
II : Integer;
begin
{This demo shows how to use the following items:
MyProps, WearAVMacro, WearPropByID, WearPropsByID, PlayWav.}
S:=MyProps;
II:=0;
PauseFor(2000); {20 seconds}
GoNaked;
WearAVMacro(10);
S2:=MyProps;
II:=0;
PauseFor(2000); {2 seconds}
GoNaked;
WearPropByID(Copy(S,1,Pos('|',S)-1));
PlayWav('Blip.wav');
II:=0;
PauseFor(20000); {20 seconds}
GoNaked;
WearPropsByID(S2);
end.
Program IncAndDecExample; Var I, X : Integer; begin X:=0; For I:=1 to 10 do Inc(X); Dec(X); Talk(IntToStr(X)); end.
Program UserInfoDemo;
Var
I : Integer;
S : String;
begin
{ Users Information is Zero Based, NumUsersInRoom isn't }
For I:=0 to NumUsersInRoom-1 do
Begin
S:=GetUserName(I);
Talk(S+' is at '+IntToStr(GetUserX(S))+','+IntToStr(GetUserY(S)));
End;
end.
Program PixelsDemo;
Var
Frame, R, G, B, A, X, Y : Integer;
AV, S : String;
begin
AV:=GetAVFrameIDHash(1); {saves the 1st prop you have on}
GoNaked;
AddAVFrame; {adds a blank frame}
Frame:=1;
{this just generates a colorful av
- in real life you could use a formula or two...}
For X:=1 to 149 do
Begin
For Y:=1 to 149 do
Begin
R:=X+Y;
G:=X;
B:=Y;
A:=(X*2-Y);
SetAVPixel(Frame, X, Y, R, G, B, A);
End;
End;
SaveAVFrameToPropSet(1); {save the generate frame to your prop set}
NotifyAVChange; {sends a message to the server that you have a new prop on}
S:='';
Y:=75;
Frame:=1;
{this just demonstrates how you can examine the pixels
of a prop you have on.}
For X:=50 to 60 do
Begin
GetAVPixel(Frame, X, Y, R, G, B, A);
S:=S+'R='+IntToStr(R)+' G='+IntToStr(G)+' B='+IntToStr(B)+' A='+IntToStr(A);
If X<60 then S:=S+',';
End;
Talk(S);
GoNaked;
WearPropByID(AV); {this puts your inital first prop back on you}
end.
Program ArriveRooom; {This script executes when you arrive in a new room}
Var
I, II : Integer;
begin
PauseFor(2000); {pauses for 2 seconds to allow room processing to occur}
If MYName='Dan' then
Begin
WearAVMacro(1); {Wears your first macro in the current AV Set}
End Else Begin
WearAVMacro(7);
End;
For I:=0 to NumUsersInRoom-1 do
Begin
If GetUserName(I)<>MYName then
Begin
II:=RandomInt(4)+1; {generates a random# between 1 and 4}
Case II of
1 : Talk('Hi '+GetUserName(I));
2 : Talk('Hello '+GetUserName(I));
3 : Talk('Howdy '+GetUserName(I));
4 : Talk('Yo '+GetUserName(I)+'!');
End; {Case}
End; {If / Then}
End; {For}
end. {script}