-
Notifications
You must be signed in to change notification settings - Fork 0
/
planetarium.lsl
141 lines (114 loc) · 3.57 KB
/
planetarium.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
integer PLANETARIUM_CHANNEL = 42;
string TEXTURE_NOTECARD_NAME = "Planetarium Texture List";
string END_OF_FILE_LINE = "###END OF FILE";
integer changeTextureIndex = 0;
integer loadTextureIndex = 1; //skip header
list textureNameList = [];
list textureKeyList = [];
list rotationSettingList = [];
key lineDataRequest = "";
integer listenHandle;
changeTexture()
{
if(changeTextureIndex >= llGetListLength(textureKeyList))
{
changeTextureIndex = 0;
}
string textureName = llList2String(textureNameList, changeTextureIndex);
key textureKey = llList2Key(textureKeyList, changeTextureIndex);
integer rotationSetting = llList2Integer(rotationSettingList, changeTextureIndex);
llSay(PUBLIC_CHANNEL, textureName);
llSetTexture(textureKey, ALL_SIDES);
if(rotationSetting)
{
llSetTextureAnim(ANIM_ON |SMOOTH| LOOP, ALL_SIDES, 0, 0, 0.0, 0.0, 0.01);
}
else
{
llSetTextureAnim(FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);
}
changeTextureIndex++;
}
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llSetTexture(TEXTURE_BLANK, ALL_SIDES);
state loading_textures;
}
}
state loading_textures
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llSay(PUBLIC_CHANNEL, "Loading spherical texture list...");
loadTextureIndex = 1;
textureNameList =[];
textureKeyList = [];
rotationSettingList = [];
lineDataRequest = "";
lineDataRequest = llGetNotecardLine(TEXTURE_NOTECARD_NAME, loadTextureIndex);
}
dataserver(key request, string data)
{
//llOwnerSay("Dataserver reached. Data: " + data);
if(request == lineDataRequest)
{
if(data != EOF && data != END_OF_FILE_LINE)
{
list texture = llParseString2List(data, ["###"], [""]);
string textureName = llList2Key(texture, 0);
key textureKey = llList2Key(texture, 1);
integer rotationSetting = llList2Integer(texture, 2);
textureNameList = textureNameList + textureName;
textureKeyList = textureKeyList + textureKey;
rotationSettingList = rotationSettingList + rotationSetting;
loadTextureIndex++;
lineDataRequest = llGetNotecardLine(TEXTURE_NOTECARD_NAME, loadTextureIndex);
}
else
{
//llOwnerSay(llDumpList2String(textureKeyList, ","));
//llOwnerSay(llDumpList2String(rotationSettingList, ","));
state ready;
}
}
}
}
state ready
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llSay(PUBLIC_CHANNEL, "Planetarium ready. " + (string)llGetListLength(textureNameList) + " texture(s) loaded. Click to change texture.");
changeTextureIndex = 0;
changeTexture();
listenHandle = llListen(PLANETARIUM_CHANNEL, "", llGetOwner(), "");
}
state_exit()
{
llListenRemove(listenHandle);
}
touch_start(integer num_detected)
{
changeTexture();
}
listen(integer channel, string name, key id, string message)
{
if(message == "reload")
{
state loading_textures;
}
}
}