I cannot call a function in main.js

0 favourites
  • 5 posts
From the Asset Store
Voice call plugin based on webrtc protocol for construct 3
  • I got error when tried to call a function in main.js:

    Video:

    Subscribe to Construct videos now

    action.js:31 Unhandled exception running script Event sheet 1, event 1, action 1: ReferenceError: testMessage is not defined

    at EventSheet1_Event1_Act1 (scriptsInEvents.js:8)

    at Action.RunUserScript (action.js:31)

    at EventBlock._RunActions_ReturnValue (eventBlock.js:27)

    at EventBlock._RunAndBlock (eventBlock.js:24)

    at EventBlock.Run (eventBlock.js:21)

    at EventSheet._ExecuteTrigger (eventSheet.js:19)

    at EventSheet._TriggerForClass (eventSheet.js:13)

    at EventSheet._Trigger (eventSheet.js:12)

    at EventSheetManager._Trigger (eventSheetManager.js:13)

    at C3Runtime.Trigger (runtime.js:86)

    RunUserScript action.js:31

    async function (async)

    RunUserScript action.js:31

    _RunActions_ReturnValue eventBlock.js:27

    _RunAndBlock eventBlock.js:24

    Run eventBlock.js:21

    _ExecuteTrigger eventSheet.js:19

    _TriggerForClass eventSheet.js:13

    _Trigger eventSheet.js:12

    _Trigger eventSheetManager.js:13

    Trigger runtime.js:86

    TriggerAsync runtime.js:87

    TriggerAsync sdkInstanceBase.js:4

    _OnClick instance.js:3

    (anonymous) plugin.js:1

    (anonymous) sdkDOMPluginBase.js:3

    _OnEventFromDOM runtime.js:16

    _OnMessageFromDOM runtime.js:14

    _PostToRuntimeMaybeSync domHandler.js:2

    _PostToRuntimeElementMaybeSync domElementHandler.js:4

    (anonymous) domSide.js:3

    action.js:32 Tip: run this to highlight in Construct the last script that had an error: goToLastErrorScript()

  • See the manual section on scripting, specifically JavaScript in Construct. Construct uses JavaScript Modules, where scope works differently to classic scripts.

  • Thank Ashley,

    Can you help to make a sample script in main.js

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • As the manual section states, either use JavaScript Modules, or use globalThis to explicitly refer to globals. There are also lots of scripting examples that come with Construct.

  • As the manual section states, either use JavaScript Modules, or use globalThis to explicitly refer to globals. There are also lots of scripting examples that come with Construct.

    Thank Ashley, I resolved my issue, just change the Script Purpose to "Imports for events" then it's work.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)