Ok, moving my first post down so i can edit and keep the 1st one for updates or releases, IF that happens, (I'm still trying though,

)
This is just to archive some the information/code and the discussion i wanted to start, while keeping the first post free.
========================================================================
Well first off. Hi,

ive been lurking around here for a few years, never had much of a reason to post cause i can never convince myself to keep bb installed longer then a few days*, so id just drop by to check on updates or play with plugins,
(*Nothing against BB, its just always some windows function i find out i use more then i thought i did, ...for instance the 'most used programs' bit in the start menu, handy that,

)
And yes, my first post and its a poll, i know how that looks, -_-
I normally dont do polls, but im honestly curious what people think about the idea.
So anyways, warning, this post is a little code'y, and im ...wordy at times, so it'll be long,

i wanted to post this is the Dev Corner, but seems i cant or im not allowed, or something, idk,
no 'new thread' button *shrugs*
though it should fit just as well here too,
Anyways, as i said
here, ive just started learning Lua, and im amazed by the unseen/unused possibilities of it,
so while playing with it and iupLua i thought itd be a Great addon to Blackbox as a plugin, OR embedded in bb to run scripts in the same way it runs plugins, or do GUI work,
(the more i fool with it, the more i think the latter)
Anyways, so i tried, and ...didnt get very far.
(Ive played with C++ for years, but theres reasons i never really get anywhere with it, -_-
so chance are ive probably screwed this up trying to implement it, ^-^;)
For some reason after running a Lua script, blackbox crashes,
i have an idea which i'll post on where it comes up in the code, but im hoping either you can guys here can help me with this, or one of you more talented coders can take off with it,
So heres how i got to what i have, i started with this:
Code:
#include <stdio.h>
extern "C"{
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
/* the Lua interpreter */
lua_State* L;
int main ( int argc, char *argv[] )
{
/* initialize Lua */
L = lua_open();
/* load Lua base libraries */
luaL_openlibs(L);
/* run the script */
luaL_dofile(L, "init.lua");
/* cleanup Lua */
lua_close(L);
return 0;
}
(Yes, im using 'luaL_dofile' because for some reason 'luaL_loadfile' wont run my script)
because i cant find a script to exe compiler, i made a launcher, ...which has its own problems that also comes up in the plugin im trying to make,
so i wanted to do that in BB, after getting DevC++ to compile the pluginSKD and setup for lua,
i took the above main() funtion and replaced the about_box() funtion in the SDK, i tried to compile but kept getting this error:
Quote:
too few arguments to function `int about_box(int, char**)'
i kept the name about_box(), then i killed the int and made it back into a void, so,
void about_box(void)
got rid of the return ofcourse,
so i uncommented the about_box() function, created my own runlua() function, replaced the about_box() in the 'WM_LBUTTONDBLCLK:' bit to runlua() ...and it still crashes after running a script,
Now, im Pretty sure this is whats causing Blackbox to crash,
i mean, taking the " int argc, char *argv[] " out of the function,
but i cant figure out how to make it call the function with it,
if i leave the function like this:
Code:
int runlua( int argc, char *argv[] )
and i change the 'WM_LBUTTONDBLCLK:' like so:
Code:
case WM_LBUTTONDBLCLK:
/* Do something here ... */
runlua();
break;
it gives me this error trying to compile it:
Quote:
too few arguments to function `int runlua(int, char**)'
Ive even taken the code out of the function and placed it like so:
Code:
case WM_LBUTTONDBLCLK:
/* Do something here ... */
{
/* initialize Lua */
L = lua_open();
/* load Lua base libraries */
luaL_openlibs(L);
/* run the script */
luaL_dofile(L, "init.lua");
/* cleanup Lua */
lua_close(L);
}
break;
this compiles, BUT, crashes blackbox after a script is run,
so that is problem #1, ...and the more important one because if that isnt fixed, problem two doesnt matter so much,
but problem #2 is:
it seems no matter What i do this to:
Code:
/*
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/
#define LUA_LDIR "!\\lua\\"
#define LUA_CDIR "!\\"
#define LUA_PATH_DEFAULT \
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
#define LUA_CPATH_DEFAULT \
".\\?.dll;" ".\\?51.dll;" LUA_CDIR"?.dll;" LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\?51.dll;" LUA_CDIR"loadall.dll;" LUA_CDIR"clibs\\loadall.dll"
in the 'luaconf.h'
ALL the lua scripts and .dlls Have to be in the same folder as the blackbox.exe in order to run,
(Same problem my launcher is having, -_-)
meaning i cant get it to run scripts or detect the .dlls in a subfolder,
ideally, youd want them in a subfolder of the lua-plugin folder so you can run 1-2 plugins that might launch different scripts or the same scripts where they wont interfer with each other,
Also note, i dont have lua 'installed', i just unziped the
windows binarys and started playing with it,
so i dont have lua environment paths set or anything,
(Personally, i dont like installing software if i dont have to, 90% of the stuff i use comes from:
The Portable Freeware Collection.)
Ok, now that im past all my problems and coding and so on, the discussion part of my post,
i'll keep this short considering the wall of text i put above, ^-^;;
while messing with this, it occurred to me, that Blackbox might be better benefited with Lua embedded, where it would run the scripts in the same manner it runs plugins,
So what do you guys think?
mebey Yet another Blackbox branch that embeds Lua?
Yes?
No?
You expect us to Read all of this?

*ahem* ^-^
...IS there even really a difference between a plugin and having it embedded?
i mean, could a plugin be made to mimic how blackbox runs scripts and just do it that way?
Would embedding it and using like the wx or iup dlls make doing GUI easyer?
(Yes, i know, i cant even get a plugin to work, how on earth would i embed Lua into BB, ...Truthfully, ive no clue, right now im just curious as to what everyone thinks.)
Anyways,
Sorry my first Real post is a little ...long,
...and a poll, -_-
But hopefully you guys can help me fix/improve the plugin here so itll get into a semi working order,
heh, i do not look forward to try tieing it into broams when i cant even get it compiled in the first place, -_-