Einhugur Lua Question


I need to embed a scripting language in my app. Perhaps the most important feature I need is that there has to be a way to debug embedded scripts. Specifically I need to be able to step/pause/inspect variables, etc.

I’m very happy to write my own debugger but I need a scripting language with hooks to do so.

I tinkered with Xojoscript but I really don’t think there’s anyway to achieve this.

Bjorn amazingly created a Wren plug-in for me which is wonderful except there are no hooks to debug it. The latest release on GitHub has very early and rough debugging support but it’s essentially a no go.

I’ve spent the last month trying to write my own scripting language with a stack based VM. It works but it’s just not fast enough and that’s even before I’ve added debugging support.

This brings me to Einhugur’s Lua plug-in. There is debugging support in the C Lua library and I even found a Lua script that implements a basic debugger.

It looks like this debugger needs support for Lua hooks and IO but according to the Einhugur Lua docs hooks and IO aren’t supported.

Any plans to add this @Björn_Eiríksson? If you do I can then try to get a debugger working. If you need sponsorship then I can help with that.

I tried to do more with things like stack trace and such back then in the lua but it always ended me in crash in Xojo, never could overcome that properly.

How big is your own engine and how much more speed do you need in it ?

The engine is currently held together with programmatic duct tape. Who knew writing a stack-based VM for an OOP language was hard? :slight_smile: The main issue is just that it’s an order of magnitude slower than your Wren plugin and since the language is for a game-making app (the scripts will control game entities) something like Wren or Lula would be more performant.

Any chance you could take a look at the Lua hooks and IO again in the plugin? I think that is all that would be needed to get the debugger script up and running.

What í was getting at is maybe your engine would belong in C++ plugin. Usually you get huge boost from that…

If I had the faintest idea how to build a C++ library I might consider it but I have no experience with it.

As an aside, can Xojo interact with libraries written in languages other than C/C++? I have some experience writing C# (especially using Element’s compiler which can compile down to native code rather than the C# VM). If that was possible maybe I could do that instead. Ultimately the app will be made in Xojo but I don’t mind using a plugin for the scripting language. Porting what I have written in Xojo to C# for example would be possible.

I use https://studio.zerobrane.com for debugging Lua in my ZWave home automation system… but have never looked into or tried it with Xojo.

1 Like

That’s a nice link @Jim_Meyer thanks. Not sure it’ll help with this particular project but I shall bookmark it for others.

@Björn_Eiríksson: To clarify, when you mention re-writing the engine in C++, is this something you would consider doing to turn it into a plugin? I’ve almost finished the Xojo code for it (still lots of testing to do).