4 ms·
Will it be possible for you to make the Lua REPL publicly available? Would love to give it a spin with Spring RTS!
by divs1210 6y ago
Will it be possible for you to make the Lua REPL publicly available? Would love to give it a spin with Spring RTS!
- nonbirithm 6y agoIt is, it's just part of a project I'm working on that uses Love2D and integrated with it a bit tightly. But I think it could be useful. Actually when I think about it the thing I made probably isn't a "REPL" in the Clojure sense since all it has is a command line and module hotloading; there is no namespace support and the command line evaluation does not happen in the context of the program, but you can basically call a function that gives you the entire global state of the game to mess with and see changes instantly. Maybe that's a better approach than having global state shared between both as Lua has no namespace support built-in, and I don't want to hack it on to keep things simple. Here is the drawing code for the REPL in-game. https://github.com/Ruin0x11/OpenNefia/blob/master/src/api/gui/menu/ReplLayer.lua https://github.com/Ruin0x11/OpenNefia/blob/master/src/api/gu... Here is the server which listens for commands using a custom protocol. I want to use nREPL at some point but that requires merging some changes into external projects with the client side tooling. https://github.com/Ruin0x11/OpenNefia/blob/master/src/internal/debug_server.lua https://github.com/Ruin0x11/OpenNefia/blob/master/src/intern... Here is the code which handles hotloading. It's complicated but I had to write the system so that it also handles sandboxing external mods and hooks into Lua's module management, running special checks to see if the loaded code is not part of the base game. You can probably get away with the version in lume if you don't need as much. But the point is that this is what ultimately allows changing files and seeing the changes instantly without restarting the program. https://github.com/Ruin0x11/OpenNefia/blob/master/src/internal/env.lua https://github.com/Ruin0x11/OpenNefia/blob/master/src/intern... https://github.com/rxi/lume/blob/98847e7812cf28d3d64b289b03fad71dc704547d/lume.lua#L688 https://github.com/rxi/lume/blob/98847e7812cf28d3d64b289b03f... Here is the integration with Emacs. https://github.com/Ruin0x11/OpenNefia/blob/master/editor/emacs/open-nefia.el https://github.com/Ruin0x11/OpenNefia/blob/master/editor/ema...