How to get my nim procs in a lua table

2020-09-07 Thread geotre
Can you paste here the commands you are running and their output?

How to get my nim procs in a lua table

2020-09-05 Thread Skaruts
It was a whole bunch of _" undefined reference to"_ a lot of the functions from the lua api. I think I was getting that too when trying to compile a C code version of my first test (that's linker errors, iirc, but my C is too rusty to be sure). I ended up giving up on C, since I couldn't figure

How to get my nim procs in a lua table

2020-09-04 Thread geotre
No problem, I'm glad it is helpful. Maybe I can help figure out what's wrong. You shouldn't need to do anything with lua libraries to get it working, what versions of Nim and Love2D are you running? Did you copy the code exactly as it is above? What error message do you get?

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
@geotre, then maybe I can't compile it for the same reason I can't compile C code for lua... I may not have my lua libraries properly setup for that, or something. I'm never figured out what the problem was. @lucian, that code worked! And my lib compiled fine too and worked as intended now. Tha

How to get my nim procs in a lua table

2020-09-02 Thread geotre
@Skaruts you don’t need either lua binding to use my demo code, just what I’ve included. Tested on nim devel. I see now that you are trying to do something different though

How to get my nim procs in a lua table

2020-09-02 Thread lucian
ignore this, it fails to run.

How to get my nim procs in a lua table

2020-09-02 Thread lucian
let fns = [ Treg(name:"foo", `func`:nimfoo), Treg(name:"bar", `func`:nimbar) ] register(L, "sllib", unsafeAddr fns[0]) Run this compiles with official Nim's Lua 5.1 package, but from there on you're on your own.

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
Not sure how to do it. This gives me an error: let fns = [ Preg(name:"foo", `func`:nimfoo),# Error: object constructor needs an object type Preg(name:"bar", `func`:nimbar) ] register(L, "sllib", fns[0]) Run

How to get my nim procs in a lua table

2020-09-02 Thread lucian
> although the lua app crashes on startup for some reason This may be due to using Nim code standalone library without doing some presetup required. Look-up threads in forum for creating a Nim dll to be linked in C projects. AFAIK it requires some code to init the GC or alike. In terms of regis

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
That module may come in handy. Gonna keep it in mind. I'm doing the opposite of that, though. Love2D already handles the whole backend lua C api stuff, and creates the lua state, then lua itself sends it to my lib when calling its functions. (`love2d <--> lua <--> dll`) [This is my test code](

How to get my nim procs in a lua table

2020-09-02 Thread disruptek
I don't really know anything about Lua, but I needed to do some luaJIT stuff, including reading arbitrary Lua data into Nim objects, so I wrote this thing: / Maybe it will help. The docs are fairly skimpy, but I use it like this: var L = newStat

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
I may have mislead everyone about the bindings I'm using (edited the OP for clarity). It's the official lua bindings, and not the `nimLua` ones. I just adapted @lucian's code to my lib and it compiled using nimLua (although the lua app crashes on startup for some reason). As for @geotre's code,

How to get my nim procs in a lua table

2020-09-02 Thread geotre
Hey Skaruts, I'm not sure what you are trying to do with Love2D, but I thought this might interest you so I'll paste it here. It's a demo using the Love API via the Lua VM: # main.nim # -- a bunch of glue code to get lua working -- type luacfunc = proc(luaSta

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
Yea, that means building love2d, and I'm not really willing to do that. Either way I think luaJIT is a nice thing to keep. How can I build a lua table in Nim? I was thinking maybe I could get away with doing that, if I can get those procs in it and push it to the lua stack, I might be able to r

How to get my nim procs in a lua table

2020-09-02 Thread lucian
btw, kind of indicates support for newer versions (unless you really want to stick with 5.1 for JIT).

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
Sadly, `luaL_Reg` isn't working for me. Probably because I'm using lua 5.1. `luaL_Reg` is defined in the [lua 5.2 file](https://github.com/nim-lang/lua/blob/ffa21d38172a6f654066f4c2c761d0cb2e915ffa/src/lua52.nim#L529) I have to use 5.1, since I'm using Love2d.

How to get my nim procs in a lua table

2020-09-02 Thread lucian
I have used this template: let L = createLuaState() openlibs(L) # overload the heck out of it proc dsSetValue*(key: string; value: string) = proc dsSetValue*(key: string; value: byte) = proc dsSetValue*(key: string; value: seq[byte]) = proc dsSetValue*(key

How to get my nim procs in a lua table

2020-09-02 Thread Skaruts
I'm using the [nim-lua bindings](https://github.com/nim-lang/lua) to make a dll that can be loaded from lua, but I can't figure out how to bind this library to a lua table. In C, you could do this (took this code partially from a tutorial): int luaopen_testlib(lua_State *L) {