LuckyCreations1488303085 Posted April 16, 2011 Share Posted April 16, 2011 I am working on a script that I can place inside an object that will delete the object after a specified period of time. I don't know too much about scripting, but was able to come up with this after looking around the lsl wiki. default { on_rez(integer start_param) { llSetTimerEvent(300); llOwnerSay("This is a demo, you have 5 minutes before it will automatically delete itself."); } timer() { llOwnerSay("Your trial has ended."); llDie(); } } The above script works well, but I was wondering how I could make the script update the user on the amount of time left on the demo. For example, at the 4 minute mark, it will say, "You have 4 minutes remaining." And it would continue to do this every minute until the time is up. I would also like it to update at the 30 second, 10 second, and 5 second marks. Would someone be able to help me accomplish this?Thanks,Lucky Link to comment Share on other sites More sharing options...
Void Singer Posted April 16, 2011 Share Posted April 16, 2011 list gLstTime =["5 minutes", 60, "4 minutes", 60, "3 minutes", 60, "2 minutes", 60, "1 minutes", 30, "30 seconds", 20, "10 seconds", 5, "5 seconds", 5, "Times up", 0];integer gIntTrack = 1;//-- some codetimer(){ ++gIntTrack; llOwnerSay( llList2String( gLstTime, gIntTrack ) ); ++gIntTrack; llSetTimerEvent( llList2Float( gLstTime, gIntTrack ) ); if (llList2Integer( gLstTime, gIntTrack ) == 0){ llDie(): }} this of course does not prevent anyone from resetting the script, removing it, or using it in a no script area, or attaching it to prevent it from dying. Link to comment Share on other sites More sharing options...
LuckyCreations1488303085 Posted April 16, 2011 Author Share Posted April 16, 2011 Thanks for your reply Void, I am not sure if I am supposed to use what you supplied as the script, or do I implement that into my script? I tried just using what you gave me in a script, but it gave a syntax error, and I am not sure how I would implement that into my script if that is what I am supposed to do. Link to comment Share on other sites More sharing options...
Void Singer Posted April 16, 2011 Share Posted April 16, 2011 the supplied variables go in the top, the timer event replaces your owner timer event, all that's left is to add the code to read the first list item and send it to the user as a message, and set the timer for the amount of time in the list at the index given in gIntTrack...... you can do that in the state entry, but really it should be done when the owner changes, or they'll miss the first message. Link to comment Share on other sites More sharing options...
LuckyCreations1488303085 Posted April 16, 2011 Author Share Posted April 16, 2011 Thank you Void. I have it up and running now. Works great! I like how the user is able to take the item back into their inventory, and then when they take it back out, it will continue counting down from where it left off. As for them using the demo in an area that doesnt allow running scripts, I plan on marking the item with demo textures and make it no mod/no copy/no transfer and maybe that will make it less appealing to keep the demo instead of buying the real thing. And as for the user wearing the item - I plan on using this script in houses (since I don't have land to display the houses in world), so I don't think the user will be wanting to wear the house. Link to comment Share on other sites More sharing options...
Void Singer Posted April 16, 2011 Share Posted April 16, 2011 they only have to wear it when it tries to die Link to comment Share on other sites More sharing options...
LuckyCreations1488303085 Posted April 16, 2011 Author Share Posted April 16, 2011 Ah, that is true... I went on the lsl wiki and found an llDetachFromAvatar example and added it to my script. So now it automatically detaches when the user tries to attach it. http://wiki.secondlife.com/wiki/LlDetachFromAvatar Link to comment Share on other sites More sharing options...
Tinkarbell Posted May 4, 2021 Share Posted May 4, 2021 Reviving an old thread I know. Could I use on_attach instead of on_rez to use this for clothing demos? Link to comment Share on other sites More sharing options...
Quarrel Kukulcan Posted May 5, 2021 Share Posted May 5, 2021 (edited) 6 hours ago, Tinkarbell said: Reviving an old thread I know. Could I use on_attach instead of on_rez to use this for clothing demos? According to the wiki, yes. It's arguably better, too, though there are more cases you need to test for to make sure you don't count them if you don't need to. (P.S. It's "attach", not "on_attach".) on_rez() triggers when the object goes from "not existing in world" to "existing in world". That means: dragging into the world from inventory attaching from inventory logging in with the object already attached attach() triggers when the object becomes attached or detached. That means: attaching from inventory, OR detaching into inventory attached from existing on the ground, OR dropped directly from being worn logging in with the object already attached Edited May 5, 2021 by Quarrel Kukulcan Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted May 5, 2021 Share Posted May 5, 2021 58 minutes ago, Quarrel Kukulcan said: sitting on the object OR standing up from it This won't trigger attach, but will trigger changed (CHANGED_LINK). 1 Link to comment Share on other sites More sharing options...
Quarrel Kukulcan Posted May 5, 2021 Share Posted May 5, 2021 42 minutes ago, Wulfie Reanimator said: This won't trigger attach, but will trigger changed (CHANGED_LINK). Thanks. I could have sworn I'd read that in the wiki. I'm thinking now it was a bad comment in an old script. Link to comment Share on other sites More sharing options...
Tinkarbell Posted May 5, 2021 Share Posted May 5, 2021 ok thanks , I'll give it a try. 1 Link to comment Share on other sites More sharing options...
Mayumi Hirano Posted May 5, 2021 Share Posted May 5, 2021 Try this one. https://pastebin.com/UzJR8v6S Link to comment Share on other sites More sharing options...
Tinkarbell Posted May 6, 2021 Share Posted May 6, 2021 It looks good thanks. would you be able to translate it into English? Link to comment Share on other sites More sharing options...
Recommended Posts
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