This project shows how to move a Windows window via JavaScript
Links:
require() is not part of the standard JavaScript API. But in Node.js, it's a built-in function with a special purpose: to load modules. require(), module.exports and exports are APIs of a module system that is specific to Node.js
Some experiments with 2 maps created with Leaflet and OpenLayers:
As usual, the code is in my repository
- https://github.com/el3um4s/construct-demo
- https://c3demo.stranianelli.com/
- Free Patreon Post: https://www.patreon.com/posts/maps-in-3-49027372
You can use
runtime.globalVars["Variable name"] = newValue
or
runtime.globalVars.myVariable = newValue;
see
globalVars An object with a property for each global variable on an event sheet in the project. For example if the project has a global variable on an event sheet named Score, then runtime.globalVars.Score provides access to the global variable from script. https://www.construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/iruntime
globalVars
An object with a property for each global variable on an event sheet in the project. For example if the project has a global variable on an event sheet named Score, then runtime.globalVars.Score provides access to the global variable from script.
https://www.construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/iruntime
I'm not on pc now but I think something like this could go:
const ytPlayer = await YouTube.CreatePlayer("youtubeIframe", { "onStateChange": e => { runtime.globalVars.myVariable = "" + e.data; } });
To simplify the use of "runtime" I prefer to insert a code of this type in 'main.js':
runOnStartup(async runtime => { globalThis.g_runtime = runtime; });
I use g_runtime instead of runtime
const ytPlayer = await YouTube.CreatePlayer("youtubeIframe", { "onStateChange": e => { g_runtime.globalVars.myVariable = "" + e.data; } });
If you want "ytPlayer" to be global you have to use the one imported from Globals.js
Globals.ytPlayer = await YouTube.CreatePlayer("youtubeIframe", { "onStateChange": e => { g_runtime.globalVars.myVariable = "" + e.data; } });
However, remember that the variables in the event sheet can only be strings, numbers or booleans
I can't test this code right now
This is a post about YouTube and C3: https://www.patreon.com/posts/46901116
Source code: https://github.com/el3um4s/construct-demo
Demo: https://c3demo.stranianelli.com/javascript/007-youtube/demo
This project is a simple cannon controlled by a genetic algorithm. With each generation the cannon fires and tries to hit the target. You can drag both the cannon and the target with the mouse.
C3 learns the Divina Commedia (aka Machine Learning and Construct 3)
Develop games in your browser. Powerful, performant & highly capable.
Very nice
Member since 9 Nov, 2015