Sansar Docs
  • 🚀Welcome to Sansar
  • 📚GLOSSARY
  • 🎏Patch Notes
  • 😇Work in Progress
  • ⚠️Creative Commons License
  • Support
    • General Troubleshooting
      • General FAQ
      • The Sansar Cache
      • The Sansar Log
    • Contact Support
  • Sansar Basics
    • Installation And Compatibility
      • Installing Sansar
      • System Requirements
      • Sansar Compatibility FAQ
      • Sansar on Mac
      • Body Tracking Vive
      • Configuring Firewalls
    • Account Management
      • Account Set Up
      • Avatar Name and ID
      • Adding Payment Method
      • Discord FAQ
      • Steam Integration
      • Subscription FAQ
    • Controls
      • Avatar Hand Gestures in VR
      • FreeCam and CineCam
      • Game Controller Buttons
      • HTC VIVE controls
      • Keyboard Shortcuts for Editing a Scene
      • Keyboard Shortcuts for Styling Your Avatar
      • Keyboard Shortcuts for Visiting an Experience
      • Mouselook Mode
      • Oculus Rift Controls
      • Vive Index Controls
    • Settings
      • General Settings
    • VR Settings
      • VR Settings Menu
      • Calibrating Height in VR
  • Exploring in Sansar
    • Navigate and Explore
      • The Codex
      • Instances
      • Interactive objects
      • The Main Menu
      • The Nexus
      • Portals
      • Quests
      • Quick Start: Exploring in Sansar
    • Socialize And Connect
      • Chat Panel
      • Experience Points, Levels, and Titles.
      • Finding People in Sansar
      • Identifying Interacting With Avatars
      • The People panel
      • User profiles
    • Attending events
      • Deploying Unpublished Event to Event World
      • Adding Events to Your Calendar
      • Attending Events in Sansar
      • Avatar Broadcasting FAQ
      • Creating Your Own Events
      • Redemption Codes
      • Tipping
    • Share Content
      • Streaming Sansar
      • Taking a photo
  • Avatar Creation
    • Avatar Basics
      • Avatar 2.0 FAQ
      • Customizing Your Avatar
      • Avatar Emotes
      • The Avatar Editor
    • Dressing The Avatar
      • Fitting Designer Clothing to your Avatar
      • Setting Custom Emotes
      • Wearing Accessories
      • Wearing Rigged Clothing
    • Managing Avatar Items
      • Importing Avatar-Related Items
      • Editing an inventory item's name
      • Editing an inventory item's image
      • Deleting avatar looks from your inventory
      • Importing a custom emote animation
      • Managing your avatar looks inventory items
    • Avatar Resources
      • Avatar Reference Files
      • Blender - Avatar files
      • Blender - Using Decimate Tool
      • Exporting Custom Avatars From Blender
      • Sansar Skeleton Skinning Details
      • Using Animation Skeleton
  • Creating In Sansar
    • Importing Things to Sansar
      • Supported file types
      • AABB Bounding Box and Item Restrictions
      • Importing Audio
      • Importing a Custom Avatar
      • Importing World Items
      • Importing Collision Volumes
      • Importing Accessories
      • Importing Clothing
      • Importing Emotes
      • Importing Hair
      • Importing Custom Scripts
      • Importing a Skybox
      • Troubleshooting Import Errors
    • Shaders and Materials
      • Shaders Information
      • Materials Information
      • VAT Shader Guides
        • VAT Shader Basics
        • VAT Technical Info
      • Displacement Guides
        • Simple Displacement
        • Advanced Displacement
    • Marvelous Designer Info
      • Marvelous Designer Integration
      • Marvelous Designer Creator Resources
      • Marvelous Import and Export
      • MD Limitations
    • Shader Scripting
    • Materials editing and shaders
    • Creator Tools
      • Creating a World
      • Creating Quests
      • Diagnostics Toolbar
      • Importing Items to Sansar
      • My Worlds Panel
    • Managing Worlds
      • Quick start: Creating experiences in Sansar
      • Deleting an experience or scene
      • Deploying a new scene to an existing experience
      • Editing a scene
      • Experience memos
      • Linking A Scene To A World
      • Managing your scenes and worlds
      • Moderation Tools for World Owners
      • Publishing Options for Your Experiences
      • Renaming a scene
      • Saving and Building A Scene
      • Sharing Your Experiences
      • Visiting your own experience
    • Part Of The World Editor
      • Object Stats Toolbar
      • Object Components
      • Parenting objects
      • Scene Item Inventory
      • Scene Objects Panel
      • Collision Volumes
      • Scene Settings
      • System objects
      • Object Motion Types
    • Working With Scripts
      • Working With Scripts
      • Working With Trigger Volume
      • Referencing Scene Components
      • Intro to Scripting in Sansar
      • Using the Script Console
      • Setting Script Parameters
      • Adding Scripts to an Object
      • Configuring Teleport Scripts
      • Simple Script User Guide
    • Working With Audio and Video
      • Working With Audio
      • Creating Media surface
      • Streaming Web Audio
      • Audio Emitter
      • Sansar Audio FAQ
      • Using Media Streams
      • Ambisonic Sounds
      • High Quality Spacial Audio
      • Audio Resource - Room Tones
      • Previewing Audio and Video in a Scene
      • Using Audio Materials
    • Working With Lights
      • Working With Lights
      • Light Types
      • Global Illumination
  • Sansar Store
    • Using the Sansar Store
      • The Sansar Store
      • Buying Items From The Store
      • Redelivering Lost Purchases
    • Buying and Selling Sansar Dollars
      • Gifting Sansar Dollars
      • Buying Sansar Dollars
      • Converting Sansar Dollars
      • Processing US Dollar Credit
    • Selling Your Content
      • Hidden Store Listings
      • Selling Items in Sansar Store
      • Selling Items in an Experience
      • Allowing Resale Of Items
      • Buyers Permissions
  • Guidelines and Moderation
    • Guidelines and Policies
      • Terms of service
      • Sansar's Discord Server Rules
      • Community Standards
      • Content Guidelines
      • World Publishing Guidelines
      • Store Listing Guidelines
      • Store Banner Guidelines
      • Event Guidelines
      • Privacy Policy
      • Sansar Freeware License Agreement
      • Intellectual Property Infringement Notification
      • Cookie Policy
    • Moderation and Reporting
      • Abuse and Griefing
      • Blocking Avatars
      • Muting Avatars
      • Reporting abuse
      • Reporting issues and bugs
      • Security issues
  • Script API Docs
    • General Information
      • External Script Repository's
      • Sansar Script API
      • Script API Updates
      • Restricted API's
    • Example Scripts
      • Example Scripts in Sansar
      • Cannonball
      • Follow The Path
      • Random Movement
      • Reflective Detector
      • Simple Script
      • Sound Randomizer
      • Stats Example
      • Teleport Hotkeys
      • Visitor Tracker
      • Mover Examples
    • Sansar Namespace
      • Namespace
      • Color
      • Mathf
      • Quarterion
      • Vector
      • Vector Extensions
    • Sansar.Script Namespace
      • AddEntryAttribute
      • CancelData
      • ComponentID
      • CoroutineException
      • Default Attributes
      • Editor Visible Attribute
      • Entries Attribute
      • Event Data
      • ICoroutine
      • IEvent Subscription
      • Instance Interface
      • Locked Attribute
      • Log
      • MaxEntriesAttribute
      • Memory
      • MinEntriesAttribute
      • NonReflectiveAttribute
      • ObjectID
      • OperationCompleteEvent
      • RangeAttribute
      • Reflective
      • Script.Base
      • Script Event Data
      • Script Handle
      • ScriptID
      • SessionID
      • Simple Script Event Data
      • ThrottleException
      • Timer
      • Tooltip Attribute
    • MetaData Namespace
      • Assembly MetaData
      • Script MetaData
    • Sansar Script Testing Namespace
      • Assertion Failure Exception
      • Assertions
    • Sansar Utility Namespace
      • GenericEnumerable <T>
      • GenericEnumerable<T>.GetItem
      • JSON Serialization Data
      • JSON Serialization Data 1
      • JSON Serializer
      • JSON Serializer Options
    • Sansar Simulation Namespace
      • Agent Info
      • Animation
      • Audio Component
      • Camera Control Mode
      • Character Tracker
      • Chat
      • Client
      • Cluster
      • Command Action and Data
      • Component Type
      • Control Point Type
      • Held Object
      • HTTP
      • Interaction
      • Light
      • Media Action
      • Mesh Component
      • Modal Dialogue
      • Move Mode and Mover
      • Objective
      • PlayHandle
      • PlaySettings
      • PlayStatus
      • Quest
      • RayCastHit
      • Rigid Body
      • Scene
      • Scene Public
      • Simple Script
      • Sit Event Type
      • Sit Object Data
      • Sound Resource
      • Stream Channel
      • Tutorial Hint
      • UI
      • User Data
