Combining small scripts into a bigger one
 

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

Combining small scripts into a bigger one

Started by bolamix, 06 July, 2004, 13:37:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bolamix

Hiya all,

I've been hosting a hub on Ptokax for almost 2 years now, and have played around with scripts a lot, thanks to the many incarnations of this board :D. I've kept and modded those I like, and now I've got 8 scripts running together, which, as you can imagine, takes quite a lot of mem. I have a PIII@1 GHz and 384 Mb RAM, but still get some uncomfortable lag on the hub. I've tried to combine the smaller scripts into bigger ones but am getting nowhere, the result is full of errors and I get lost among the elseif's and strsub's.
Would some kind and knowledgeable scripter be willing to give me a hand in this? If you have some spare time, if you're on holiday, if you're bored, even :D... drop me a line in pm or by email, maybe we can work out a trade or something (i'm heavily into live music).

Or I could post the small scripts here and it might be an education for someone else, too... I'm using LIS so this one stays standalone but I also use:
- Ban/unban Bot ver 1.2 by Neo
- HelpBot by Piglja & aMutex
- InfoBot by lallo82 & plop
- a "nickcheck" bot put together by myself using various sources to prevent users with unwanted tags and nicknames (descriptions too, optionally) to get into the hub
- offlinemsg.lua, by aMutex
- Roulette-Bot 1.0 translated to LUA by MatrixX (this one can stay standalone too)
- and SlotsBot by OpiumVolage

That makes 6 scripts to combine ideally into 1. I'm using the same botname for all scripts. How does that sound? Am I even in the right part of the board? :P

Thx in advance!
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

Herodes

QuoteOriginally posted by bolamix
- a "nickcheck" bot put together by myself using various sources to prevent users with unwanted tags and nicknames (descriptions too, optionally) to get into the hub

Can u post this one pls ? :D

bolamix

QuoteOriginally posted by Herodes
QuoteOriginally posted by bolamix
- a "nickcheck" bot put together by myself using various sources to prevent users with unwanted tags and nicknames (descriptions too, optionally) to get into the hub
Can u post this one pls ? :D
Lol why didn't I post it straight away? I should've known...  Ah well, here goes, but please bear in mind this is not the objective of this thread... can you help with combining?
blocked = {
-- put the tags and nicknames (or nicknames' parts) you want to block in here, letters all in lowercase
-- examples:
"abc",
"%[123%]abc" -- no comma after the last line
}

function DataArrival(curUser, Data) 
	if strsub(Data, 1, 13) == "$ValidateNick" then 
		nick = strsub(Data, 14)
		for i,v in blocked do
			if strfind(strlower(nick),v) then 
				curUser:Disconnect() 
			end
		end
	end
--	if strsub(Data, 1, 7) == "$MyINFO" then
--		description = strsub(Data, 8)
--		for i,v in blocked do
--			if strfind(strlower(description),v) then 
--				curUser:Disconnect() 
--			end
--		end
--	end
end
It's very quick'n dirty and simply disconnects users without even sending a message. The aim is to discourage people from trying to connect without overloading PermBan.dat and without them trying to circumvent the ban. I'd love a bot that could send "unknown address" even before the "This hub is running Ptokax etc..." but I doubt that it is feasible.
The last part that is commented out is to disconnect if the string is found in the user's description. But you can easily end up alone in the hub with this :P
And yes I know it's very primitive lol
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

plop

from what i can see is that you are using ptokax TD.
if the lag starts about 7-8 day's there is nothing more you can do then restart ptokax just before that.
it's a bug in ptokax causing that.
i can't see why any of those scripts would use a lot of memory, but 2 be sure could you post the amount every script is using.

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

bolamix

Well I'm using 0.3.30 build 15.25 as I once was part of the beta-testers.

The lag mostly depends on what other apps I have running, eg. when I download bootlegs with bittorrent or (rarely) stuff with emule.  But I figured if I can reduce the amount of mem used by those scripts, the hub should fare even better. None of them is using a lot of memory per se (except LIS, but that's expected), it's just that from what i've read it's more memory-efficient to have fewer scripts running.

Here's the mem specs:

Script--Mem--GC
SlotsBot--67--93
OfflineMsg--69--92
NickCheck--93--98
InfoBot--61--93
HelpBot--91--111
Ban_Unban--55--89

As you can see, not much, but it's my everyday computer, so every Kb counts :D

Btw: email notification doesn't work, good thing I came lookin' ;)

Of course it's possible that combining those scripts will do nothing for the mem usage as it is already pretty low... in which case i'll promptly drop the question :)
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

NotRabidWombat

"it's more memory-efficient to have fewer scripts running."

I don't follow your logic. Why would combining all the scripts into one large script save memory (other than simple loading overhead).

It is more memory efficient to have fewer scripts running if you _remove_ other scripts. But combining will pretty much be the same.

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

pHaTTy

more or less what rabid said, and then i will include, that combining the scripts will save cpu time.... static memory will always be the same combined or not, altho it will save a little if 10 table is in 1....so yep it can save some mem, and it deffy saves cpu

later,,
Resistance is futile!

plop

#7
QuoteOriginally posted by bolamix
Well I'm using 0.3.30 build 15.25 as I once was part of the beta-testers.
then i got still got bad news.
check what the commands_note.txt from the docs folder shows.
$ValidateNick        FullData Mode,     Non-blockable
it won't work aslong as you don't enable fulldata, which you don't want.
it passes a lot more data 2 the script, which results in a higer load on ptokax.

QuoteOriginally posted by bolamix
As you can see, not much, but it's my everyday computer, so every Kb counts :D
just a fun remark you may ignore this.
if every KB counts then why do you run windows??  lol

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

pHaTTy

QuoteOriginally posted by plop
QuoteOriginally posted by bolamix
As you can see, not much, but it's my everyday computer, so every Kb counts :D
just a fun remark you may ignore this.
if every KB counts then why do you run windows??  lol

plop

because wine and other window emulators are not very good and not very stable for running ptokax within the linux, unix OS's ??? :-P
Resistance is futile!

bolamix

Well first to RabidWombat(orNot) you'll notice I said "from what I've read". It seemed to me that if some functions like strsubs were done once instead of several times, then the load would be noticeably lighter. And (thank you phatty) let's say I meant CPU usage, not RAM, hmmm? 8)

So I could gain something by combining those scripts (clutching at straws now) it seems.

To plop: it seems I missed something about EnableFullData(), thank you for pointing this out to me... I'll go revise my commands_note.txt (and probably my scripts).
And as for the fun remark, it's because I'm on Windows that every Kb counts, I'll switch to Linux as soon (or as late) as it gets easier for noobs.

Btw again: email notification works magnificently, the problem was me not checking the right account... doh!
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

bolamix

QuoteOriginally posted by (uk-kingdom)pH?tt?
because wine and other window emulators are not very good and not very stable for running ptokax within the linux, unix OS's ??? :-P
Damn I thought Ptokax did run on Linux, or at least on wine 8o
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

pHaTTy

QuoteOriginally posted by bolamix
QuoteOriginally posted by (uk-kingdom)pH?tt?
because wine and other window emulators are not very good and not very stable for running ptokax within the linux, unix OS's ??? :-P
Damn I thought Ptokax did run on Linux, or at least on wine 8o

yes it does, just not as stable as on lets say windows xp...
Resistance is futile!

SMF spam blocked by CleanTalk