this post was submitted on 12 Nov 2023
12 points (83.3% liked)

Programming

17343 readers
377 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

The official documentation isn't 100% clear on things (why am I getting LUA_TNIL for functions?), and the best I can find with some simple web search is kinda relevant stackoverflow (๐Ÿคฎ) posts, except they're mostly about calling host functions from Lua side, the rest are things that seem I've nailed so far.

EDIT: Solution was that everyone was using luaL_dofile, while I was forward thinking and used lua_load instead, which isn't a macro, and as such doesn't do an initial lua_pcall. Now I do it manually, and now I get different, but less cryptic and actually documented errors. Now I just have to wrestle with D metaprogramming features (very strong and capable, but is a rabbit hole itself).

top 8 comments
sorted by: hot top controversial new old
[โ€“] tdawg@lemmy.world 7 points 1 year ago

Not really sure what you're trying to achieve here. Do you have an application that lets you use Lua extensions? Or do you want to build an application that lets you use Lua extensions?

[โ€“] DmMacniel@feddit.de 5 points 1 year ago (1 children)

Whats the host language you try to embed lua into?

[โ€“] ZILtoid1991@kbin.social 3 points 1 year ago (1 children)

D.

It has C ABI compatibility, so it should work. But as others wrote, I might have messed up my Lua script.

[โ€“] aluminium@lemmy.world 2 points 1 year ago

Upvote for D, underrated lang.

[โ€“] Swim@lemmy.ca 4 points 1 year ago (1 children)

let me take a guess, gta online modder ?

[โ€“] ZILtoid1991@kbin.social 1 points 1 year ago

No, I'm developing my own engine.

[โ€“] adamnejm@programming.dev 2 points 1 year ago

One Lone Coder has made few videos about adding Lua scripting to a C++ program, maybe it has what you're looking for: Embedding Lua in C++ #1

[โ€“] bizdelnick@lemmy.ml -3 points 1 year ago

Well, reference manual was enough for me. There' nothing difficult. You probably have troubles with your lua code, try executing it in the standalone interpreter.