kerstmis bot want it to lua5
 

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

kerstmis bot want it to lua5

Started by Ajax, 01 October, 2005, 15:01:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ajax

-----------------------------------------------------------------------------
-------                  countdown bot by plop                         -------
-------             original julian day made by tezlo                  -------
-------      modifyd by chilla 2 also handle hours, mins, seconds      -------
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-------           THE TEXT FILE LOADS ON BOT START                     -------
------------------------------------------------------------------------------
------- this may sound weird but this 2 make sure it shows on time,    -------
-------      as i allready seen some big ascii's come by               -------
------------------------------------------------------------------------------


------------------------------------------------------------------------------
Bot = "Robotime"
--This the date the timer has 2 stop @ midnight
-- year (2 numbers), month, day
SylYear,SylMonth,SylDay = 05,12,31
-- this is the file 2 be shown
file = "happynewyear.txt"
------------------------------------------------------------------------------


------------------------------------------------------------------------------
function OnTimer()
   if last == 0 then
      SendToAll(Bot, TimeLeft())
      Sync()
   elseif last == 1 then
      SendAscii() -- send the msg
      StopTimer() -- kill the timer
   end
end
------------------------------------------------------------------------------
function jdatehms(d, m, y,ho,mi,se)
   local a, b, c = 0, 0, 0
   if m <= 2 then
      y = y - 1
      m = m + 12
   end
   if (y*10000 + m*100 + d) >= 15821015 then
      a = floor(y/100)
      b = 2 - a + floor(a/4)
   end
   if y <= 0 then c = 0.75 end
   return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+se
end
------------------------------------------------------------------------------
function TimeLeft()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
   local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day >= 0 then
      line = "*~Time*~left*~till*~new*~year:"
      if day ~= 0 then
         line = line.." "..day.." Day's"
      end
      if hours ~= 0 then
         line = line.." "..hours.." Hours"
      end
      if minutes ~= 0 then
         line = line.." "..minutes.." Minutes"
      end
      if seconds ~= 0 then
         line = line.." "..seconds.." Seconds"
      end
      return line
   else
      return 1
   end
end
------------------------------------------------------------------------------
function ShowAscii()
   text ="\r\n\r\n"
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      text = text..line.."\r\n"
   end
end
------------------------------------------------------------------------------
function SendAscii()
   SendToAll(Bot, text.." |")
   SendToAll(Bot, "happy new year 2 everybody from all the guy's/girls/bot's from the lua forum|")
end
------------------------------------------------------------------------------
function DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!daysleft" then
         local tmp = TimeLeft()
         if tonumber(tmp) == nil then
            user:SendData(Bot, tmp.."|")
         end
         return 1
      end
   end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function OpConnected(user)
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function Main()
   SetTimer(100 * 1000)
   StartTimer()
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      SendToAll(Bot, tmp.."|")
   end
   Sync()
   ShowAscii()
   last = 0
