FANDOM


SyntaxEdit

llResetOtherScript(string name);

Is applied to another script within the same prim, which one immediately is reseted to it's initial state and restarted.

Parameters

string name
any string value or string variable, that contains the name of the script to be reseted

Returns void

This function doesn't return a result.

Example

Resets all other scripts in the same prim, when the owner says "/1 reset", except this one.

default 
{
	state_entry()
	{
		llListen(1, "", llGetOwner(), "");
	}

	listen(integer channel, string name, key id, string message)
	{
		if (llToLower(message) == "reset")
		{
			integer i;
			string ScriptName;
			for ( i = 0; i < llGetInventoryNumber(INVENTORY_SCRIPT); i++ )
			{
				ScriptName = llGetInventoryName(INVENTORY_SCRIPT, i);
				if (llGetScriptName() != ScriptName) 
				{
					llResetOtherScript(ScriptName);
				}
			}
		}
	}
}

Remarks

llResetOtherScript() does the following operations in detail:

  • It looks up, if the script given in parameter name exists.
  • Does it not exist, the error could not find script is spawn and no further action is taken.
  • Does the script exist, it's execution is stopped immediately.
  • It clears all pending events for the named script. So keep in mind, that any events waiting in the queue are lost and are not raised after the script is restarted.
  • It resets all variables to their default values. Any stored data or modified values in the named script are lost.
  • The named script switches to the default state, but without raising any state-events like state_exit.
  • The named script is restarted and the default state_entry is triggered, if it exists.

Notes

Icon-warning-22x22If not coded properly, the use of llResetOtherScript() can introduce bugs or serious side effects, as the script that resets the other script does have no information about the actual commands the other script might be executing at the moment of the reset.

To avoid side effects, like losing of data, think about other better possibilities to achieve the same, which llResetOtherScript() is used for in a special case. Often, other solutions are possible and better.

This function has no effect, when the other script is not running. The same is the case for scripts being suspended by a function.

Also, this function does not reset scripts, that might have been crashed with a run-time error. This is for a long time like that and even from many requested to work on crashed scripts (see SVC-57, it might be intended like that and never "fixed". Because resetting a crashed script without checking into it, might cause the script to crash repeatedly in some cases.

Related Functions

Related Events

  • state_entry - Is the first event raised, after a script reset

Related Articles

How to code a crash recovery system, that auto-recovers crashed scripts

Platforms

SecondLife (agni), Secondlife (aditi), OpenSimulator

See alsoEdit


  Icon-edit-22x22 Read comments or write a new one!    

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.