ILua scripting

by Unknown

Back to Project L.

Unknown2007-10-24 05:21:48
QUOTE(mitbulls @ Oct 24 2007, 12:46 AM) 452807
I'm still missing something here. I started with the code that Zarquan has in the first post, which echoed the new prompt nicely but didn't gag the old prompt. If I change it to just replace (-1, new prompt), it does not display the new prompt at all, just the old prompt. If I try to use hide_line, I get an error about trying to use a global function (which makes me assume that I'm on the old version and hide_line doesn't exist yet). If I'm on the new version, it seems like hide_line(-1) should do it. If I'm on the old version, it seems like mb.gag_line=true should do it, but for some reason neither one seems to be working.

Any other ideas I might be missing?

Then you most likely are on the old, sixth release. Don't know why it doesn't work for you though. Tried replace("New prompt> ")? Or to use both mb.gag_line=true and mb.gag_ending=true? Other than that I don't know. It should work.

QUOTE(mitbulls @ Oct 24 2007, 12:46 AM) 452807
I might try to get the files off of the SF SVN. Is that what you were talking about, or is there another CVS somewhere?
.
EDIT: I take that back, I can't connect to the SF SVN; should have seen that coming

IMTS doesn't use SVN, only CVS. What happens when you try to connect?
Unknown2007-10-24 10:28:02
QUOTE(CroX @ Oct 24 2007, 12:21 AM) 452906
Then you most likely are on the old, sixth release. Don't know why it doesn't work for you though. Tried replace("New prompt> ")? Or to use both mb.gag_line=true and mb.gag_ending=true? Other than that I don't know. It should work.
IMTS doesn't use SVN, only CVS. What happens when you try to connect?


I tried using both together, but somehow even that didn't get through.

Ohh...IMTS, I was still looking at the LMTS site...

