Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Calculator Jontte_Gremlins_calculator_script  

Jontte_Gremlins_calculator_script

Jontte_Gremlins_calculator_script

Category: Calculator
By : Nitsuj Kidd
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Jontte_Gremlins_calculator_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Jontte_Gremlins_calculator_script_1.lsl
1 //Created by Jontte Gremlin
2 //All rights reserved
3 //Open sourced with permission by Alpha Zaius and tag written by Alpha himself.
4 list datalist;
5 list temporary;
6 list templist;
7 string start;
8 integer i;
9 integer number;
10 integer number2;
11 integer greturn;
12 list variables;
13 calculate()
14 {
15 greturn=0;
16 if(llListFindList(datalist,["("])!=-1)
17 {
18 for(i=0;i<llGetListLength(datalist);i++)
19 {
20 if(llList2String(datalist,i)=="(")
21 {
22 number=i;
23 }
24 if(llList2String(datalist,i)==")")
25 {
26 number2=i;
27 i=llGetListLength(datalist);
28 }
29 }
30 templist=datalist;
31 if(number2<number)
32 {
33 llOwnerSay("Could not calculate.");
34 datalist=[];
35 return;
36 }
37 datalist=llList2List(datalist,number + 1 ,number2 - 1 );
38 greturn=1;
39 }
40 if(llListFindList(datalist,["^"])!=-1)
41 {
42 temporary=[];
43 for(i=0;i<llGetListLength(datalist);i++)
44 {
45 if(llList2String(datalist,i + 1)=="^")
46 {
47 temporary+=(string)( llPow(((float)llList2String(datalist,i)),((float)llList2String(datalist,i + 2)) ));
48 i+=2;
49 }
50 else
51 {
52 temporary+=llList2String(datalist,i);
53 }
54 }
55 datalist=temporary;
56 }
57
58 if(llListFindList(datalist,["/"])!=-1)
59 {
60 temporary=[];
61 for(i=0;i<llGetListLength(datalist);i++)
62 {
63 if(llList2String(datalist,i + 1)=="/")
64 {
65 if((float)llList2String(datalist,i + 2)==0)
66 {
67 llOwnerSay("Could not calculate.");
68 datalist=[];
69 temporary=[];
70 return;
71 }
72 temporary+=(string)( (((float)llList2String(datalist,i))/((float)llList2String(datalist,i + 2)) ));
73 i+=2;
74 }
75 else
76 {
77 temporary+=llList2String(datalist,i);
78 }
79 }
80 datalist=temporary;
81 }
82
83 if(llListFindList(datalist,["*"])!=-1)
84 {
85 temporary=[];
86 for(i=0;i<llGetListLength(datalist);i++)
87 {
88 if(llList2String(datalist,i + 1)=="*")
89 {
90 temporary+=(string)( (((float)llList2String(datalist,i))*((float)llList2String(datalist,i + 2)) ));
91 i+=2;
92 }
93 else
94 {
95 temporary+=llList2String(datalist,i);
96 }
97 }
98 datalist=temporary;
99 }
100
101 if(llListFindList(datalist,["-"])!=-1)
102 {
103 temporary=[];
104 for(i=0;i<llGetListLength(datalist);i++)
105 {
106 if(llList2String(datalist,i + 1)=="-")
107 {
108 temporary+=(string)( (((float)llList2String(datalist,i)) - ((float)llList2String(datalist,i + 2)) ));
109 i+=2;
110 }
111 else
112 {
113 temporary+=llList2String(datalist,i);
114 }
115 }
116 datalist=temporary;
117 }
118 if(llListFindList(datalist,["+"])!=-1)
119 {
120 temporary=[];
121 for(i=0;i<llGetListLength(datalist);i++)
122 {
123 if(llList2String(datalist,i + 1)=="+")
124 {
125 temporary+=(string)( (((float)llList2String(datalist,i)) + ((float)llList2String(datalist,i + 2)) ));
126 i+=2;
127 }
128 else
129 {
130 temporary+=llList2String(datalist,i);
131 }
132 }
133 datalist=temporary;
134 }
135 if(greturn==1)
136 {
137 temporary=[];
138 if(number - 1 > 0)
139 {
140 temporary+=llList2List(templist,0,number - 1);
141 }
142 temporary+=datalist;
143 if(number2 + 1 < llGetListLength(templist))
144 {
145 temporary+=llList2List(templist,number2+1,-1);
146 }
147 datalist=temporary;
148 }
149 }
150 default
151 {
152 link_message(integer sender_num, integer num, string msg, key id)
153 {
154 datalist=llParseString2List(msg,[" "],[]);
155 if(llList2String(datalist,0)=="hdfdfuureihue")
156 {
157 if(llListFindList(variables,[llList2String(datalist,1)])==-1)
158 {
159 variables+=llList2String(datalist,1);
160 variables+=llList2String(datalist,2);
161
162
163 llOwnerSay(llDumpList2String(variables,"\n"));
164 return;
165 }
166 else
167 {
168 i=llListFindList(variables,[llList2String(datalist,1)]);
169 variables=llListReplaceList(variables,[llList2String(datalist,2)],i +1 ,i +1);
170
171
172 llOwnerSay(llDumpList2String(variables,"\n"));
173 return;
174 }
175 }
176 if(msg=="var")
177 {
178 llOwnerSay(llDumpList2String(variables,"\n"));
179 return;
180 }
181 if(llList2String(datalist,0)!="/calc")return;
182 msg=llGetSubString(msg,5,-1);
183 start=msg;
184 datalist=llParseString2List(msg,[],["+","-","*","/","^","(",")"]);
185 number = 0;
186 number2 =0;
187 for(i=0;i<llGetListLength(datalist);i++)
188 {
189 if(llList2String(datalist,i)=="(")
190 {
191 number++;
192 }
193 if(llList2String(datalist,i)==")")
194 {
195 number2++;
196 }
197 }
198 if(number!=number2)
199 {
200 llOwnerSay("Could not calculate.");
201 return;
202 }
203 for(i=0;i<llGetListLength(variables);i+=2)
204 {
205 number=llListFindList(datalist,[llList2String(variables,i)]);
206 if(number!=-1)
207 {
208 datalist=llListReplaceList(datalist,[(float)llList2String(variables,i + 1)],number,number);
209 }
210 }
212 {
213 calculate();
214 }
215 if(llGetListLength(datalist)!=0)
216 {
217 llOwnerSay(start+" = "+llList2String(datalist,0));
218 }
219 }
220 }

Back to the Best Free Tools in Second Life and OpenSim.