This short tutorial will sum up all the tiny things you should know about if only you took the time to read the manual. I will try to keep this up to date with new features, but I won't just copy/paste the docs. For full info on everything, rtfm: construct.net/en/make-games/manuals/construct-3/scripting/overview
- Global scope is accessed using
globalThis
and not window
or this
. globalThis
is made available on every browser and in worker mode, so it will never break
- Global vars are accessed using
runtime.globalVars
- Local vars are accessed using
localVars
- Functions are called using
runtime.callFunction(name, ...params)
- Function params are also accessed using
localVars
- Function return value is set using
runtime.setReturnValue(value)
- DeltaTime is accessed using
runtime.dt
- Objects are accessed using
runtime.objects
- Subclasses are set using
runtime.objects.objName.setInstanceClass(SubClass)
- Subclasses must be set in the
runOnStartup
function
- Mouse and Keyboard can either be accessed using
runtime.mouse
or runtime.keyboard
or using runtime.addEventListener(name, callback)
with the following events: "keydown", "keyup", "mousedown", "mousemove", "mouseup", "dblclick", "wheel", "pointerdown", "pointermove", "pointerup", "pointercancel"
- On start of layout is done by using
runtime.layout.addEventListener(name, callback)
with one of the following events "beforelayoutstart", "afterlayoutstart"
.