• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: SVC-2560
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Duplicate
Priority: Normal Normal
Assignee: Unassigned
Reporter: Christopher Omega
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
2. Second Life Service - SVC

State transitions shouldn't clear the event queue!

Created: 22/Jun/08 02:55 AM   Updated: 25/Jun/08 06:05 PM
Return to search
Component/s: Scripts
Affects Version/s: 1.22.3 Server
Fix Version/s: None

Issue Links:
Duplicate
 


 Description  « Hide
Currently when a script transitions its state, all the events in the event queue are cleared. This prevents people from using state transitions in the purely abstract manner I think they were meant to be used for - to handle the next upcoming events in a different way. My scripts use link_messages to communicate with each other, and when the state changes, a critical number of these messages may be lost in the transition. This forces me to add llSleep calls to other scripts, breaking abstraction; when writing script B that talks to script A, I have to keep in mind which messages cause script A to change state, and wait for that change in script B. If I later rewrite script A to no longer require a transition, I'd then have the potentially large task of figuring out which scripts made the llSleep calls to compensate for script A's now-removed transition.

Back in the very very far gone past, state transitions used to not clear state. Transitioning to the new state would sometimes execute events from the old state that were still in the queue, using the old event body code. This is NOT the behavior I'm pushing for. The event-queue clearing behavior was put in place as a solution to this problem. I think that clearing was the wrong choice to make here, because it really kills the usefulness of states. Instead, what I propose is that all the old data that was passed to the script in the previous state should be used to execute the event body in the new state, iff that event is declared in the new state.

For example: the script is in state A, which declares a touch_start event. When state A's touch_start event is executed, it causes a transition into state B, which also has a touch_start event declared. When the touch_start event is queued, data that the llDetected* functions can access is queued along with it. I want to call all this data "event signature data" because it would also include the integer argument passed to the touch_start event.

When state A's touch_start event triggers the state transition, the script should not clear the event queue of event signature data. The remaining touch_start event signature data that was queued in state A should be used to execute the code in the touch_start event body in state B.

In essence, I'd like for LL to decouple the event signature data from the code that is executed when the event runs. This would successfully address the "old event's code running" problem that plagued scripts back before state-change caused the event queue to clear, and it would make states a lot less dangerous to use, especially when dropping an event causes a critical failure or unusual change in behavior.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Christopher Omega added a comment - 22/Jun/08 03:17 AM
As mentioned in SVC-2286, I would be all for an llRetainEvents(integer bool) function that determines whether to follow the current, clear-on-transition behavior (FALSE), or that preserves the event signature data on state transition (TRUE).

Christopher Omega added a comment - 22/Jun/08 10:56 AM
I dont think I was entirely clear about the behavior of the queue if the event isn't declared in the new state. If the next event in the queue does not have a body declared in the new state, it can be safely discarded from the queue.

Aimee Trescothick added a comment - 25/Jun/08 06:05 PM
This duplicates SVC-2297, feel free to edit and expand on that issue.