** Lua Help: I'm Paying **

Started by
4 comments, last by Prozak 19 years, 1 month ago
I give up on this... I either don't have the time, or the skills are eluding me... Here's what I want: To have a simple app run in a Pocket PC, using Lua scripts. I don't need any of Lua's libraries, whatever functions I want, I can design and code them... but I do need a functional interpreter... So just present me with an app that calls a lua function in a script, and that script calls a C function back, and I'll be all happy [wink] What I offer: I'll pay you 3 Months of GD.Net membership, once I get the source code and compilables working under Embedded C++. Whoever wants to help me out, and has what I'm asking for, can PM or email me for the details of where to submit the source code, etc...
Advertisement
/* On the house :) */

extern "C"
{
#include "lua.h"
}

int cFunction(lua_State *luaState)
{
return 0;
}

const char luaScript[] =
"function luaFunction() cFunction() end";

/* This script loader is basically a reproduction of the
lauxlib function luaL_loadbuffer() */
typedef struct
{
const char *chunk;
size_t size;
} LuaChunk;

const char *luaChunkReader(lua_State *luaState, void *data, size_t *size)
{
LuaChunk *loadChunk = (LuaChunk *)data;
if (loadChunk != NULL && loadChunk->size != 0)
{
*size = loadChunk->size;
loadChunk->size = 0;
return loadChunk->chunk;
}
return NULL;
}

int main(int argc, char *argv[])
{
lua_State *luaState;
LuaChunk luaChunk = { luaScript, sizeof(luaScript)-1 };

luaState = lua_open();

/* create a global variable called "cFunction"
containing the C function */
lua_pushstring(luaState, "cFunction");
lua_pushcfunction(luaState, cFunction);
lua_settable(luaState, LUA_GLOBALSINDEX);

lua_load(luaState, luaChunkReader, &luaChunk, "luaScript");
/* lua_load() compiles the script into a function */
/* call the function to run the script */
lua_call(luaState, 0, 0);

/* get the global function created by the script and call it */
lua_pushstring(luaState, "luaFunction");
lua_gettable(luaState, LUA_GLOBALSINDEX);
lua_call(luaState, 0, 0);

lua_close(luaState);
return 0;
}

[Edited by - corysama on March 16, 2005 1:32:52 AM]
Thank you for your time Corysama.

Unfortunately the code you posted is well known to me. I know how to initialize Lua, in fact I'm about to finish up a Lua Tutorial I've been working on since December, but haven't got the time to actually finish it.

My problems seems to be connected with the generation of the Lua libraries in a Pocket PC environment, and their correct integration with the project.

If anyone can solve this problem for me, and because I have so little time left for this project, I can either offer you a 3 month GD.NET subscription, or make a donation in the same value, in your name to GD.Net.

Thanks for any help on this.
anyone?
Can't you just use a cross-compiler and build the libraries? What kind of processor do you have and which OS does the PPC run? I have a copy of Embedded Visual Studio 4 somewhere and could just compile it for the required target(s) if you want...
I've got an IPaq 3660, it has an ARM processor, and I think it runs Windows CE 2000, or maybe 2002.

All I want is a project space, under embedde visual c++, that compiles the libraries for Lua, and has a small demo app using the library and interfacing with some lua code. The more simple it is, the better.

Just compile it, see if it all works out, zip it and email me [wink]

If it works out we can discuss your reward details [wink]

This topic is closed to new replies.

Advertisement