:Scripting:Utilities:Central: - Page 2
 

News:

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

:Scripting:Utilities:Central:

Started by Herodes, 11 July, 2004, 00:19:43

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Herodes

Thats why I posted it typ ;D
I am glad u like the function ...

tezlo

#26
dug this one up..
local tmp = clock()
local days, hours, minutes = floor(tmp/86400), floor(mod(tmp/3600, 24)), floor(mod(tmp/60, 60))

considering your code..
instead of multiplying time by 1000, you could just take away the three zeros from the values in tO
and instead of substracting them n times in a loop, you could just use modulo/division once

Typhoon

#27
QuoteOriginally posted by Herodes
Thats why I posted it typ ;D
I am glad u like the function ...

Well , you missed my point , in your version on cmd  !uptime you try to call a function that dont exist , thats why i below your post , made the correction...

You call

function DataArrival(user, data)
	data = strsub(data,1,strlen(data)-1)
	local s,e,cmd = strfind( data, "%b<>%s+(%S*)" )
	if cmd == "!uptime" then
		SendToAll("UpTime", "The "..frmHub:GetHubName().." Hub has been running for"..DoTime(clock()) )
	end
end

But it should be

function DataArrival(user, data)
	data = strsub(data,1,strlen(data)-1)
	local s,e,cmd = strfind( data, "%b<>%s+(%S*)" )
	if cmd == "!uptime" then
		SendToAll("UpTime", "The "..frmHub:GetHubName().." Hub has been running for"..DoTimeUnits(clock()) )
	end
end

hope you get it now ;)

keep up the good work inhere

*** Typhoon?



Herodes

#28
QuoteOriginally posted by tezlo
dug this one up..
local tmp = clock()
local days, hours, minutes = floor(tmp/86400), floor(mod(tmp/3600, 24)), floor(mod(tmp/60, 60))

considering your code..
instead of multiplying time by 1000, you could just take away the three zeros from the values in tO
and instead of substracting them n times in a loop, you could just use modulo/division once
hmmm ... but it doesnt modify the ' time ' variable so that the next indexes of tO work on the leftovers from the current index operation ... hope its clear ... I would appreciate the a mod to show me how ...
I had been trying to make it work like that but the maths procedure came hard on me at the time ... ( late in night... ) I'll have another look unless a reply comes faster ...

about the time = time*1000 this is so that I can operate for the seconds in the same way as in days,hours,minutes ... I expected myself to come up with something more ingenious, but ... to no avail.


[*note*] Thx typ ... ;) post edited ...

Psycho_Chihuahua

anyone got a snipplet or standalone Code to insert into a bot that checks for Users that are in Open Hubs and kicks them with a message referring to which rule he broke? (in my example rule Nr. 6).
The Reason is that i'm running a Reg Hub and i don't want my Users running round in Open Hubs seeming though the Authoritys are getting pretty harsh here in Europe
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

NightLitch

this should work:

-- By NightLitch

DisconnectMessage = "Enter Message Here"

function DataArrival( sUser , sData )
	if strsub( sData , 1 , 7 ) == "$MyINFO" then
		local _,_,openhubs = strfind( sData , "H:(%d+)" )
		if ( openhubs ~= 0 ) then
			SendToNick( sUser.sName , DisconnectMessage )
			sUser:Disconnect()
		end
	end
end

/NL
//NL

NotRabidWombat

#31
Nightlitch,

H:0 in the description will bypass your script.

I think this will do the trick:
local _,_,openhubs = strfind( sData , ".+H:(%d+)" );

-NotRabidWombat


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

tezlo

that.. and you're comparing a string with a number, which will never equal, so everyone gets disconnected
should be: if openhubs ~= "0" then ..

herodes..
this one does :)
function strftime(form, time)
  local d, h, m
  d, time = floor(time/86400), mod(time, 86400)
  h, time = floor(time/3600), mod(time, 3600)
  m, time = floor(time/60), mod(time, 60)
  return format(form, d, h, m, time)
end

print("uptime: "..strftime("%ddays %dhours %dminutes %dseconds", 90061))

Herodes

function strftime(form, time)
  local d, h, m
  d, time = floor(time/86400), mod(time, 86400)
  h, time = floor(time/3600), mod(time, 3600)
  m, time = floor(time/60), mod(time, 60)
  return format(form, d, h, m, time)
end

print("uptime: "..strftime("%ddays %dhours %dminutes %dseconds", 90061))

nasty math lib use ;)

ty tezlo ... I will post an update of the DoTimeUnits later ... I need to find more about that mod(num) lua function as I dont know what it does ... floor(num/num) was hard to figure out ... but I need to know these I suppose....

PS: btw this snippet still comes up with the 0 days 0 hours 15 minutes and so on string ... the DoTimeFunction intends to eliminate reduntant 0 units from the string ... again thx for the input ... :)

Psycho_Chihuahua

--
#34
QuoteOriginally posted by NightLitch
this should work:

-- By NightLitch

DisconnectMessage = "Enter Message Here"

function DataArrival( sUser , sData )
	if strsub( sData , 1 , 7 ) == "$MyINFO" then
		local _,_,openhubs = strfind( sData , "H:(%d+)" )
		if ( openhubs ~= "0" ) then
			SendToNick( sUser.sName , DisconnectMessage )
			sUser:Disconnect()
		end
	end
end


NL
Works great with the 2 missing " 's :)
Just 1 more thing: Can you please add a timer to set that it checks all RegUsers every x minutes just in case they connect to Open Hubs fter they have connected to mine?
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

NightLitch

--
#35
this one should be green then:

-- By NightLitch

DisconnectMessage = "Enter Message Here"

function DataArrival( sUser , sData )
	if strsub( sData , 1 , 7 ) == "$MyINFO" then
		local _,_,openhubs = strfind( sData , ",H:(%d+)" )
		if ( tonumber(openhubs) ~= 0 ) then
			SendToNick( sUser.sName , DisconnectMessage )
			sUser:Disconnect()
		end
	end
end


Quote
Just 1 more thing: Can you please add a timer to set that it checks all RegUsers every x minutes just in case they connect to Open Hubs fter they have connected to mine?

there's no need to add a timer, the MyINFO string updates in every hub when u connect to another...

DataArrival take's care of it...

Cheers / NightLitch
//NL

Psycho_Chihuahua

--
#36
QuoteOriginally posted by NightLitch
...there's no need to add a timer, the MyINFO string updates in every hub when u connect to another...

DataArrival take's care of it...

Cheers, NightLitch

Oh, ok thnx for the Info and also for the script. Would be interesting to se something like this in Thor in a future release ;) perhaps.
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Herodes

this here is used for extracting the tag from the $MyINFO $ALL nickname description$[...]
you insert the whole descriptiontag string ...
function SplitTagDescr(str)
	local tag, descr, tTab = "", "", {}
--- get those letters in the tTab
	for i= 1, strlen(str) do 
		tTab[i] = strsub(str, i,i) 
	end
--- move backwards until we find a "<"
	local i = getn(tTab)
	repeat 
		tag = tTab[i]..tag
		i = i - 1
	until tTab[i] == "<"
--- add the missing "<"
	tag = "<"..tag
--- construct the description
	for l = 1, i-1 do 
		descr = descr..tTab[l] 
	end
	return descr, tag
end

Markitos

Hello!
Maybe continuing posting code snippets in lua 5/ 5.1 wouldn't be a bad idea...??
WE all wanna learn and i found this thread very usefull for that kind of thing.


Regards

SMF spam blocked by CleanTalk