end
------------------------------------------------------------------------------
function Sync()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
   local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day ~= 0 then
      adjust = (floor(mod(minutes, 60))*60)+seconds
      if adjust ~= 0 then
         SetTimer(adjust * 1000)
      else
         SetTimer(3600 * 1000)
      end
   else
      if tmp > 3600 then  --- every hours a msg
         adjust = (floor(mod(minutes, 60))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(3600 * 1000)
         end
      elseif tmp > 900 then  -- every 15 mins a msg
         adjust = (floor(mod(minutes, 15))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(900 * 1000)
         end
      elseif tmp > 300 then  -- every 5 mins a msg
         adjust = (floor(mod(minutes, 5))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(300 * 1000)
         end
      elseif tmp > 60 then  -- every min a msg
         adjust = (floor(mod(minutes, 1))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(60 * 1000)
         end
      elseif tmp > 15 then  -- every 15 secs a msg
         adjust = floor(mod(seconds, 15))
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(15 * 1000)
         end
      elseif tmp > 10 then  -- every 10 secs a msg
         adjust = floor(mod(seconds, 10))
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(5 * 1000)
         end
      elseif tmp > 1 then
         SetTimer(1 * 1000)
      else
         last = 1
         SetTimer(1 * 1000)
      end
   end
end
------------------------------------------------------------------------------

can somebody moddedto lua5 greats ajax thnx
:evil:


Ajax

QuoteOriginally posted by Ajax
-----------------------------------------------------------------------------
-------                  countdown bot by plop                         -------
-------             original julian day made by tezlo                  -------
-------      modifyd by chilla 2 also handle hours, mins, seconds      -------
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-------           THE TEXT FILE LOADS ON BOT START                     -------
------------------------------------------------------------------------------
------- this may sound weird but this 2 make sure it shows on time,    -------
-------      as i allready seen some big ascii's come by               -------
------------------------------------------------------------------------------


------------------------------------------------------------------------------
Bot = "Robotime"
--This the date the timer has 2 stop @ midnight
-- year (2 numbers), month, day
SylYear,SylMonth,SylDay = 05,12,31
-- this is the file 2 be shown
file = "happynewyear.txt"
------------------------------------------------------------------------------


------------------------------------------------------------------------------
function OnTimer()
   if last == 0 then
      SendToAll(Bot, TimeLeft())
      Sync()
   elseif last == 1 then
      SendAscii() -- send the msg
      StopTimer() -- kill the timer
   end
end
------------------------------------------------------------------------------
function jdatehms(d, m, y,ho,mi,se)
   local a, b, c = 0, 0, 0
   if m <= 2 then
      y = y - 1
      m = m + 12
   end
   if (y*10000 + m*100 + d) >= 15821015 then
      a = floor(y/100)
      b = 2 - a + floor(a/4)
   end
   if y <= 0 then c = 0.75 end
   return floor(365.25*y - c) + floor(30.6001*(m+1) + d + 1720994 + b),ho*3600+mi*60+se
end
------------------------------------------------------------------------------
function TimeLeft()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
   local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day >= 0 then
      line = "*~Time*~left*~till*~new*~year:"
      if day ~= 0 then
         line = line.." "..day.." Day's"
      end
      if hours ~= 0 then
         line = line.." "..hours.." Hours"
      end
      if minutes ~= 0 then
         line = line.." "..minutes.." Minutes"
      end
      if seconds ~= 0 then
         line = line.." "..seconds.." Seconds"
      end
      return line
   else
      return 1
   end
end
------------------------------------------------------------------------------
function ShowAscii()
   text ="\r\n\r\n"
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      text = text..line.."\r\n"
   end
end
------------------------------------------------------------------------------
function SendAscii()
   SendToAll(Bot, text.." |")
   SendToAll(Bot, "happy new year 2 everybody from all the guy's/girls/bot's from the lua forum|")
end
------------------------------------------------------------------------------
function DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!daysleft" then
         local tmp = TimeLeft()
         if tonumber(tmp) == nil then
            user:SendData(Bot, tmp.."|")
         end
         return 1
      end
   end
end
------------------------------------------------------------------------------
function NewUserConnected(user)
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function OpConnected(user)
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      user:SendData(Bot, tmp.."|")
   end
end
------------------------------------------------------------------------------
function Main()
   SetTimer(100 * 1000)
   StartTimer()
   local tmp = TimeLeft()
   if tonumber(tmp) == nil then
      SendToAll(Bot, tmp.."|")
   end
   Sync()
   ShowAscii()
   last = 0
end
------------------------------------------------------------------------------
function Sync()
   local curday,cursec = jdatehms(tonumber(date("%d")),tonumber(date("%m")),tonumber(date("%y")),tonumber(date("%H")),tonumber(date("%M")),tonumber(date("%S")))
   local sylday,sylsec = jdatehms(SylDay,SylMonth,SylYear,24,0,0)
   local tmp = sylsec-cursec
   local hours, minutes,seconds = floor(mod(tmp/3600, 60)), floor(mod(tmp/60, 60)), floor(mod(tmp/1, 60))
   local day = sylday-curday
   if day ~= 0 then
      adjust = (floor(mod(minutes, 60))*60)+seconds
      if adjust ~= 0 then
         SetTimer(adjust * 1000)
      else
         SetTimer(3600 * 1000)
      end
   else
      if tmp > 3600 then  --- every hours a msg
         adjust = (floor(mod(minutes, 60))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(3600 * 1000)
         end
      elseif tmp > 900 then  -- every 15 mins a msg
         adjust = (floor(mod(minutes, 15))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(900 * 1000)
         end
      elseif tmp > 300 then  -- every 5 mins a msg
         adjust = (floor(mod(minutes, 5))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(300 * 1000)
         end
      elseif tmp > 60 then  -- every min a msg
         adjust = (floor(mod(minutes, 1))*60)+seconds
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(60 * 1000)
         end
      elseif tmp > 15 then  -- every 15 secs a msg
         adjust = floor(mod(seconds, 15))
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(15 * 1000)
         end
      elseif tmp > 10 then  -- every 10 secs a msg
         adjust = floor(mod(seconds, 10))
         if adjust ~= 0 then
            SetTimer(adjust * 1000)
         else
            SetTimer(5 * 1000)
         end
      elseif tmp > 1 then
         SetTimer(1 * 1000)
      else
         last = 1
         SetTimer(1 * 1000)
      end
   end
end
------------------------------------------------------------------------------

can somebody moddedto lua5 greats ajax thnx

oww under witch name is thise bot all  ???

ore put thise to lua5 please thnx
:evil:

UwV

\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

SMF spam blocked by CleanTalk