Author Topic: :Scripting:Utilities:Central:  (Read 11019 times)

0 Members and 1 Guest are viewing this topic.

Herodes

  • Guest
(No subject)
« Reply #25 on: 18 August, 2004, 18:55:45 »
Thats why I posted it typ ;D
I am glad u like the function ...

PtokaX forum

(No subject)
« Reply #25 on: 18 August, 2004, 18:55:45 »

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #26 on: 19 August, 2004, 11:39:32 »
dug this one up..
Code: [Select]
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
« Last Edit: 19 August, 2004, 11:40:38 by tezlo »

Offline Typhoon

  • Lord
  • ***
  • Posts: 397
  • Karma: +22/-3
  • PGE Developer
    • PGE Homepage
(No subject)
« Reply #27 on: 19 August, 2004, 13:28:17 »
Quote
Originally 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

Code: [Select]
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

Code: [Select]
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?
« Last Edit: 19 August, 2004, 13:29:15 by Typhoon? »



Herodes

  • Guest
(No subject)
« Reply #28 on: 19 August, 2004, 18:04:10 »
Quote
Originally posted by tezlo
dug this one up..
Code: [Select]
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 ...
« Last Edit: 19 August, 2004, 18:06:56 by Herodes »

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #29 on: 21 August, 2004, 13:38:07 »
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

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #30 on: 21 August, 2004, 16:45:07 »
this should work:

Code: [Select]
-- 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

Offline NotRabidWombat

  • Lord
  • ***
  • Posts: 384
  • Karma: +2/-0
(No subject)
« Reply #31 on: 21 August, 2004, 17:39:27 »
Nightlitch,

H:0 in the description will bypass your script.

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

-NotRabidWombat
« Last Edit: 21 August, 2004, 17:47:25 by NotRabidWombat »


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

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #32 on: 21 August, 2004, 20:31:34 »
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 :)
Code: [Select]
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

  • Guest
(No subject)
« Reply #33 on: 22 August, 2004, 07:53:24 »
Code: [Select]
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 ... :)

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
--
« Reply #34 on: 22 August, 2004, 11:44:57 »
Quote
Originally posted by NightLitch
this should work:

Code: [Select]
-- 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?
« Last Edit: 08 July, 2006, 09:21:56 by Herodes »
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
--
« Reply #35 on: 22 August, 2004, 12:54:32 »
this one should be green then:

Code: [Select]
-- 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
« Last Edit: 08 July, 2006, 09:19:52 by Herodes »
//NL

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
--
« Reply #36 on: 22 August, 2004, 13:26:54 »
Quote
Originally 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.
« Last Edit: 08 July, 2006, 09:22:20 by Herodes »
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Herodes

  • Guest
(No subject)
« Reply #37 on: 18 October, 2004, 12:18:13 »
this here is used for extracting the tag from the $MyINFO $ALL nickname description$[...]
you insert the whole descriptiontag string ...
Code: [Select]
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

  • Guest
Re: :Scripting:Utilities:Central:
« Reply #38 on: 07 July, 2006, 19:59:19 »
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

PtokaX forum

Re: :Scripting:Utilities:Central:
« Reply #38 on: 07 July, 2006, 19:59:19 »