Conversion LUA4 -> LUA5.1.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

Conversion LUA4 -> LUA5.1.2

Started by LeChuck, 05 March, 2008, 12:21:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LeChuck

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

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 !  :-*

LeChuck

Thanks Mutor,

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

[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 ?  :-*

Madman

We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

LeChuck

#3
Thanks Mutor,
its work ........ but not so i will.

--[[

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

	By Mutor	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 Mutor
--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.  :'(

LeChuck

#4
YEAH !
Now it's run !
I've make more modified, now running.

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

	By Mutor	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 !

;)

@Mutor,
it's my own german closed Hub with only german member, so i don't need UTC Timezones.

SMF spam blocked by CleanTalk