Skip to content

Commit 6da5d44

Browse files
committed
Initial Commit
0 parents  commit 6da5d44

10 files changed

+654
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
links

src/Makefile

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
lslfiles := $(wildcard *.lsl)
2+
linkfiles := $(lslfiles:%.lsl=./links/%.lsl)
3+
tmpfiles := $(wildcard /tmp/*.lsl)
4+
lslint := $(shell command -v lslint 2> /dev/null)
5+
highlighting := while read line; do \
6+
echo $$line | grep ERROR > /dev/null \
7+
&& echo -e "\e[91m$$line\e[0m" \
8+
|| echo $$line | grep WARN > /dev/null \
9+
&& echo -e "$$line" \
10+
|| echo -e "\e[90m$$line\e[0m"; \
11+
done;
12+
13+
.PHONY: link clean all release check
14+
15+
all : link $(linkfiles)
16+
@echo -e "\e[92mFinished build...\e[0m";
17+
18+
release : debfilter = | grep -v llOwnerSay\(\"DEBUG
19+
release : link $(linkfiles)
20+
@echo -e "\e[92mFinished build release...\e[0m";
21+
22+
./links/%.lsl : %.lsl
23+
ifdef lslint
24+
@echo -e "\e[96mSyntaxcheck with lslint...\n\e[93m$<\e[0m";
25+
@lslint $< 2>&1 | \
26+
$(highlighting)
27+
endif
28+
@echo -e "\e[96mUploading file...\e[0m";
29+
cat $< $(debfilter) > $@
30+
31+
check :
32+
ifdef lslint
33+
@echo -e "\e[96mSyntaxcheck with lslint...\e[0m";
34+
@for script in $(lslfiles); do \
35+
echo -e "\e[93m$$script\e[0m"; \
36+
lslint $$script 2>&1 | \
37+
$(highlighting) \
38+
done;
39+
else
40+
@echo -e "\e[96mNeed lslint for this, check out http://w-hat.com/#lslint...\e[0m";
41+
endif
42+
43+
link :
44+
@echo -e "\e[96mLinking lsl files from /tmp/...\e[0m";
45+
@[ -d links ] || mkdir links;
46+
@for script in $(tmpfiles); do \
47+
ln -sf $$script ./links/`grep '//### ' $$script | sed 's/\/\/### //g' | head -1`; \
48+
done;
49+
50+
clean :
51+
rm ./links/*.lsl

src/autohide.lsl

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//### autohide.lsl
2+
list gl_alphaConfig = [
3+
"apollo", "",
4+
"adonis", "",
5+
"ares", "",
6+
"athena", "",
7+
"freya", ""
8+
]
9+
10+
11+
12+
default
13+
{
14+
attach(key id)
15+
{
16+
integer i_mode;
17+
if (id)
18+
{
19+
i_mode = 1;
20+
}
21+
else if (llGetAttached() == 0)
22+
{
23+
i_mode = 2;
24+
}
25+
else
26+
{
27+
return;
28+
}
29+
30+
integer i_count = llGetListLength(gl_alphaConfig);
31+
integer a = 0;
32+
string s_ident;
33+
string s_alpha;
34+
while (a < i_count)
35+
{
36+
s_ident = llList2String(gl_alphaConfig, a);
37+
s_alpha = llList2String(gl_alphaConfig, ++a);
38+
if (s_alpha != "")
39+
{
40+
llRegionSayTo(llGetOwner(), -50, s_ident + ":-" + (string)i_mode + s_alpha);
41+
}
42+
++a;
43+
}
44+
}
45+
}

src/body-single-layer.lsl

+282
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
//### body-alpha.lsl
2+
//indentification string of the mesh body
3+
string gs_ident = "apollo";
4+
//link numbers that get ignored
5+
list gl_ignorePrims = [1];
6+
//setup upper body texture
7+
integer gi_channelUpper = 171800;
8+
string gs_UpperParts = "";
9+
//setup for lower body texture
10+
integer gi_channelLower = 171801;
11+
string gs_LowerParts = "";
12+
13+
setAlphaAll(float alpha)
14+
{
15+
integer a;
16+
integer prim1s = llGetNumberOfPrims();
17+
for( a = 1; a <= prim1s; ++a)
18+
{
19+
if (llListFindList(gl_ignorePrims, (list)a) == -1)
20+
{
21+
llSetLinkPrimitiveParamsFast(a, [PRIM_COLOR, ALL_SIDES, <1.000, 1.000, 1.000>, alpha]);
22+
}
23+
}
24+
}
25+
26+
toggleAlpha(integer num,integer face)
27+
{
28+
list value = llGetLinkPrimitiveParams(num, [PRIM_COLOR,face]);
29+
float alpha = llList2Float(value,1);
30+
vector colore = llList2Vector(value,0);
31+
if(alpha == 0.0)
32+
{
33+
llSetLinkPrimitiveParamsFast(num, [PRIM_COLOR, face, colore, 1]);
34+
}
35+
else
36+
{
37+
llSetLinkPrimitiveParamsFast(num, [PRIM_COLOR, face, colore, 0]);
38+
}
39+
}
40+
41+
string getBase64AlphaString()
42+
{
43+
string s_base64alpha = "";
44+
integer i_prims = llGetNumberOfPrims();
45+
integer a = 0;
46+
integer i_bitCount = 32;
47+
integer i_tempAlphaConf = 0;
48+
integer b;
49+
integer i_mask;
50+
while (a < i_prims)
51+
{
52+
a++;
53+
b = 0;
54+
while (b < 8)
55+
{
56+
--i_bitCount;
57+
if (llList2Float(llGetLinkPrimitiveParams(a, [PRIM_COLOR, b]), 1) != 1.0)
58+
{
59+
i_mask = 0x0000001;
60+
i_mask = i_mask << i_bitCount;
61+
i_tempAlphaConf = i_tempAlphaConf | i_mask;
62+
}
63+
if (i_bitCount == 0)
64+
{
65+
s_base64alpha += llGetSubString(llIntegerToBase64(i_tempAlphaConf), 0, 5);
66+
i_bitCount = 32;
67+
i_tempAlphaConf = 0;
68+
}
69+
++b;
70+
}
71+
}
72+
llRegionSayTo(llGetOwner(), -51, gs_ident + ":+" + s_base64alpha);
73+
return s_base64alpha;
74+
}
75+
76+
readBase64AlphaString(string s_base64alpha, integer mode)
77+
{
78+
//mode:
79+
// 1: Set bits are going to be set to transparency
80+
// 2: Set bits are going to be set to full oppacy
81+
// 3: Set bits are going to be set to transparency,
82+
// unset bist are going to be set to full oppacy
83+
// 4: Set bits will be toggled
84+
integer i_partLength = llStringLength(s_base64alpha) / 6;
85+
integer a = 0;
86+
integer i_tempAlphaConf;
87+
integer i_bitCount;
88+
integer i_totalBitCount = 0;
89+
integer i_prim;
90+
integer i_face;
91+
integer i_alpha;
92+
while (a < i_partLength)
93+
{
94+
i_tempAlphaConf = llBase64ToInteger(llGetSubString(s_base64alpha, a * 6, a * 6 + 5));
95+
i_bitCount = 32;
96+
while (i_bitCount > 0)
97+
{
98+
--i_bitCount;
99+
i_prim = llFloor(i_totalBitCount / 8) + 1;
100+
i_face = i_totalBitCount % 8;
101+
i_alpha = (i_tempAlphaConf >> i_bitCount) & 0x0000001;
102+
if (llListFindList(gl_ignorePrims, (list)i_prim) == -1)
103+
{
104+
if (mode == 1)
105+
{
106+
if (i_alpha)
107+
{
108+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_COLOR, i_face, <1.0, 1.0, 1.0>, 0.0]);
109+
}
110+
}
111+
else if (mode == 2)
112+
{
113+
if (i_alpha)
114+
{
115+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_COLOR, i_face, <1.0, 1.0, 1.0>, 1.0]);
116+
}
117+
}
118+
else if (mode == 3)
119+
{
120+
if (i_alpha)
121+
{
122+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_COLOR, i_face, <1.0, 1.0, 1.0>, 0.0]);
123+
}
124+
else
125+
{
126+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_COLOR, i_face, <1.0, 1.0, 1.0>, 1.0]);
127+
}
128+
}
129+
else if (mode == 4)
130+
{
131+
if (i_alpha)
132+
{
133+
if(llList2Float(llGetLinkPrimitiveParams(i_prim, [PRIM_COLOR, i_face]), 1) == 1.0)
134+
{
135+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_COLOR, i_face, <1.0, 1.0, 1.0>, 0.0]);
136+
}
137+
else
138+
{
139+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_COLOR, i_face, <1.0, 1.0, 1.0>, 1.0]);
140+
}
141+
}
142+
}
143+
}
144+
++i_totalBitCount;
145+
}
146+
a++;
147+
}
148+
}
149+
150+
setTexture(string s_base64alpha, string s_texture)
151+
{
152+
integer i_partLength = llStringLength(s_base64alpha) / 6;
153+
integer a = 0;
154+
integer i_tempPartConf;
155+
integer i_bitCount;
156+
integer i_totalBitCount = 0;
157+
integer i_prim;
158+
integer i_face;
159+
integer i_set;
160+
while (a < i_partLength)
161+
{
162+
i_tempPartConf = llBase64ToInteger(llGetSubString(s_base64alpha, a * 6, a * 6 + 5));
163+
i_bitCount = 32;
164+
while (i_bitCount > 0)
165+
{
166+
--i_bitCount;
167+
i_prim = llFloor(i_totalBitCount / 8) + 1;
168+
i_face = i_totalBitCount % 8;
169+
i_set = (i_tempPartConf >> i_bitCount) & 0x0000001;
170+
if (llListFindList(gl_ignorePrims, (list)i_prim) == -1)
171+
{
172+
if (i_set)
173+
{
174+
llSetLinkPrimitiveParamsFast(i_prim, [PRIM_TEXTURE, i_face, message, <1,1,0>, <0,0,0>, 0]);
175+
}
176+
}
177+
++i_totalBitCount;
178+
}
179+
a++;
180+
}
181+
}
182+
183+
string hexToString(integer bits)
184+
{
185+
string XDIGITS = "0123456789abcdef";
186+
string nybbles;
187+
integer cnt = 0;
188+
while (cnt < 8)
189+
{
190+
integer lsn = bits & 0xF; // least significant nybble
191+
string nybble = llGetSubString(XDIGITS, lsn, lsn);
192+
nybbles = nybble + nybbles;
193+
bits = bits >> 4; // discard the least significant bits at right
194+
bits = bits & 0xfffFFFF; // discard the sign bits at left
195+
cnt++;
196+
}
197+
nybbles = "0x" + nybbles;
198+
return nybbles;
199+
}
200+
201+
default
202+
{
203+
state_entry()
204+
{
205+
llListen(-50,"","","");
206+
llListen(gi_channelUpper, "", "", "");
207+
llListen(gi_channelLower, "", "", "");
208+
//setAlphaAll(1.0);
209+
210+
}
211+
listen(integer channe, string name, key id, string message)
212+
{
213+
key ownerOfThisObject = llGetOwner();
214+
key ownerOfSpeaker = llGetOwnerKey(id);
215+
if (ownerOfSpeaker != ownerOfThisObject)
216+
{
217+
return;
218+
}
219+
220+
if (channe == gi_channelUpper)
221+
{
222+
if (gs_UpperParts == "")
223+
{
224+
return;
225+
setTexture(gs_UpperParts, message);
226+
}
227+
}
228+
if (channe == gi_channelLower)
229+
{
230+
if (gs_LowerParts == "")
231+
{
232+
return;
233+
setTexture(gs_LowerParts, message);
234+
}
235+
}
236+
237+
if (llSubStringIndex(message, gs_ident) != 0)
238+
{
239+
return;
240+
}
241+
else
242+
{
243+
message = llGetSubString(message, llStringLength(gs_ident) + 1, -1);
244+
}
245+
246+
if (llSubStringIndex(message, "getalpha") == 0)
247+
{
248+
string s_config = getBase64AlphaString();
249+
llRegionSayTo(ownerOfThisObject, 0, "Current Alpha String:\n" + s_config);
250+
}
251+
252+
if (llSubStringIndex(message, "updatealpha") == 0)
253+
{
254+
getBase64AlphaString();
255+
}
256+
257+
string definizione=llGetSubString(message,0,0);
258+
259+
if (definizione == "-")
260+
{
261+
integer i_mode = (integer)llGetSubString(message, 1, 1);
262+
string s_base64Alpha = llGetSubString(message, 2, -1);
263+
readBase64AlphaString(s_base64Alpha, i_mode);
264+
getBase64AlphaString();
265+
}
266+
267+
if (message == "Reset")
268+
{
269+
setAlphaAll(1.0);
270+
getBase64AlphaString();
271+
}
272+
273+
274+
if (definizione == "P")
275+
{
276+
integer i_linkNumber = (integer)llGetSubString(message, 1, -2);
277+
integer i_faceNumber = (integer)llGetSubString(message, -1, -1);
278+
toggleAlpha(i_linkNumber,i_faceNumber);
279+
}
280+
}
281+
}
282+

0 commit comments

Comments
 (0)