If I compile the new version of IMTS, I'll be back to the problems of before LMTS (i.e. not recognizing balance loss to cows/sheep, etc). Is it possible to compile the Lua section of IMTS with the rest of the code from LMTS? I haven't been able to connect to the LMTS SVN to download the latest code from it (I assume it's a permissions issue?) but if I could I could try compiling them together to get the changes from LMTS along with the new lua support from IMTS.

EDIT: Unless, of course, when he says modularized he actually means modularized, so I can just compile the Lua dlls and replace the ones I have. I am used to assuming that modularized programs are not actually that well designed, though. Guess I'll find out!
Unknown2007-10-24 11:14:15
It's not a permissions issue. You need to use CVS instead of Subversion. tongue.gif
Unknown2007-10-24 12:27:49
QUOTE(Zarquan @ Oct 24 2007, 06:14 AM) 452957
It's not a permissions issue. You need to use CVS instead of Subversion. tongue.gif


I don't see anything in a CVS for LMTS...is it not hosted on SF? I tried :pserver:anonymous@lmts.cvs.sourceforge.net:/cvsroot/lmts, as well as just lmts.sourceforge.net for the server. The first connects but doesn't find anything, the second isn't found. If I manually browse to http://lmts.cvs.sourceforge.net, it's empty. All of the files seem to be in the SVN repository there; I can browse through the http list, but I can't actually connect to it with tortoise.

Is the user name/password something different, or am I just not connecting correctly? I'm still new to all of this new-fangled open source stuff...people who write code for free during their free time then give it away have always confused me, but projects like this are looking more and more fun.
Unknown2007-10-24 15:34:50
Lusternia Modularized Trigger System (LMTS) uses Subversion (SVN). Imperian Modularized Trigger System (IMTS) uses Concurrent Versions System (CVS). All the acronyms might get confusing but that might sort it up for you. Either way, both repositories works just fine and I just controlled that.

To checkout LMTS, please use this:
CODE
svn co https://lmts.svn.sourceforge.net/svnroot/lmts lmts


If all else fails, try with the sources attached to this post, which I just pulled down from the CVS of IMTS. It got the new ILua and it's dependancies. I hope that's all it needs atleast.
Unknown2007-10-24 19:30:43
I got all of the files down from the IMTS CVS and tried compiling them, but now I'm getting compiler errors. It doesn't like the use of __attribute__ in some of the global functions:

CODE
In file included from c:\\users\\tim\\desktop\\imts\\i_lua.c:13:
c:\\users\\tim\\desktop\\imts\\module.h:60: argument format specified for non-function `prefixf'
c:\\users\\tim\\desktop\\imts\\module.h:61: argument format specified for non-function `suffixf'
c:\\users\\tim\\desktop\\imts\\module.h:67: argument format specified for non-function `debugf'
c:\\users\\tim\\desktop\\imts\\module.h:69: argument format specified for non-function `logff'
c:\\users\\tim\\desktop\\imts\\module.h:72: argument format specified for non-function `clientff'
c:\\users\\tim\\desktop\\imts\\module.h:75: argument format specified for non-function `mxp'
c:\\users\\tim\\desktop\\imts\\i_lua.c: In function `ilua_gettimeofday':
c:\\users\\tim\\desktop\\imts\\i_lua.c:1062: storage size of `tv' isn't known


I've heard of some other people having this problem with different versions of gcc. Is this a gcc problem or a problem with the header.h file?

Once I finally get all of this compiled and working, I promise to leave you all alone and start having more fun with lua scripting...
Unknown2007-10-24 20:25:20
I compile with MinGW and it works for me, though I haven't tried the very latest IMTS code yet. So, if you're using a compiler other than MinGW, I'd recommend downloading that and trying again.
Unknown2007-10-25 05:49:07
I tried all the examples I could find to make aliases, and got some to actually work, but no matter what I do, when I enter the alias it executes, but in the end it also sends the alias name and I get the error message from lusternia that it doesn't understand what I was trying to do.
I'm using MushClient.

Can anyone help, or should I just use MushClient's aliases?

Thanks
Unknown2007-10-25 11:23:34
Honestly, I'd recommend that you use MUSHclient's aliases. The only reasons I could think of to use ILua aliases is either that you've built something (combat system, for example) in ILua and need to interface with it or your client doesn't support advanced scripting. MUSHclient supports Lua very well, so you're better off with that.
Unknown2007-10-25 11:25:07
QUOTE(waldor @ Oct 25 2007, 07:49 AM) 453212
I tried all the examples I could find to make aliases, and got some to actually work, but no matter what I do, when I enter the alias it executes, but in the end it also sends the alias name and I get the error message from lusternia that it doesn't understand what I was trying to do.

If I recall it correctly offhand, you'll need to "return true" to stop the input parser from sending the text to the server.
Unknown2007-10-25 12:41:19
QUOTE(Zarquan @ Oct 24 2007, 03:25 PM) 453057
I compile with MinGW and it works for me, though I haven't tried the very latest IMTS code yet. So, if you're using a compiler other than MinGW, I'd recommend downloading that and trying again.


I was using whichever version is installed with Dev-C++. I think it actually uses MinGW, but I tried downloading MinGW itself just to be sure. Now I'm ending up with a whole new problem, though: MinGW can't find CC1.exe. I know a lot of people have had this problem with it, and it's usually just fixed by a reinstall. I tried with v. 5.1.3, reinstalled it, then switched to 4.1.1, reinstalled it, and still have the same problem. The bizarre part is that the file does exist, and the path is one of the search paths:

QUOTE
programs: =../libexec/gcc/mingw32/3.4.2/;../libexec/gcc/;/mingw/libexec/gcc/mingw32/3.4.2/;/mingw/libexec/gcc/mingw32/3.4.2/;/mingw/libexec/gcc/mingw32/;
/mingw/lib/gcc/mingw32/3.4.2/;/mingw/lib/gcc/mingw32/;/usr/libexec/gcc/mingw32/3.4.2/;/usr/libexec/gcc/mingw32/;/usr/lib/gcc/mingw32/3.4.2/;/usr/lib/gcc/mingw32/;
../mingw32/bin/mingw32/3.4.2/;../mingw32/bin/;/mingw/mingw32/bin/mingw32/3.4.2/;/mingw/mingw32/bin/
libraries:=../lib/gcc/mingw32/3.4.2/;../lib/gcc/;/mingw/lib/gcc/mingw32/3.4.2/;/usr/lib/gcc/mingw32/3.4.2/;../mingw32/lib/mingw32/3.4.2/;../mingw32/lib/;
/mingw/mingw32/lib/mingw32/3.4.2/;/mingw/mingw32/lib/;/mingw/lib/mingw32/3.4.2/;/mingw/lib/;../lib/mingw32/3.4.2/;../lib/;/mingw/lib/mingw32/3.4.2/;
/mingw/lib/;/lib/mingw32/3.4.2/;/lib/;/usr/lib/mingw32/3.4.2/;/usr/lib/


QUOTE
C:\\MinGW\\libexec\\gcc\\mingw32\\3.4.2>dir
Volume in drive C has no label.
Volume Serial Number is 04EE-6168

Directory of C:\\MinGW\\libexec\\gcc\\mingw32\\3.4.2

10/25/2007 07:27 AM .
10/25/2007 07:27 AM ..
09/21/2004 03:13 AM 4,419,584 cc1.exe
09/21/2004 03:13 AM 4,483,072 cc1obj.exe
09/21/2004 03:13 AM 4,893,696 cc1plus.exe
09/21/2004 03:13 AM 87,552 collect2.exe
09/21/2004 03:13 AM 3,813,376 f771.exe
09/21/2004 03:13 AM 5,439,488 gnat1.exe
09/21/2004 03:13 AM 4,382,208 jc1.exe
09/21/2004 03:13 AM 11,776 jvgenmain.exe
8 File(s) 27,530,752 bytes
2 Dir(s) 68,284,841,984 bytes free


I'm starting to think maybe it's just not meant to be. I tried copying all of these files from this folder and just pasting them in the BIN directory instead. It found them all then, but came up with an endless string of errors. I might have been missing the header files in the include directory, though. I'll try putting those in, moving these to the BIN, and try it again. Faililng that, I'm out of ideas.
Unknown2007-10-25 14:08:39
My guess is that you can't compile the newer ILua without dependencies from the core IMTS source files. A hybrid LMTS with the new ILua may not be possible without tweaking the LMTS code to make things fit together.
Unknown2007-10-25 21:49:53
QUOTE(Zarquan @ Oct 25 2007, 04:08 PM) 453270
My guess is that you can't compile the newer ILua without dependencies from the core IMTS source files. A hybrid LMTS with the new ILua may not be possible without tweaking the LMTS code to make things fit together.

I'd second Zarquan's guess. You could try pulling down IMTS, compile it and only use the core with ILua, and then get LMapper from LMTS. No idea if they're compatible or not though. It's either that or redo the modifications me and Zarquan did to IMTS, for the LMTS release, all over again with the new IMTS.
Unknown2007-10-26 12:49:55
QUOTE(CroX @ Oct 25 2007, 04:49 PM) 453380
I'd second Zarquan's guess. You could try pulling down IMTS, compile it and only use the core with ILua, and then get LMapper from LMTS. No idea if they're compatible or not though. It's either that or redo the modifications me and Zarquan did to IMTS, for the LMTS release, all over again with the new IMTS.


I think it would be easier to just make it work with the old version instead. So, failing getting this dll to compile, I decided to start over. I deleted LMTS and downloaded the latest binaries from sourceforge, and copied the code from the first post into the matching files. For some reason, it still refuses to gag any of the prompts for me. Every prompt, I get this:

CODE
3900h, 3158m, 3900e, 10p, 17600en, 14000w elrx-
3900h, 3158m, 3900e, 10p, 17600en, 14000w 68% -


It's the exact same result as when I comment out the lines setting mb.gag_line and mb.gag_end to true. Replace also doesn't seem to work, whether I use it on its own or together with mb.gag_line. If I use the two together, it gags the new prompt and displays only the normal Lusternia prompt. If I comment out mb.gag_line, it shows both prompts again.

I've also tried simple things like switching the return values, but they don't seem to affect anything. Do either of you have any suggestions what else I might try? If not, it may be about time for me to give up the lua scripting for awhile until cMUD is stable enough to use exclusively.
Unknown2007-10-26 16:56:11
I get prompts displayed like that when I have the newline added via CONFIG PROMPT ADD LINEBREAK. Try removing the linebreak in Lusternia and see if the extra one goes away. wink.gif
Unknown2007-10-29 11:31:07
QUOTE(Zarquan @ Oct 26 2007, 11:56 AM) 453610
I get prompts displayed like that when I have the newline added via CONFIG PROMPT ADD LINEBREAK. Try removing the linebreak in Lusternia and see if the extra one goes away. wink.gif


You, sir, are a gentleman and a scholar.

Now I just have to get some of my other scripts to work. Thanks for all of the help so far, I have no doubt that I will have a ton of other questions.
Unknown2007-10-30 13:36:47
I knew this wouldn't take long.

I tried writing several scripts without testing them. I finally tried online testing, only to find out none of them worked. I went back and cleared them all, and started over again with just the triggers. I added these lines to config.ilua.txt, making sure to leave a couple of blank lines before and after them:

CODE
module "afftracker"
load "affs.lua"


Then, in affs.lua, I added this function:

CODE
function trigger_handler()
  echo("Start")
  return false
end

mb.server_lines = trigger_handler


When I connect, I see that the iLua module is loaded (and the prompt is working now). The afftracker lua module is also loaded correctly, but I never see any echos; the trigger_handler function doesn't ever seen to fire. I've looked over the IMTS documentation, and there doesn't seem like there should be a lot more to it than this for such a simple trigger handler. Am I missing something simple?
Xinael2007-10-30 15:03:50
This was a while ago, so it might've been fixed, but I had to leave a few blank lines at the bottom of the file and put a comment there for it to work. So after the last load, my file looks like this:

CODE
load "something.lua"


#lol


and it's working.
Unknown2007-10-30 17:15:06
QUOTE(Xinael @ Oct 30 2007, 10:03 AM) 454496
This was a while ago, so it might've been fixed, but I had to leave a few blank lines at the bottom of the file and put a comment there for it to work. So after the last load, my file looks like this:

CODE
load "something.lua"
#lol


and it's working.


I tried that, but didn't have much luck. My config.ilua.txt looks like this now:

CODE
# ILua configuration file.

# This file is sectioned in modules. Each module has its own globals, and
# modules cannot communicate between them. A module may load any number of
# Lua script files.

# Example of an ILua module:

#module "Foo"
#load "example1.lua"
#load "example2.lua"

module "cool"
load "triggers.lua"


module "afftracker"
load "affs.lua"


#test
Unknown2007-11-18 23:23:20
Okay, thanks for all of the help so far! I figured a lot of things out and have made a lot of progress. I'm working on making a complete system in ILua (possibly to sell someday, if by some accident it actually works well). I finally found out my original problem, which was simple enough: the version of IMTS that was adapted to LMTS was before the lines change. I downloaded off of SF, and changed it to use mb.server_line and the old syntax instead, and everything is now up and running. Now, though, I have a new question for the people who actually know Lua.

I am having trouble finding an example of calling a function that is stored in a table by its table index. For example, I have table t. t = function A, t = function B, t = function C, etc. I want to loop through table t, and call each of the functions in order. So, for example, something like:

for i, f in ipairs(t) do
-- somehow execute function f
end

Can anyone give me a suggestion (or better yet, an example) for how this would be done?

Thanks!