Jump to content

Counting time in % script needed


Guest
 Share

You are about to reply to a thread that has been inactive for 2654 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello!

I'd need a script for animations that counts in % from 0% to 100% which displays the progression in a hovertext. This 100% should be a time going from 2 to 5 minutes, which is set on an editable notecard or in the script itself. When the % reaches the 100% the avatar sitting on the poseball or the object should be able to stand up automatically.

Let me give you an example: let's say i have a painting that needs to be cleaned for a roleplay. The avatar sits on the painting, getting a duster to dust, the cleaning animation starts and while the avatar is sitting on the painting the %, stated in a red hovertext, runs towards the 100%. Once it gets there, the "timer" should warn the avatar in local chat that the job is done and a green hoverext displays 100%. Then he automatically could stand. If the avatar stands before reaching 100% the % would remain fixed, let's say for example i stand when the hovertext says 66%. So when i sit again it starts counting from 66% and not 0%. 

I'd like to know if something like this can be scripted and how much it would cost me. I can show you IW something that is similar to what i need.

Thank you in advance!

Link to comment
Share on other sites

I wrote this, it appears to work(with the ability to add custom functions such as llSay, if you want):

//Insert custom functions here//Called once every progress tickonProgress(){    }//Called when 100% is reachedonFinished(){
llSetText(satMessage+"\n100%", <0, 1, 0>, 1);
llWhisper(0, "Task finished!"); llUnSit(currentAgent);
//If you wish to delay when the task can be done again, you can use sleep.
//Uncomment this line and it will wait 10 seconds before the task can be done again:
//llSleep(10);}//Called when starting/continuingonStart(){ }//Notecard readerkey ncReq;integer ncLine;ncRead(){ llSetText("Reading notecard...", <1,1,0>, 1); if(llGetInventoryType("config") == INVENTORY_NONE){ llSetText("MISSING NOTECARD!", <1,0,0>, 1); llOwnerSay("ERROR: Missing a notecard named \"config\".\n" +"Please create this notecard and set the contents to:\n" +"animation = someAnimation //Animation to play when sat upon." +"timeBetweenPercentages = 1 //Seconds between percentages. A value of 1 means one percent per second\n" +"color = <R, G, B> // Color for the floating text, for red: <255, 0, 0>\n" +"unsatMessage = //Text to display if no one is sitting, leave empty for nothing.\n" +"satMessage = //Text to display if someone is sitting, leave empty for nothing."); }else{ llOwnerSay("Reading notecard, please wait..."); llSetTimerEvent(0); percentage = 0; animation = "stand"; timeBetweenPercentage = 0; ncReq = llGetNotecardLine("config", ncLine = 0); }}ncLoadKeyValue(string Key, string Value){ if(Key == "animation"){ animation = Value; }else if(Key == "timeBetweenPercentages"){ timeBetweenPercentage = (float)Value; }else if(Key == "color"){ vector tmp = (vector)Value; textColor = <tmp.x/255.0, tmp.y/255.0, tmp.z/255.0>; }else if(Key == "unsatMessage"){ unsatMessage = Value; }else if(Key == "satMessage"){ satMessage = Value; }}ncFinished(){ llSetText(unsatMessage+"\n"+(string)percentage+"%", textColor, 1); llOwnerSay("Finished!");}//Internal stuffinteger percentage = 0;float timeBetweenPercentage = 0;key animation;key currentAgent;vector textColor = <1, 0, 0>;string unsatMessage = "";string satMessage = "";default{ //Run once state_entry(){ ncRead(); llSitTarget(<0,0,0.00001>, <0,0,0,0>); } timer(){ percentage++; if(percentage >= 100){ onFinished(); percentage = 0; }else{ onProgress(); } llSetText(satMessage+"\n"+(string)percentage+"%", textColor, 1); } changed(integer c){ if(c&CHANGED_INVENTORY){ //Reload the notecard ncRead(); }else if(c&CHANGED_LINK){ key newUser = llAvatarOnSitTarget(); if(newUser){ //If someone is sitting if(currentAgent != newUser){ llRequestPermissions(newUser, PERMISSION_TRIGGER_ANIMATION); llSetTimerEvent(timeBetweenPercentage); onStart(); llSetAlpha(0, ALL_SIDES); } }else{ if(llGetPermissions()){ llStopAnimation(animation); } llSetText(unsatMessage+"\n"+(string)percentage+"%", textColor, 1); llSetAlpha(1, ALL_SIDES); llSetTimerEvent(0); } currentAgent = newUser; } } run_time_permissions(integer p){ if(p){ llStopAnimation("sit"); llStartAnimation(animation); } } dataserver(key req, string data){ if(req == ncReq){ //Remove any // text if(data != EOF){ data = llList2String(llParseString2List(data, [" \/\/","\/\/"], []),0); list kv = llParseString2List(data, [], [" = ", "= ", " =, "=]); string Key = llList2String(kv, 0); string Value = llDumpList2String(llList2List(kv, 2, -1), ""); ncLoadKeyValue(Key, Value); //If not EOF, then continue reading lines ncReq = llGetNotecardLine("config", ++ncLine); }else{ ncFinished(); } } }}

Notecard configuration template:

//Make sure that you do not add any extra spaces at the end of the values or it might error.//Animation to play when sat upon.animation = stand//Seconds between percentages. A value of 1 means one percent per secondtimeBetweenPercentages = 0.1//Color for the floating text, for red: <255, 0, 0>color = <255, 0, 0>//(OPTIONAL)Text to display if no one is sitting, leave empty for nothing.unsatMessage = Testing 123//(OPTIONAL)Text to display if someone is sitting, leave empty for nothing.satMessage = Doing 123

Elements with (OPTIONAL) can be removed entirely from the notecard configuration and will presume "", 0, or what ever is a empty value.

Hope this works for you!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2654 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...