struct hwCmdStruct *list = GetCommands(void);
struct hwCmdStruct
items
that contains a number of commands this plugin wants to make available. The array
must be terminated by two NULL
elements. struct hwCmdStruct
looks like this:
struct hwCmdStruct { STRPTR Name; int (*Func)(lua_State *L); }; |
You have to specify a name and a function pointer for every command that you want to add. Functions must be implemented as Lua C functions. Please check the manual of Lua 5.0.2 to find out how Lua C functions are implemented. See Library plugins for some more details on how to implement Lua functions. The array that is to be returned by this function may look like this then:
struct hwCmdStruct plugin_commands[] = { {"TestFunc", hw_TestFunc}, {"TestFunc2", hw_TestFunc2}, ... {NULL, NULL} }; |
All functions that you specify here will then be pushed into the Lua table whose name has been specified using GetBaseTable(). The user can then call your functions like this:
testplugin.TestFunc() |
struct hwCmdStruct
elements