PtokaX forum

Development Section => Your Developing Problems => Topic started by: zxcvbn on 06 March, 2004, 06:24:17

Title: Modular LuaScript
Post by: zxcvbn on 06 March, 2004, 06:24:17
Please can people tell me how to make an efficient template for modular script, so that command parsing functions are not duplicated without need, and with the ablilty to switch off modules in a top level file, so that the module files can be absent if they are not wanted?

I've used the search and this is one major topic that for some reason gets no discussion at all that I could find..
Title:
Post by: Skrollster on 06 March, 2004, 20:43:11
check out this one:

http://skrollan.myftp.org/Bot.lua
Title:
Post by: zxcvbn on 07 March, 2004, 03:24:10
Thankyou.
I don't see how it can help me though. It's not modular the way I need. I mentioned needing to use seperate files, and that implies the dofile() function, which isn't in that script. Also, I do need a basic template, if anyone is able to paste or write one. :) It just needs a minimum of code, but needs to show how to get past the problem of global variables somehow not being available to the LuaScripts called by dofile().
Also, maybe there are other ways? The only thing that matters being that the script have one main header file, and an easy way to make seperate modules, added as required. I just need to frame this idea for now. Until I have that understood, it's going to be too difficult to extract it from a large existing script, which is why I'd like a template. :)
Title:
Post by: zxcvbn on 07 March, 2004, 12:07:50
ok, looks like I might have got there first. :)
the script I was looking at had two gotchas in it, one a local var named same as an earlier declaration of a global var, the other being that variables used as input receivers from functions are local and not global, something that did not get noticed till the attempt to cut up the script.

Anyone know of any other gotchas that might affect this?

Also, if anyone is willing, I think a small tutorial example of modular script templates in the how-to section here would be a good thing. I'd do it myself but I doubt I'm anywhere near competent.
Title:
Post by: Skrollster on 07 March, 2004, 12:25:40
it was a loong time (4?month) since i did write a real script so i have to do a bit of reading to fresh up my mind, but I'll show you how to make a modular script of mine.. and I'll show you why it is one of the best ways..

But it might take some time though, since sparetime is something i don't have in large quantities  now a day..
Title:
Post by: plop on 07 March, 2004, 17:05:49
take a look @ the startup.lua file from bcdc++, that works in a modulair way.

plop
Title:
Post by: Skrollster on 07 March, 2004, 21:07:16
ok, seems like i don't have to make any example for you...

what i have done so far is:

http://skrollan.myftp.org/LuaExample.rar
Title:
Post by: zxcvbn on 07 March, 2004, 22:50:24
ty both, I think I have it now though, and have some things done based on it..
Skrollster, that RAR won't download in one piece, and plop, that Startup.lua is not modular, it just has seperate functions. No use of dofile() at all.

My posts are long, I guess, but I do wish people would read them carefully. :) Would save me having to post more for you to read, for a start...



Plop, I had a look at that client, and I really want to use it.
But there has been a sticking point that has stopped me.
Since just after v0.242 of BCDC++ there is a scrolling bug in the main chat that makes it leap up the screen like a broken windowblind every time the main window regains focus. I have found that this bug is not in the DC++ original app. What is worse, the bug has got really bad in this latest client, or in some other very recent version of BCDC++. Now, all the text leaps out of sight, right off the top of the chat pane, the instant I enter any text. Sometimes it shows just the last line, mostly nothing at all. I tried sending chat from the PtokaX hub too, and same happens. Chatting with this thing, or even trying to read it, would be utterly impossible! I'd be fighting to keep it in view, let alone actually read a word at a time....
I don't know how to reach the people who code it, or even who they are, so can you help me with this? Others have seen this bug, but no-one I know knows anything about it, and I'm not sure it appears in all situations.

Sorry to post so off-topic, but I have nothing better to do until I can find a more direct way to talk to the people who can help.
Title:
Post by: Skrollster on 07 March, 2004, 23:45:06
Hi, unfortunetly my webserver seems to bug some times, i have uploaded the file to another server now..

http://hem.bredband.net/light/LuaExample.rar

this file isn't finnished yet, but it might be enought for you...
Title:
Post by: plop on 08 March, 2004, 00:07:52
QuoteOriginally posted by zxcvbn
ty both, I think I have it now though, and have some things done based on it..
Skrollster, that RAR won't download in one piece, and plop, that Startup.lua is not modular, it just has seperate functions. No use of dofile() at all.

My posts are long, I guess, but I do wish people would read them carefully. :) Would save me having to post more for you to read, for a start...



Plop, I had a look at that client, and I really want to use it.
But there has been a sticking point that has stopped me.
Since just after v0.242 of BCDC++ there is a scrolling bug in the main chat that makes it leap up the screen like a broken windowblind every time the main window regains focus. I have found that this bug is not in the DC++ original app. What is worse, the bug has got really bad in this latest client, or in some other very recent version of BCDC++. Now, all the text leaps out of sight, right off the top of the chat pane, the instant I enter any text. Sometimes it shows just the last line, mostly nothing at all. I tried sending chat from the PtokaX hub too, and same happens. Chatting with this thing, or even trying to read it, would be utterly impossible! I'd be fighting to keep it in view, let alone actually read a word at a time....
I don't know how to reach the people who code it, or even who they are, so can you help me with this? Others have seen this bug, but no-one I know knows anything about it, and I'm not sure it appears in all situations.

Sorry to post so off-topic, but I have nothing better to do until I can find a more direct way to talk to the people who can help.
take a look @ phantomDC and report the bug there, 1 of the bcdc++ programers is registered there (sedules).
i use the same forum 2 talk 2 him on developing the lua part of bcdc++.
they don't have a forum themselfs (they don't want 1), or look for them in the dc-dev hub.
if the bcdc++ crew doesn't fix the problem twink (phantomDC programmer) may do it.

the dofile is needed 2 load the modules, again on the phantomDC website you can find the links 2 the latest script version.
things have changed since the last version has been released of the client.
you'll see that it now is more modulair then you think.
sedules isn't planning 2 make support 2 just have the main script load every lua file from a folder so i'm planning 2 make a add-on for it which does that.
on the phantomDC forum you can also find a couple scripts/modules i made.

plop
Title:
Post by: zxcvbn on 08 March, 2004, 10:20:02
Thanks, Skrollster, I got it this time. I can't help thinking it might be more complex than it needs to be. :) It's helpful though. Is there an advantage to reading the file to a variable and using dostring() as opposed to just using dofile()?
Plop, ty again. I found Sedulus. I got briefly lost looking for phantomDC on Google, but I found he'd been active very recently on the DC++ Sourceforge forum, and I sent a PM from there.
Title:
Post by: Skrollster on 08 March, 2004, 11:11:34
It's a bit more complex then it needs to be, i know that.. but it is much more flexible and extendeble this way...

And why should i remove some code from my script that i'm working on?
This is going to be my new framework for my next script, if ptaczek ever will implement the database support...
Title:
Post by: plop on 08 March, 2004, 11:11:54
QuoteOriginally posted by zxcvbn
Plop, ty again. I found Sedulus. I got briefly lost looking for phantomDC on Google, but I found he'd been active very recently on the DC++ Sourceforge forum, and I sent a PM from there.
yw.
here (http://pdc.recoil.net.nz/) is the phantomDC site/forum.

plop