-
Notifications
You must be signed in to change notification settings - Fork 0
/
elevator.lsl
79 lines (71 loc) · 1.98 KB
/
elevator.lsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*v### Teleporter Settings - Make Changes Below ###v*/
string PROMPT_TEXT = "Teleport back to Main Hub: Click on Prim"; //Hover text
vector DEFAULT_DESTINATION = <148.00000, 95.00000, 3497.00000>;
rotation ROTATION = ZERO_ROTATION;
integer LOAD_LANDMARK = FALSE; //Set this to true if you want to load destination from landmark in object inventory instead
float HEIGHT_OFFSET = 1.0; //Height offset for destination
/*^### Teleporter Settings - Make Changes Above ###^*/
//Global Variables
vector startPosition;
vector destination;
key requestID;
teleport(vector destination)
{
if(llGetPos() != destination)
{
llSetRegionPos(destination);
teleport(destination);
}
else
{
llSleep(0.5);
llUnSit(llAvatarOnSitTarget());
llSetRegionPos(startPosition);
}
}
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llSetText(PROMPT_TEXT, <1,1,1>, 1.0);
llSitTarget(<0.0, 0.0, 1.0>, ROTATION);
startPosition = llGetPos();
destination = DEFAULT_DESTINATION + <0.0, 0.0, HEIGHT_OFFSET>;
if(LOAD_LANDMARK)
{
if (llGetInventoryNumber(INVENTORY_LANDMARK) == 0)
{
llSay(0, "No Landmark found in inventory, destination set to default in script");
}
else
{
requestID = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, 0));
}
}
}
dataserver(key query, string data)
{
if(requestID == query)
{
destination = (vector)data + <0.0, 0.0, HEIGHT_OFFSET>;
}
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llGetNumberOfPrims() > 1)
{
teleport(destination);
}
}
else if(change & CHANGED_INVENTORY)
{
llResetScript();
}
}
}