Author Topic: Conversion LUA4 -> LUA5.1.2  (Read 3826 times)

0 Members and 1 Guest are viewing this topic.

Offline LeChuck

  • Junior Member
  • **
  • Posts: 12
  • Karma: +1/-0
Conversion LUA4 -> LUA5.1.2
« on: 05 March, 2008, 12:21:21 »
Hello,
i need a conversion of this script from PtokaX 0.3.2.6 Testdrive with ChannelBot (LUA4) to PtokaX 0.3.6.0 with RoboCop 10.0.23 (LUA 5.1.2).

Code: [Select]
botname = "-= TimeBot =-"
bot_speed = "Atomic"
bot_descr = "Stunden-Timer"



function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"
end

function zeitAnzeige()
local sHour = date("%H")
local sMin = date("%M")
UhrZeit=("\t\t\t Current Time is " ..sHour.. ":" ..sMin.. " .")
if sMin=="00" then
SendToAll("Time", UhrZeit)
StopTimer()
local sSec = date("%S")
SetTimer(60*60*1000-sSec)
StartTimer()
end
end

function OnTimer()
zeitAnzeige()
end

function Main()
SetTimer(57000)
StartTimer()
end

Can anybody help, please !  :-*
« Last Edit: 05 March, 2008, 12:30:22 by LeChuck »

PtokaX forum

Conversion LUA4 -> LUA5.1.2
« on: 05 March, 2008, 12:21:21 »

Offline LeChuck

  • Junior Member
  • **
  • Posts: 12
  • Karma: +1/-0
Re: Conversion LUA4 -> LUA5.1.2
« Reply #1 on: 06 March, 2008, 16:11:22 »
Thanks American Idiot,

but dosn't work with PtokaX 0.3.6.0.  :'(

Code: [Select]
[15:12] No syntax errors in script file lua/showtime_everyhour.lua
... on startup hub, on 16:00 pm local time no message.

Any idea what's wrong ?  :-*

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: Conversion LUA4 -> LUA5.1.2
« Reply #2 on: 06 March, 2008, 19:03:20 »
Yup, this is made for 0.4.0.0
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Offline LeChuck

  • Junior Member
  • **
  • Posts: 12
  • Karma: +1/-0
Re: Conversion LUA4 -> LUA5.1.2
« Reply #3 on: 08 March, 2008, 20:40:19 »
Thanks American Idiot,
its work ........ but not so i will.

Code: [Select]
--[[

ChimeBot 1.0 LUA 5.1x [Strict][API 1&2]

By American Idiot 03/06/08

Sends current hub time [UTC/GMT] to all in main chat
at preset minute of the hour [any 00 - 59]
]]

local bot_name = "-=TimeBot=-"
local bot_descr = "? Stunden-Timer ?"
--Minute of the hour to chime [00 - 59]
local chime_time = 00


--local Tmr,Id = 0
--OnStartup = function()
-- Tmr = TmrMan.AddTimer(1000)
-- Core.RegBot(bot_name:gsub("[$|<>:?*\"/\\]",string.char(95)),bot_descr,"",true)
--end

Main = function()
SetTimer(1000) StartTimer()
frmHub:RegBot(bot_name:gsub("[$|<>:?*\"/\\]",string.char(95)),1,bot_descr,"")
Tmr = nil
end

OnTimer = function(Id)
if Id == Tmr then
local sHour,sMin = os.date("%H"),os.date("%M")
if sMin == tostring(chime_time) then
local UhrZeit=("\t\t Hello members, it is now " ..sHour.. ":" ..sMin.. " exaktly !")
if Core then
Core.SendToAll("<"..bot_name.."> "..UhrZeit.."|")
TmrMan.RemoveTimer(Tmr)
Tmr = TmrMan.AddTimer(60*60000)
else
SendToAll(bot_name,UhrZeit)
StopTimer() SetTimer(60*60000) StartTimer()
end
end
end
end

--Returns UTC timezone as a string by American Idiot
--TimeZone = function()
-- local h,m = math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
-- return string.format("%+d UTC",(h + (60 * m)))
--end

You see, i've little modified, but the mysterium is the message don't make when chime_time = 00 or 01 or 02 ....... or 09.
I will use it whenever full hour, also 00.
It's works perfektly 0n 11 .... 59.

Do you have a little help for idea, PLEASE.  :'(
« Last Edit: 08 March, 2008, 20:43:09 by LeChuck »

Offline LeChuck

  • Junior Member
  • **
  • Posts: 12
  • Karma: +1/-0
Re: Conversion LUA4 -> LUA5.1.2
« Reply #4 on: 08 March, 2008, 22:08:14 »
YEAH !
Now it's run !
I've make more modified, now running.

Code: [Select]
--[[
ChimeBot 1.0 LUA 5.1x [Strict][API 1&2]

By American Idiot 03/06/08

Sends current hub time [UTC/GMT] to all in main chat
at preset minute of the hour [any 00 - 59]
]]

local bot_name = "-=TimeBot=-"
local bot_descr = "? Stunden-Timer ?"

Main = function()
SetTimer(1000) StartTimer()
frmHub:RegBot(bot_name:gsub("[$|<>:?*\"/\\]",string.char(95)),1,bot_descr,"")
Tmr = nil
end

OnTimer = function(Id)
if Id == Tmr then
local sHour,sMin = os.date("%H"),os.date("%M")
if sMin == "00" then
local UhrZeit=("\t\t Hello members, it is now " ..sHour.. ":" ..sMin.. " exaktly !")
if Core then
Core.SendToAll("<"..bot_name.."> "..UhrZeit.."|")
TmrMan.RemoveTimer(Tmr)
Tmr = TmrMan.AddTimer(60*60000)
else
SendToAll(bot_name,UhrZeit)
StopTimer() SetTimer(60*60000) StartTimer()
end
end
end
end

Now message is : Hello members, it is now 22:00 exaktly !

 ;)

@American Idiot,
it's my own german closed Hub with only german member, so i don't need UTC Timezones.
« Last Edit: 08 March, 2008, 22:58:19 by LeChuck »

PtokaX forum

Re: Conversion LUA4 -> LUA5.1.2
« Reply #4 on: 08 March, 2008, 22:08:14 »