17 April 2013
This texture cycler is able to turn pages forwards and backwards depending on the coordinate where the primitive it resides in is touched.
The primitive that the script resides in is placed in the screen itself as can be seen in the illustration above. The screen is divided in half so that llDetectedTouchST
reports:
y=0
on the right-most side of the screen.y=.5
in the middle of the screen.y=1
on the left-most side of the screen.
Thus any touch on the screen so that y>.5
will be considered a backwards page turn and any touch so that y<.5
will be considered a forwards turn.
page=0
.
/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// string wasKeyValueGet(string var, string kvp) { list dVars = llParseString2List(kvp, ["&"], []); do { list data = llParseString2List(llList2String(dVars, 0), ["="], []); string k = llList2String(data, 0); if(k != var) jump continue; return llList2String(data, 1); @continue; dVars = llDeleteSubList(dVars, 0, 0); } while(llGetListLength(dVars)); return ""; } /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// string wasKeyValueSet(string var, string val, string kvp) { list dVars = llParseString2List(kvp, ["&"], []); if(llGetListLength(dVars) == 0) return var + "=" + val; list result = []; do { list data = llParseString2List(llList2String(dVars, 0), ["="], []); string k = llList2String(data, 0); if(k == "") jump continue; if(k == var && val == "") jump continue; if(k == var) { result += k + "=" + val; val = ""; jump continue; } string v = llList2String(data, 1); if(v == "") jump continue; result += k + "=" + v; @continue; dVars = llDeleteSubList(dVars, 0, 0); } while(llGetListLength(dVars)); if(val != "") result += var + "=" + val; return llDumpList2String(result, "&"); } default { touch_start(integer num) { integer page = (integer)wasKeyValueGet("page", llGetObjectDesc()); vector p = llDetectedTouchST(0); if(p.y > .5) jump back; if(page+1 > llGetInventoryNumber(INVENTORY_TEXTURE)-1) return; llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, ++page), 0); llSetObjectDesc(wasKeyValueSet("page", (string)page, llGetObjectDesc())); return; @back; if(page-1 < 0) return; llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, --page), 0); llSetObjectDesc(wasKeyValueSet("page", (string)page, llGetObjectDesc())); } }