Powered by GitBook
On this page
  1. Script API Docs
  2. Sansar.Script Namespace

Script.Base

PreviousReflectiveNextScript Event Data

Last updated 7 months ago

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 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

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

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

Thrown if Token is null.

Remarks

Example

C# Example

        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

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

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

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

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

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

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

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

See Also

Parameters

targetScriptId

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

See Also

Parameters

Token

The object controlling the lock. Recommended to be a private object member.

Exceptions

Type
Reason

Thrown if Token is null.

Remarks

Example

C# Example

        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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

See Also

Parameters

Token

The object controlling the lock. Recommended to be a private object member.

Exceptions

Type
Reason

Thrown if Token is null.

Remarks

Example

C# Example

        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

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

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0

protected GetCoroutineCount ()

[Sansar.Script.NonReflective] public abstract Init ()

[Sansar.Script.NonReflective] public Log { protected get; set; }

protected MaxCoroutines { get; }

[Sansar.Script.NonReflective] public Memory { protected get; set; }

protected PendingEventCount { get; }

protected PostScriptEvent ( message)

The id of the script to sent the event to. To broadcast the message to all subscripted scripts use .

[System.Obsolete("Deprecated. Use PostScriptEvent directly instead.", true)] protected PostSimpleScriptEvent ( message, data)

