API Docs for:
Show:

LS.Components.Script Class

Module: LS

Script must be coded in Javascript and they have full access to all the engine, so one script could replace the behaviour of any part of the engine. Scripts are executed inside their own context, the context is local to the script so any variable defined in the context that is not attached to the context wont be accessible from other parts of the engine. To interact with the engine Scripts must bind callback to events so the callbacks will be called when those events are triggered, however, there are some generic methods that will be called

Constructor

LS.Components.Script

(
  • object
)

Parameters:

  • object Object

    to configure from

Methods

getActions

()

get actions that could be performed from graphs or animations

getEvents

()

get events that could be triggered by this component

hasBreakpoint

(
  • method_name
)
Boolean

tells if there is a breakpoint set (using addBreakpoint) in this method

Parameters:

  • method_name String

    name of the method to check if it has a breakpoint

Returns:

Boolean:

true if there is a breakpoint

hookEvents

()

This check if the context binds engine events to the methods in the context with an specific name. This way we dont have to bind manually all the methods.

onScriptEvent

()

Called every time an event should be redirected to one function in the script context

processCode

()

This is the method in charge of compiling the code and executing the constructor, which also creates the context. It is called everytime the code is modified, that implies that the context is created when the component is configured.

reload

()

Force to reevaluate the code (only for special situations)

reload

(
  • [on_complete=null]
)

Force to reevaluate the code (only for special situations like remove codes)

Parameters:

  • [on_complete=null] Function optional

setBreakpoint

(
  • method_name
  • value
)

It will stop the execution when this method is called, but only if the console is open and the method is an event related method (onRender, onUpdate, etc)

Parameters:

  • method_name String

    name of the method to add breakpoint

  • value Boolean

    true to set, false to remove