lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

From: [] On Behalf Of Leinen, Rick
Sent: Thursday, July 17, 2014 2:26 PM
Subject: User-Defined Types




I’ve been reading chapter 29 of Programming in Lua 3ed.  I understand everything from the beginning of the chapter through 29.1 except for one thing.  How does Lua get the function name “array”?  I understand how the library array works for registering the functions “new”, “set”, etc, but when the text shows the line “a =, how does the label “array” get associated with the library?


I’m sure there must be a simple answer, it’s just alluding me.







Thanks to Doug Currie for clearing this up for me!


I’m still working on proof-of-concept on my project and currently do not have a file system in place on my target.  Registering the new library worked just fine, but when I enter, array = require "arraylib", from my shell interface I get the following response:


[string "array = require "arraylib""]:1: module 'arraylib' not found:

        no field package.preload['arraylib']

        no file '/usr/local/share/lua/5.2/arraylib.lua'

        no file '/usr/local/share/lua/5.2/arraylib/init.lua'

        no file '/usr/local/lib/lua/5.2/arraylib.lua'

        no file '/usr/local/lib/lua/5.2/arraylib/init.lua'

        no file './arraylib.lua'

        no file '/usr/local/lib/lua/5.2/'

        no file '/usr/local/lib/lua/5.2/'

        no file './'


Is there a way to use this userdata method without a file system?  I got around this problem with my C functions using the following:


void LCAN_RegFunctions( lua_State *L )


  lua_pushcfunction(L, LCAN_LuaSendChanFade);

  lua_setglobal(L, "LCAN_SendChanFade");

  lua_pushcfunction(L, LCAN_LuaAddDimmer);

  lua_setglobal(L, "LCAN_AddDimmer");