A common problem is that you have several activities being managed, and each one needs code in a number of events. Sometimes multiple scripts helps, but a) this adds to sim load, and b) if activities need to share global variables this gets very hairy very quickly.
What I would like is to be able to put all the code for a given activity in one place for each state. This would make it much easier to understand which chunk is doing which task, and waay much easier to debug when a particular feature mis-behaves.
What this needs is to allow multiple instances of each event within a state. These should be concatenated, so that
default
{
state_entry()
{
llOwnerSay("Hello"
;}
state_entry()
{
llOwnerSay("Hello again"
;}
}
is the same as:
default
{
state_entry()
{
llOwnerSay("Hello"
;llOwnerSay("Hello again"
;}
}
(at the moment, the first version doesn't even throw an error -- it just silently overwrites the first event handler code with the second version)
The reason I wanted this was to allow me to do stuff like ...
integer up_time; // in minutes
default
{
//************ Greeting code **************
state_entry()
{
llSay(0,"Hello"
;}
touch_start(integer total_number)
{
llSay(0,"I've been touched"

}
// ************ up-time code **************
state_entry()
{
llTimerStart(60.0);
}
timer()
{
up_time+=1;
}
touch_start(integer total_number)
{
llSay(0,"I've been up "+(string)up_time+" minutes"
;}
}
OK, that's a trivial example, but you get the idea.
An interesting side-effect of this approach is that it would be possible to merge multiple scripts (provided they don't do state changes) just by a copy and past of the code inside the "default" state. [If scripts use state, then it probably makes sense for them to be in separate files].
I don't think this would be hard to implement. The only really tricky issue is what to do when parameters are quoted with different names in two places (for example
touch_start(integer x){} and touch_start(integer y). Simple solution is just to disallow that and raise an error.
As a further thought, I suppose one could emulate this functionality by using functions:
// ********** code for the 'a' feature **********
a_touch_start(integer count)
{
// do stuff
}
// ...and functions for the other events that a needs ...
// ********** code for the 'b' feature **********
b_touch_start(integer total)
{
// do other stuff
}
// ...and functions for the other events that b needs ...
default
{
touch_start(integer total_number)
{
a_touch_start(total_number)
b_touch_start(total_number)
}
// and other events as required ...
}
Solves most of the problem, but adds more overhead ...