Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer display=0;
- integer total=0;
- string flag="";
- integer clean=0;
- string ASCII = " \n !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
- integer ord(string chr)
- {
- if(llStringLength(chr) != 1) return -1;
- if(chr == " ") return 32;
- return llSubStringIndex(ASCII, chr);
- }
- string chr(integer i)
- {
- i %= 127;
- return llGetSubString(ASCII, i, i);
- }
- render()
- {
- string s=(string)display;
- llMessageLinked(LINK_SET,100,s,NULL_KEY);
- // llSay(0,"display: "+(string)display+" total: "+(string)total+" flag: "+flag+" clean: "+(string)clean);
- }
- default
- {
- state_entry()
- {
- integer i;
- for(i=1;i<=llGetNumberOfPrims();i++)
- {
- string n=llGetLinkName(i);
- // llSay(0,"n: "+n+" l: "+(string)llStringLength(n));
- if(llStringLength(n)<3)
- {
- llSetLinkPrimitiveParamsFast(i,[ PRIM_TEXT, " ", <1,1,1>, 1]);
- }
- }
- total=-1;
- display=0;
- render();
- }
- touch_start(integer count)
- {
- integer link=llDetectedLinkNumber(0);
- string n=llGetLinkName(link);
- if(ord(n)>=ord("0") && ord(n)<=ord("9"))
- {
- if(clean==1) display=0;
- display=display*10+(integer)n;
- clean=0;
- }
- else
- if(n=="C"){
- display=0; total=-1;
- flag="";
- clean=0;
- }
- else
- if(n=="AC"){
- total=-1;
- display=0;
- flag="";
- clean=0;
- }
- else
- if(n=="+")
- {
- flag="+";
- if(total==-1) total=display;
- clean=1;
- }
- else
- if(n=="-")
- {
- flag="-";
- if(total==-1) total=display;
- clean=1;
- }
- else
- if(n=="*")
- {
- flag="*";
- if(total==-1) total=display;
- clean=1;
- }
- else if(n=="/")
- {
- flag="/";
- if(total==-1) total=display;
- clean=1;
- }
- else if(n=="=")
- {
- if(flag=="+") total+=display;
- else if(flag=="-") total-=display;
- else if(flag=="*") total*=display;
- else if(flag=="/"){
- if(display!=0) total/=display;
- }
- display=total;
- clean=1;
- }
- render();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement