> For the complete documentation index, see [llms.txt](https://docs.sansar.com/latest/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sansar.com/latest/script-api-docs/sansar-script-namespace/script.base.md).

# Script.Base

#### ScriptBase Constructor

> Constructor
>
> #### Syntax
>
> public **ScriptBase** ()
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### CurrentCoroutine Property

> Gets the ICoroutine interface for the current coroutine.
>
> #### Syntax
>
> protected [ICoroutine](https://help.sansar.com/hc/en-us/articles/360000914646) **CurrentCoroutine** { get; }
>
> **Value**
>
> > The ICoroutine interface to the currently running coroutine.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### GetAllCoroutines Method

> A list of all coroutines for this script.
>
> #### Syntax
>
> **Returns**
>
> > A list containing all running or waiting coroutines.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### GetCoroutineCount Method

> The total number of coroutines running on this script.
>
> #### Syntax
>
> protected [int](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Int32) **GetCoroutineCount** ()
>
> **Returns**
>
> > The total number of coroutines running on this script.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Init Method

> Init() is called after all interfaces have been initialized.
>
> #### Syntax
>
> \[Sansar.Script.NonReflective]\
> public abstract [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **Init** ()
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Lock Method

> Use to create a critical section with a using statement, ensuring that no other coroutines or scripts (via Reflective) may enter this code section while one coroutine or script is in it.
>
> #### Syntax
>
> **See Also**
>
> **Parameters**
>
> > *Token*
> >
> > The object controlling the lock. Recommended to be a private object member.
>
> **Returns**
>
> > A ScopedLock that holds the lock and will release it in IDisposable.Dispose.
>
> **Exceptions**

| Type                                                                                                  | Reason                   |
| ----------------------------------------------------------------------------------------------------- | ------------------------ |
| [ArgumentNullException](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.ArgumentNullException) | Thrown if Token is null. |

> #### Remarks
>
> #### Example

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>C# Example</strong></td></tr><tr><td><pre><code>            private object BalanceLock = new Object();
</code></pre></td></tr></tbody></table>

```
        int Balance = 100;
        bool Spend(int value)
        {
            using (Lock(BalanceLock))
            {
                if (Balance > value)
                {
                    Balance -= value;
                    return true;
                }
                return false;
            }
        }
```

|

> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Log Property

> Gets the script console.
>
> #### Syntax
>
> \[Sansar.Script.NonReflective]\
> public [Log](https://help.sansar.com/hc/en-us/articles/115005084908) **Log** { protected get; set; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### MaxCoroutines Property

> The maximum number of coroutines that a single script can run.
>
> #### Syntax
>
> protected [int](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Int32) **MaxCoroutines** { get; }
>
> **Value**
>
> > The maximum number of coroutines that a single script can run.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Memory Property

> Memory information for the pool this script is in.
>
> #### Syntax
>
> \[Sansar.Script.NonReflective]\
> public [Memory](https://help.sansar.com/hc/en-us/articles/115001972446) **Memory** { protected get; set; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PendingEventCount Property

> The number of events currently waiting to be processed.
>
> #### Syntax
>
> protected [int](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Int32) **PendingEventCount** { get; }
>
> **Value**
>
> > The number of events currently waiting to be processed.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PostScriptEvent Method

> Post the event for all scripts.
>
> #### Syntax
>
> protected [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **PostScriptEvent** ([string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) message)
>
> **Parameters**
>
> > *message*
> >
> > The message id used to direct the event.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PostScriptEvent Method

> Post the event for all scripts.
>
> #### Syntax
>
> **Parameters**
>
> > *message*
> >
> > The message id used to direct the event.
> >
> > *data*
> >
> > The object to be post.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PostScriptEvent Method

> Post the event for the target script.
>
> #### Syntax
>
> **Parameters**
>
> > *targetScriptId*
> >
> > The id of the script to sent the event to. To broadcast the message to all subscripted scripts use [ScriptBase.PostScriptEvent(string, Reflective)](https://help.sansar.com/hc/en-us/articles/115003549048#M:Sansar.Script.ScriptBase.PostScriptEvent\(System.String,Sansar.Script.Reflective\)).
> >
> > *message*
> >
> > The message id used to direct the event.
> >
> > *data*
> >
> > The object to be post.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PostSimpleScriptEvent Method

> #### Syntax
>
> \[System.Obsolete("Deprecated. Use PostScriptEvent directly instead.", true)]\
> protected [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **PostSimpleScriptEvent** ([string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) message, [object](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Object) data)
>
> **See Also**
>
> **Parameters**
>
> > *message*
> >
> > The message id used to direct the event.
> >
> > *data*
> >
> > An object to send to scripts subscribed to message.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PostSimpleScriptEvent Method

> #### Syntax
>
> \[System.Obsolete("Deprecated. Use PostScriptEvent directly instead.", true)]\
> protected [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **PostSimpleScriptEvent** ([ScriptId](/latest/script-api-docs/sansar-script-namespace/scriptid.md) targetScriptId, [string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) message, [object](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Object) data)
>
> **See Also**
>
> **Parameters**
>
> > *targetScriptId*
> >
> > The id of the script to sent the event to. To broadcast the message to all subscripted scripts use [ScriptBase.PostSimpleScriptEvent(string, object)](https://help.sansar.com/hc/en-us/articles/115003549048#M:Sansar.Script.ScriptBase.PostSimpleScriptEvent\(System.String,System.Object\)).
> >
> > *message*
> >
> > The message id used to direct the event.
> >
> > *data*
> >
> > An object to send to script targetScriptId if subscribed to message.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ReleaseLock Method

> Release a lock if held.
>
> #### Syntax
>
> protected [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **ReleaseLock** ([object](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Object) Token)
>
> **See Also**
>
> **Parameters**
>
> > *Token*
> >
> > The object controlling the lock. Recommended to be a private object member.
>
> **Exceptions**

| Type                                                                                                  | Reason                   |
| ----------------------------------------------------------------------------------------------------- | ------------------------ |
| [ArgumentNullException](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.ArgumentNullException) | Thrown if Token is null. |

> #### Remarks
>
> #### Example

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>C# Example</strong></td></tr><tr><td><pre><code>            private object BalanceLock = new Object();
</code></pre></td></tr></tbody></table>

```
        int Balance = 100;
        bool Spend(int value)
        {
            WaitForLock(BalanceLock);
            bool success = false;
            if (Balance > value)
            {
                Balance -= value;
                success = true;
            }
            ReleaseLock(BalanceLock);
            // Note that any early exit between WaitForLock and ReleaseLock fail to release the lock, creating a deadlock the next time this method is called.
            // For this reason it is highly recommended to instead do: using (Lock(BalanceLock))
            return success;
        }
```

|

> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Script Property

> Script handle to this script.
>
> #### Syntax
>
> \[Sansar.Script.NonReflective]\
> public [ScriptHandle](https://help.sansar.com/hc/en-us/articles/115003551048) **Script** { protected get; set; }
>
> **Value**
>
> > An opaque type used by certain API methods.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ScriptEventMessageIdCount Property

> Obsolete
>
> #### Syntax
>
> \[System.Obsolete("No longer used as there is no longer a limited number of message ids. Obsoleted 2018-04.", true)]\
> protected static [int](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Int32) **ScriptEventMessageIdCount** { get; }
>
> **Value**
>
> > Always returns 0
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### StartCoroutine Method

> Starts a coroutine on the current script.
>
> #### Syntax
>
> **Parameters**
>
> > *coroutine*
> >
> > The coroutine to run.
> >
> > *handler*
> >
> > A callback to know when the coroutine has finished.
>
> **Returns**
>
> > An ICoroutine interface to stop the coroutine or see if it has finished.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### StartCoroutine Generic Method

> Starts a coroutine on the current script.
>
> #### Syntax
>
> **Type Parameters**
>
> > *T*
> >
> > Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
>
> **Parameters**
>
> > *coroutine*
> >
> > The coroutine to run.
> >
> > *arg1*
> >
> > First parameter to pass to the coroutine when it is run.
> >
> > *handler*
> >
> > A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.
>
> **Returns**
>
> > An ICoroutine interface to stop the coroutine or see if it has finished.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### StartCoroutine\<T,T1> Generic Method

> Starts a coroutine on the current script.
>
> #### Syntax
>
> **Type Parameters**
>
> > *T*
> >
> > Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
> >
> > *T1*
> >
> > Type of the second parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
>
> **Parameters**
>
> > *coroutine*
> >
> > The coroutine to run.
> >
> > *arg1*
> >
> > First parameter to pass to the coroutine when it is run.
> >
> > *arg2*
> >
> > Second parameter to pass to the coroutine when it is run.
> >
> > *handler*
> >
> > A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.
>
> **Returns**
>
> > An ICoroutine interface to stop the coroutine or see if it has finished.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### StartCoroutine\<T,T1,T2> Generic Method

> Starts a coroutine on the current script.
>
> #### Syntax
>
> **Type Parameters**
>
> > *T*
> >
> > Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
> >
> > *T1*
> >
> > Type of the second parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
> >
> > *T2*
> >
> > Type of the third parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
>
> **Parameters**
>
> > *coroutine*
> >
> > The coroutine to run.
> >
> > *arg1*
> >
> > First parameter to pass to the coroutine when it is run.
> >
> > *arg2*
> >
> > Second parameter to pass to the coroutine when it is run.
> >
> > *arg3*
> >
> > Third parameter to pass to the coroutine when it is run.
> >
> > *handler*
> >
> > A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.
>
> **Returns**
>
> > An ICoroutine interface to stop the coroutine or see if it has finished.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### StartCoroutine\<T,T1,T2,T3> Generic Method

> Starts a coroutine on the current script.
>
> #### Syntax
>
> protected [ICoroutine](https://help.sansar.com/hc/en-us/articles/360000914646) **StartCoroutine\<T, T1, T2, T3>** ([Action\<T, T1, T2, T3>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action`4) coroutine, *T* arg1, *T1* arg2, *T2* arg3, *T3* arg4, [Action](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action`1) handler)
>
> **Type Parameters**
>
> > *T*
> >
> > Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
> >
> > *T1*
> >
> > Type of the second parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
> >
> > *T2*
> >
> > Type of the third parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
> >
> > *T3*
> >
> > Type of the fourth parameter to pass to the coroutine when it is run. This can usually be derived from the Action.
>
> **Parameters**
>
> > *coroutine*
> >
> > The coroutine to run.
> >
> > *arg1*
> >
> > First parameter to pass to the coroutine when it is run.
> >
> > *arg2*
> >
> > Second parameter to pass to the coroutine when it is run.
> >
> > *arg3*
> >
> > Third parameter to pass to the coroutine when it is run.
> >
> > *arg4*
> >
> > Fourth parameter to pass to the coroutine when it is run.
> >
> > *handler*
> >
> > A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.
>
> **Returns**
>
> > An ICoroutine interface to stop the coroutine or see if it has finished.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### SubscribeToScriptEvent Method

> Subscribes to events sent by other scripts
>
> #### Syntax
>
> **Parameters**
>
> > *message*
> >
> > The event message to listen for.
> >
> > *callback*
> >
> > Handler to call when the event is generated
> >
> > *persistent*
> >
> > Set to false if a one time event is desired.
>
> **Returns**
>
> > An IEventSubscription that can be used to Unsubscribe from these script events.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### SubscribeToScriptEvent Method

> Subscribes to events sent only by a specific script.
>
> #### Syntax
>
> **Parameters**
>
> > *sourceScriptId*
> >
> > Ignore events posted by scripts not matching this id.
> >
> > *message*
> >
> > The event message to listen for.
> >
> > *callback*
> >
> > Handler to call when the event is generated.
> >
> > *persistent*
> >
> > Set to false if a one time event is desired.
>
> **Returns**
>
> > An IEventSubscription that can be used to Unsubscribe from these script events.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Terminate Method

> Terminates this script immediately.
>
> #### Syntax
>
> protected [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **Terminate** ([string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) message)
>
> **Parameters**
>
> > *message*
> >
> > The message to write to the log.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Wait Method

> Delays execution of the current coroutine for the specified time.
>
> #### Syntax
>
> **Parameters**
>
> > *duration*
> >
> > The length of time to wait before continuing in seconds.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Wait Method

> Delays execution of the current coroutine for the specified time.
>
> #### Syntax
>
> **Parameters**
>
> > *duration*
> >
> > The length of time to wait before continuing.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Method

> Block the current coroutine until otherCoroutine finishes.
>
> #### Syntax
>
> **Parameters**
>
> > *otherCoroutine*
> >
> > The coroutine to wait for.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *run*
> >
> > An Action to run after subscribing the the event, but before waiting for the event to occurr.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *run*
> >
> > An Action to run after subscribing the the event, but before waiting for the event to occurr.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *T1*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *t1*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *run*
> >
> > An Action to run after subscribing the the event, but before waiting for the event to occurr.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<T1,T2> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *T1*
> >
> > The type of the argument to func.
> >
> > *T2*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *t1*
> >
> > An argument to func.
> >
> > *t2*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3>** ([Func\<ARG1, ARG2, ARG3, Action, Action\<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`7) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3>** ([Func\<ARG1, ARG2, ARG3, Action\<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`6) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3>** ([Func\<ARG1, ARG2, ARG3, Action\<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`6) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, [Action](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action) run)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *run*
> >
> > An Action to run after subscribing the the event, but before waiting for the event to occurr.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<T1,T2,T3> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> **Type Parameters**
>
> > *T1*
> >
> > The type of the argument to func.
> >
> > *T2*
> >
> > The type of the argument to func.
> >
> > *T3*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *t1*
> >
> > An argument to func.
> >
> > *t2*
> >
> > An argument to func.
> >
> > *t3*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3,ARG4> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3, ARG4>** ([Func\<ARG1, ARG2, ARG3, ARG4, Action, Action\<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`8) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, *ARG4* arg4)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
> >
> > *ARG4*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *arg4*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3,ARG4> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3, ARG4>** ([Func\<ARG1, ARG2, ARG3, ARG4, Action\<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`7) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, *ARG4* arg4)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
> >
> > *ARG4*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *arg4*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3,ARG4> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3, ARG4>** ([Func\<ARG1, ARG2, ARG3, ARG4, Action\<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`7) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, *ARG4* arg4, [Action](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action) run)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
> >
> > *ARG4*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *arg4*
> >
> > An argument to func.
> >
> > *run*
> >
> > An Action to run after subscribing the the event, but before waiting for the event to occurr.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<T1,T2,T3,T4> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [OperationCompleteEvent](https://help.sansar.com/hc/en-us/articles/115003436923) **WaitFor\<T1, T2, T3, T4>** ([Action\<T1, T2, T3, T4, Action>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action`5) func, *T1* t1, *T2* t2, *T3* t3, *T4* t4)
>
> **Type Parameters**
>
> > *T1*
> >
> > The type of the argument to func.
> >
> > *T2*
> >
> > The type of the argument to func.
> >
> > *T3*
> >
> > The type of the argument to func.
> >
> > *T4*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *t1*
> >
> > An argument to func.
> >
> > *t2*
> >
> > An argument to func.
> >
> > *t3*
> >
> > An argument to func.
> >
> > *t4*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3,ARG4,ARG5> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3, ARG4, ARG5>** ([Func\<ARG1, ARG2, ARG3, ARG4, ARG5, Action, Action\<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`9) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, *ARG4* arg4, *ARG5* arg5)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
> >
> > *ARG4*
> >
> > The type of the argument to func.
> >
> > *ARG5*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *arg4*
> >
> > An argument to func.
> >
> > *arg5*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3,ARG4,ARG5> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3, ARG4, ARG5>** ([Func\<ARG1, ARG2, ARG3, ARG4, ARG5, Action\<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`8) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, *ARG4* arg4, *ARG5* arg5)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
> >
> > *ARG4*
> >
> > The type of the argument to func.
> >
> > *ARG5*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *arg4*
> >
> > An argument to func.
> >
> > *arg5*
> >
> > An argument to func.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitFor\<ARG1,ARG2,ARG3,ARG4,ARG5> Generic Method

> Use to pause the script until an event happens.
>
> #### Syntax
>
> protected [EventData](https://help.sansar.com/hc/en-us/articles/115003548788) **WaitFor\<ARG1, ARG2, ARG3, ARG4, ARG5>** ([Func\<ARG1, ARG2, ARG3, ARG4, ARG5, Action\<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Func`8) func, *ARG1* arg1, *ARG2* arg2, *ARG3* arg3, *ARG4* arg4, *ARG5* arg5, [Action](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action) run)
>
> **Type Parameters**
>
> > *ARG1*
> >
> > The type of the argument to func.
> >
> > *ARG2*
> >
> > The type of the argument to func.
> >
> > *ARG3*
> >
> > The type of the argument to func.
> >
> > *ARG4*
> >
> > The type of the argument to func.
> >
> > *ARG5*
> >
> > The type of the argument to func.
>
> **Parameters**
>
> > *func*
> >
> > The event-generating API to wait for.
> >
> > *arg1*
> >
> > An argument to func.
> >
> > *arg2*
> >
> > An argument to func.
> >
> > *arg3*
> >
> > An argument to func.
> >
> > *arg4*
> >
> > An argument to func.
> >
> > *arg5*
> >
> > An argument to func.
> >
> > *run*
> >
> > An Action to run after subscribing the the event, but before waiting for the event to occurr.
>
> **Returns**
>
> > An EventData that can be case to type corresponding to the event type of func.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitForLock Method

> WaitFor and take a lock on Token
>
> #### Syntax
>
> protected [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **WaitForLock** ([object](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Object) Token)
>
> **See Also**
>
> **Parameters**
>
> > *Token*
> >
> > The object controlling the lock. Recommended to be a private object member.
>
> **Exceptions**

| Type                                                                                                  | Reason                   |
| ----------------------------------------------------------------------------------------------------- | ------------------------ |
| [ArgumentNullException](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.ArgumentNullException) | Thrown if Token is null. |

> #### Remarks
>
> #### Example

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>C# Example</strong></td></tr><tr><td><pre><code>            private object BalanceLock = new Object();
</code></pre></td></tr></tbody></table>

```
        int Balance = 100;
        bool Spend(int value)
        {
            WaitForLock(BalanceLock);
            bool success = false;
            if (Balance > value)
            {
                Balance -= value;
                success = true;
            }
            ReleaseLock(BalanceLock);
            // Note that any early exit between WaitForLock and ReleaseLock fail to release the lock, creating a deadlock the next time this method is called.
            // For this reason it is highly recommended to instead do: using (Lock(BalanceLock))
            return success;
        }
```

|

> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### WaitForSignal Method

> Wait the current coroutine until at least 1 signal is sent to it through the ICoroutine interface.
>
> #### Syntax
>
> protected [int](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Int32) **WaitForSignal** ()
>
> **Returns**
>
> > The number of signals received while waiting.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Yield Method

> Yield to let other coroutines or events run.
>
> #### Syntax
>
> \[Sansar.Script.NonReflective]\
> public [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **Yield** ()
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sansar.com/latest/script-api-docs/sansar-script-namespace/script.base.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
