Just as how it's done from any other languages:
    
    
    import lua
    
    proc nimluafunc(L: PState): cint {.cdecl.} =
      let i = tonumber(L,1)
      let j = tonumber(L,2)
      let k = i + j
      pushnumber(L,k)
      result = 1
    
    let l = newstate()
    openlibs(L)
    register(L, "callablefromlua", nimluafunc)
    discard dostring(L,"""
      x = callablefromlua(3,7)
      print(x)
    """)
    

Reply via email to