I have figured out i can use something like this:
Code: Select all
local out = assert(loadstring(console.command))()
This allows me to enter commands directly into the game whilst it is running, such as:
Code: Select all
world.gravity = 2300
And also to help modify levels very fast, being able to type actual lua code, for example;
Code: Select all
for _, e in (world.enemies) do editor:remove(e) end
Code: Select all
assert(loadstring("world.gravity = 2300"))()
For context; This is what i am trying to achieve; https://love2d.org/imgmirrur/mEfBQYn.jpg The lines which start with DEBUG are the commands that were entered into the in-game console. Here's the project/file which i've added this to: https://github.com/Jigoku/boxclip/blob/ ... e.lua#L115
The problem is that i cannot find a way to stop the game crashing if invalid syntax is entered. Does anyone know if there is a way to do this?