How to execute live user-written code in a game?

Hi, we are trying to create a coding simulation where users will be typing in code in a code editor that will affect the game environment (like move a character). Is that possible in Phaser?

We looked into Unity and Godot but they use compiled languages so that’s harder or nearly impossible to do. We thought maybe it will be easier with an interpreted language like JS?

We’re super new to Phaser so don’t know how it works so apologies if this is a dweeb level question haha :slight_smile:

PS: of course the code the user types in would be sanitized so they aren’t trying to do something they shouldn’t. and the user code would have to use the function calls/api that we tell them to for character movement and stuff .. so if they used some non-standard function the code editor would flag it as an error

Ty for reading! <3

:waving_hand:

The Function() constructor is useful if you wish to create local bindings within your eval source, by passing the variables as parameter bindings.

eval(): Using the Function() constructor