Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================================================
- // SLANTIX SCORING FRAME 2.2 by rory torrance
- //=== sizer ==================================================================================================
- float TS = 0.04; // tile size
- float HS = 0.02; // half tile size
- integer max = 38; // biggest size for frame
- vector Size; // current size of frame
- float SX; float SY; // last size of frame
- integer XX; integer YY; // size in spaces
- float SZ = 0.04; // height of frame stays the same
- float scale = 25; // factor to make ideal tile size = 1
- vector myPos; // current position of tile
- float margin = 0.95; // physical margin size
- float marg1 = 0.1; // low limit of control margin
- float marg2 = 0.9; // hi limit of control margin
- vector Tcolr = <1, 1, 0.75>; // color of display text
- //==== score =================================================================================================
- integer Symmetry = 1; // default score variables
- integer Floors = 1;
- integer Rooms = 1;
- integer Tiles = 1;
- //==== input =================================================================================================
- integer listenHandle; // input handler
- integer Chanl = 99;
- string Result = "empty"; // results string
- //============================================================================================================
- default // regular mode in which you adjust the frame size
- { state_entry()
- { Size = llGetScale(); // get size of frame prim
- SX = Size.x*margin; // extract true x size of frame by shinking slightly
- SY = Size.y*margin; // extract true y size of frame
- XX = (integer)(SX*scale); // find width in spaces
- YY = (integer)(SY*scale); // find height in spaces
- }
- touch_start(integer num) // give instructions
- { integer Face = llDetectedTouchFace(0); // which face was touched
- vector Place = llDetectedTouchST(0); // where it was touched
- float PX = Place.x; // separate out the x part
- float PY = Place.y; // separate out the y part
- myPos = llGetPos(); // check the tile's position
- if (Face == 0) // +z // if its the front face
- { if ( PX >= marg2 ) // right
- { if (( PY >= marg1 ) && ( PY < 0.5)) // lo mid R
- { LESSX(<-HS, 0.0, 0.0>); }
- else if (( PY >= 0.5 ) && ( PY <= marg2)) // hi mid R
- { MOREX(<HS, 0.0, 0.0>); }
- else { state inputter; } // input variables
- }
- else if( PX <= 0.05 ) // left
- { if (( PY >= marg1 ) && ( PY <= 0.5)) // lo mid L
- { LESSX(<HS, 0.0, 0.0>); }
- else if (( PY >= 0.5 ) && ( PY <= marg2)) // hi mid L
- { MOREX(<-HS, 0.0, 0.0>); }
- else { state inputter; } // input variables
- }
- else if ( PY >= marg2 ) // top
- { if (( PX > marg1 ) && ( PX <= 0.5)) // L top
- { LESSY(<0.0, -HS, 0.0>); }
- else if (( PX > 0.5 ) && ( PX < marg2)) // R top
- { MOREY(<0.0, HS, 0.0>); }
- }
- else if ( PY <= marg1 ) // bottom
- { if (( PX > marg1 ) && ( PX <= 0.5)) // L botm
- { LESSY(<0.0, HS, 0.0>); }
- else if (( PX > 0.5 ) && ( PX < marg2)) // R botm
- { MOREY(<0.0, -HS, 0.0>); }
- }
- }
- }
- }
- //============================================================================================================
- MOREX(vector P) // increment frame X
- { if (XX < max) // if not too big
- { XX++; finish(P); } // set position & scale
- }
- //============================================================================================================
- MOREY(vector P) // increment frame Y
- { if (YY < max) // if not too big
- { YY++; finish(P); } // set position & scale
- }
- //============================================================================================================
- LESSX(vector P) // decrement frame X
- { if (XX > 1) // if not too small
- { XX--; finish(P); } // set position & scale
- }
- //============================================================================================================
- LESSY(vector P) // decrement frame Y
- { if (YY > 1) // if not too small
- { YY--; finish(P); } // set position & scale
- }
- //============================================================================================================
- finish(vector P) // set position & scale
- { SX = XX/scale; SY = YY/scale; // convert spaces to metric
- Size = <SX/margin, SY/margin, SZ>; // adjust to outside of tiles
- llSetScale(Size); // set the scale
- llSetPos( myPos + P ); // move the frame
- }
- //============================================================================================================
- integer contains(string haystack, string needle) // finds substring in string
- { return ~llSubStringIndex(haystack, needle); // & returns it
- }
- //============================================================================================================
- state inputter // mode in which you may input the score variables
- { state_entry() // give instructions
- { integer listenHandle = llListen(Chanl, "", NULL_KEY, "");
- llWhisper(0, "Listening now on channel " + (string)Chanl + " \n"
- + "Say ON, OFF, BLANK to control text, or say\n"
- + "{slash Chanl space} tile-count, sym-level, # floors, # rooms."
- + "\nSeparate digits by commas, no spaces");
- }
- listen(integer channel, string name, key id, string message)
- { if (channel == Chanl) // if its the right channel
- { llWhisper(0, "You said "+ message); // repeat the message to the user
- if ( (message == "on") || (message == "ON") ) // ON turns on text display
- { llSetText( Result, Tcolr, 1.0); } // display text
- else if ( (message == "off") || (message == "OFF") ) // OFF turns off text display
- { llSetText( "", < 0.0, 0.0, 0.0 >, 1.0); } // display NO text
- else if ( (message == "blank") || (message == "BLANK") ) // BLANK resets text display
- { string Result = "empty"; // reset results string
- llSetText( Result, Tcolr, 1.0); // display text
- }
- else if (contains( message, ",")) // finds first comma if its score input
- { integer Index1 = llSubStringIndex(message, ","); // set marker there
- string Rem1 = llGetSubString(message, Index1+1, -1); // save rest of message
- string Targ = llGetSubString(message, 0, Index1-1); // get 1st[,] & string up "tile count"
- Tiles = (integer)Targ; // save as TILES
- if (contains(Rem1, ",")) // look for next comma
- { integer Index2 = llSubStringIndex(Rem1, ","); // set marker there
- string Rem2 = llGetSubString(Rem1, Index2+1, -1); // save rest of text,
- Targ = llGetSubString(Rem1, 0, Index2-1); // save next as target
- Symmetry = (integer)Targ; // save as SYM LEVEL
- if (contains(Rem2, ",")) // look for next comma
- { integer Index3 = llSubStringIndex(Rem2, ","); // set marker there
- string Rem3 = llGetSubString(Rem2, Index3+1, -1); // save rest of text
- Targ = llGetSubString(Rem2, 0, Index3-1); // save next as target
- Floors = ((integer)Targ); // save as FLOORS
- Rooms = ((integer)Rem3); // save rest as ROOMS
- } }
- integer Score = Tiles*Symmetry*Floors*Rooms; // <<<<<<<< EDIT FORMULA HERE <<
- Result = "Tiles=" + (string)Tiles +"\n"+
- "Sym.Levl=" + (string)Symmetry +"\n"+
- "Floors=" + (string)Floors + "\n"+
- "Rooms=" + (string)Rooms + "\n"+
- "SCORE=" + (string)Score;
- llSetText( Result, Tcolr, 1.0); // put results in display text
- } }
- llListenRemove(listenHandle); // remove listen handles
- state default;
- } }
- //============================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement