Modular LuaScript
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Modular LuaScript

Started by zxcvbn, 06 March, 2004, 06:24:17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zxcvbn

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..


zxcvbn

#2
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. :)

zxcvbn

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.

Skrollster

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..

plop

take a look @ the startup.lua file from bcdc++, that works in a modulair way.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Skrollster

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

zxcvbn

#7
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.

Skrollster

#8
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...

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

zxcvbn

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.

Skrollster

#11
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...

plop

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 is the phantomDC site/forum.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk