Difference between revisions of "User:Kira Komarov/Trick or Treat"

From Second Life Wiki
Jump to navigation Jump to search
m
m
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
=Tricks used in this Script (Developers)=
{{delete|Redundant now since the same content can be found under [[Wizardry and Steamworks]]}}
 
==[[The Stash (Bank)]]==
 
There are a number of problems that I got around while writing this script. You can also find them at [[User:Kira Komarov/Trick or Treat]].
 
* '''There is no way to get the amount of L$ your avatar has on itself.'''
 
One way around that, is to pay an amount into an object and count the money using money(). Not only will the script now be aware of the money, but you can thereby implicitly set a limit. Neat!
 
* '''Dang! I already used up the timer() event.'''
 
Use llSensorRepeat() with some ridiculous parameters (initially I was searching for Philip Linden's key in a 0.1 range) and a repeat time of your desired time. Since the llSensorRepeat() is crafted to fail and trigger no_sensor() all the time it runs, you can use no_sensor() as your timer() equivalent. In fact with llSensorRemove() you can have your llSetTimerEvent(0) call.
 
Here is a pragmatic equivalence table (NUMBER is the number of seconds, replace with a value):
<pre>
llSetTimerEvent(NUMBER) <=> llSensorRepeat("", NULL_KEY, AGENT, 0.1, 0.1, NUMBER)
timer() <=> no_sensor()
llSetTimerEvent(0) <=> llSensorRemove()
</pre>
 
Now you have freed up the timer() event, effectively having two timers. Neat!
 
* '''Heap protection. Adding and adding stuff to lists will eventually make the stack collide with the heap.'''
 
Ideally, you could measure the amount of free memory and flush those lists when it becomes critically low. Since we are unable to do that reliably, you can just flush them after a certain period of time and size. For example, this script will check every 60 seconds if the DONORS and RETRIEVERS lists are over 25 elements and flush them if they are.
 
This should be kept in mind for logging scripts which continuously add to the heap. Eventually, if there is no upper limit on the data, the script will crash.
 
* '''Using llSetTimerEvent() as alarm() for adaptive timeouts.'''
 
System programmers might have used before alarm() (man alarm) to constantly reschedule the sending of SIGALRM to a process. This effectively reschedules a timer and is meant for adaptively determining whether an operation has succeeded or not. This script uses llSetTimerEvent() and reschedules the removal of the channel handle of llListen() every time it receives user input. This way, the script will not time-out the channel after a set predetermined time, but rather after the last input from the user has been received.

Latest revision as of 00:30, 29 August 2012

Deletion Requested
The deletion of this article was requested for the following reason:

Redundant now since the same content can be found under Wizardry and Steamworks

If there is a need to discuss the deletion of this article, please add your comment(s) here.


@Admin: Please read the discussion before deleting the article.