The following two scripts implement a spinner using llSetText
without destroying the text that is already displayed. This may be useful for providing a visual feedback that the script is working or making progress.
Drop the two scripts bellow in a primitive and touch the primitive for the spinner to rotate.
The spinner script listens for link messages:
link_message(integer sender_num, integer num, string str, key id)
and will spin num
characters forward once a message is received. For example, to make the spinner rotate 8
times, send the following link message to the primitive where the spinner script is placed:
llMessageLinked(LINK_THIS, 8, "spin", "");
////////////////////////////////////////////////////////// // WaS (c) grimore.org - 2012, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// default { state_entry() { llSetText("Touch to spin...", <1,1,1>, 1); } touch(integer num) { llMessageLinked(LINK_THIS, 1, "spin", ""); } }
////////////////////////////////////////////////////////// // WaS (c) grimore.org - 2012, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // ////////////////////////////////////////////////////////// list spinChars = [ "↑", "↗", "→", "↘", "↓", "↙", "←", "↖" ]; default { link_message(integer sender_num, integer num, string str, key id) { if(str != "spin") return; @start; string text = llList2String(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXT]), 0); do { string tok = llGetSubString(text, llStringLength(text)-1, llStringLength(text)-1); if(llListFindList(spinChars, (list)tok) == -1 && tok != "\n" && tok != "[" && tok != "]") jump show; text = llDeleteSubString(text, llStringLength(text)-1, llStringLength(text)-1); } while(llStringLength(text)); @show; string next = llList2String(spinChars, 0); spinChars = llDeleteSubList(spinChars, 0, 0); spinChars += next; llSetText(text + "\n" + "[" + next + "]", <1,1,1>, 1); if(--num > 0) jump start; } }
The following function will rotate the spinner once and can be used separately in scripts.
list spinChars = [ "↑", "↗", "→", "↘", "↓", "↙", "←", "↖" ]; string spin() { string text = llList2String(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXT]), 0); do { string tok = llGetSubString(text, llStringLength(text)-1, llStringLength(text)-1); if(!~llListFindList(spinChars, (list)tok) && tok != "\n" && tok != "[" && tok != "]") jump show; text = llDeleteSubString(text, llStringLength(text)-1, llStringLength(text)-1); } while(llStringLength(text)); @show; string next = llList2String(spinChars, 0); spinChars = llDeleteSubList(spinChars, 0, 0); spinChars += next; return "[" + next + "]"; }
To make the spinner move one step forward, call:
spin()
which returns [↗] where ↗ is the next position of the arrow.
For other spinner art that could be used instead of the arrows, please see the spinner character art page.
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.