[System.Obsolete("Deprecated. Use PostScriptEvent directly instead.", true)] protected PostSimpleScriptEvent ( targetScriptId, message, data)

The id of the script to sent the event to. To broadcast the message to all subscripted scripts use .

protected ReleaseLock ( Token)

[Sansar.Script.NonReflective] public Script { protected get; set; }

[System.Obsolete("No longer used as there is no longer a limited number of message ids. Obsoleted 2018-04.", true)] protected static ScriptEventMessageIdCount { get; }

protected StartCoroutine<T, T1, T2, T3> ( coroutine, T arg1, T1 arg2, T2 arg3, T3 arg4, handler)

protected Terminate ( message)

protected WaitFor<ARG1, ARG2, ARG3> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3)

protected WaitFor<ARG1, ARG2, ARG3> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3)

protected WaitFor<ARG1, ARG2, ARG3> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, run)

protected WaitFor<ARG1, ARG2, ARG3, ARG4> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4)

protected WaitFor<ARG1, ARG2, ARG3, ARG4> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4)

protected WaitFor<ARG1, ARG2, ARG3, ARG4> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, run)

protected WaitFor<T1, T2, T3, T4> ( func, T1 t1, T2 t2, T3 t3, T4 t4)

protected WaitFor<ARG1, ARG2, ARG3, ARG4, ARG5> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5)

protected WaitFor<ARG1, ARG2, ARG3, ARG4, ARG5> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5)

protected WaitFor<ARG1, ARG2, ARG3, ARG4, ARG5> ( func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, run)

protected WaitForLock ( Token)

protected WaitForSignal ()

[Sansar.Script.NonReflective] public Yield ()

            private object BalanceLock = new Object();
            private object BalanceLock = new Object();
            private object BalanceLock = new Object();
ICoroutine
int
void
Log
int
Memory
int
void
string
ScriptBase.PostScriptEvent(string, Reflective)
void
string
object
void
ScriptId
string
object
ScriptBase.PostSimpleScriptEvent(string, object)
void
object
ScriptHandle
int
ICoroutine
Action<T, T1, T2, T3>
Action
void
string
EventData
Func<ARG1, ARG2, ARG3, Action, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>
EventData
Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>
EventData
Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>
Action
EventData
Func<ARG1, ARG2, ARG3, ARG4, Action, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>
EventData
Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>
EventData
Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>
Action
OperationCompleteEvent
Action<T1, T2, T3, T4, Action>
EventData
Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>
EventData
Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>
EventData
Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>
Action
void
object
int
void
ArgumentNullException
ArgumentNullException
ArgumentNullException