Converting Lua 3 to Lua 5/5.1
 

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

Converting Lua 3 to Lua 5/5.1

Started by ((KMN))Gazza-95, 25 April, 2006, 19:46:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

((KMN))Gazza-95

I have a script that is in lua 3 and it wont work with the latest version of PtokaX but is there any way i can convert it.

It is a bot wrote by the lessons that Phatty wrote and its turned out in LUA 3 any help

thx


Markitos

Quote from: ((KMN))Gazza-95 on 25 April, 2006, 19:46:49
I have a script that is in lua 3 and it wont work with the latest version of PtokaX but is there any way i can convert it.

It is a bot wrote by the lessons that Phatty wrote and its turned out in LUA 3 any help

thx


its lua 4...as ppk said, ptokax never used lua3.
Post your script...

((KMN))Gazza-95

#2
Bot = "']['h????r][V][???"

version = "1.0 by ((KMN))Gazza-95 & ideas from ((KMN))?h?i?"
NEWCON = 1 
prefix = "!"
TimeMins = 10
TimeToBan = "120" 
SendC = SendToAll

MessageTimer = 1
BadWords

TheBadWords = { "fuck", "twat", "suck", "fucker", "sex", "porno", "xxx" }

function Main() 
	frmHub:']['h????r][V][??(Bot)
? ? ? ? SetTimer(TimerMins*60000)
? ? ? ? StartTimer()
end 

function OnTimer() --This is what will be sent on the timer 
? ? ? ? if MessageTimer == 1 then
? ? ? ? ? ? ? ? randomtimer = random(2) 
	? ? ? ? if randomtimer == 1 then
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","----------------------------------")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","---Also Avalible In The Network---")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","---themusiccavern.servemp3.com----")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","---themusakpalace.servemp3.com----")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","---themusicshack.servemp3.com-----")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","---koolmusic.servemp3.com:422-----")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","----Hope you enjoy these hubs-----") 
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","----------------------------------")
? ? ? ? ? ? ? ? elseif randomtimer == 2 then
		? ? ? ? SendC(bot,"']['h????r][V][???","-------------------------------------------")
		? ? ? ? SendC(bot,"']['h????r][V][???","--This Bot Was Written By ((KMN))Gazza-95--")
? ? ? ? ? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][???","--------With ideas from ((KMN))?h?i?-------")
		? ? ? ? SendC(bot,"']['h????r][V][???","-------------------------------------------")
? ? ? ? ? ? ? ? end
	end
end


function NewUserConnected(user)
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","Welcome our new guest "..user.sName", we hope you enjoy your stay here if any help is needed pm a op")
end

function OpConnected(user)
Pillock = GetProfileName(user.iProfile)
? ? ? ? thisisthevariable == random(5)
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","Bow before our Op "..user.sName" and make him feel welcome")

? ? ? ? elseif thisisthevariable == 2 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","Our allmighty op "..user.sName" has entered") 

? ? ? ? elseif thisisthevariable == 3 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","Playing on his PsP op "..user.sName" walks into the hub")

? ? ? ? elseif thisisthevariable == 4 then
		SendC(bot,"']['h????r][V][??","The Bodygaurd "..user.sName" is here to protect us HORRAY") 

	elseif thisisthevariable == 5 then
		SendC(bot,"']['h????r][V][??","Mixing on his decks "..user.sName" walks into the hub") 
? ? ? ? end
end


function VipConnected(user)
? ? ? ? thisisthevariable == random(5)
? ? ? ? ? ? SendC(bot,"']['h????r][V][??","The very important person "..user.sName" is here to chat")

? ? ? ? elseif thisisthevariable == 2 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??"""..user.sName" walks in covered in something that smells very similar to Sh*t")

	elseif thisisthevariable == 3 then
		SendC(bot,"']['h????r][V][??",""user.sName" And just like that, They Are Gone into the dark night hoping to find? ?The T?RM???']['?R") 

	elseif thisisthevariable == 4 then
		SendC(bot,"']['h????r][V][??","A warm welcome back "..user.sNamre" to this fine hub") 

	elseif thisisthevariable == 5 then
		SendC(bot,"']['h????r][V][??","Well Hello "..user.sName" Hey, buddy. You got a dead cat in there, or what?") 
	end
end


function RegUserConnected(uesr)
? ? ? ? thisisthevariable == random(5)
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","The registered user "..user.sName" is here and wants some music")

? ? ? ? elseif thisisthevariable == 2 then
		SendC(bot,"']['h????r][V][??",""..user.sName" appears out of the blue and takes their rightful place in this damn fine hub") 

	elseif thisisthevariable == 3 then
		SendC(bot,"']['h????r][V][??","with a gust of wind and a flash of lightning "..user.sName" appears") 

	elseif thisisthevariable == 4 then
		SendC(bot,"']['h????r][V][??","like ants from beneath the floorboards "..user.sName" comes crawling home") 

	elseif thisisthevariable == 5 then
		SendC(bot,"']['h????r][V][??","with a twinkle in their eye and a new hair do "..user.sName" comes waltzing in") 
	end
end

? ? ? ? ? 

function NetFounderConnected(user)
? ? ? ? thisisthevariable == random(5) 
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","The king of the house "..user.sName" has entered now be nice")? 

	elseif thisisthevariable == 2 then
		SendC(bot,"']['h????r][V][??","The one and only "..user.sName" runs into the hub") 

	elseif thisisthevariable == 3 then
		SendC(bot,"']['h????r][V][??","Welcome King "..user.sName" to this fine hub") 

	elseif thisisthevariable == 4 then
		SendC(bot,"']['h????r][V][??","Shouing Whos this T?RM???']['?R "..user.sName" enters the hub") 

	elseif thisisthevariable == 5 then
		SendC(bot,"']['h????r][V][??","Highlander's Evil side runs towards "..user.sName"And chases him into the hub") 
	end
end



function MasterConnected(user)
? ? ? ? thisisthevariable== random(5)
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","Hello Master "..user.sName" How are you today")

? ? ? ? elseif thisisthevariable == 2 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??","Master of the hub "..user.sName" enters the hub on a KTM 720")
? ? ? ? 
? ? ? ? elseif thisisthevariable == 3 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??""After Alot Of Loud Groaning "..user.sName" strides in saying That son of a bitch took my pants")

? ? ? ? elseif thisisthevariable == 4 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??""..user.sName" Arrives Ranting And Raving OK? Listen. And understand. The T?RM???']['?R is out there. It can't be bargained with. It can't be reasoned with. It doesn't feel pity, or remorse, or fear. And it absolutely will not stop, ever, until you are dead , unless of course you give him ?5.")
? ? ? ? 
? ? ? ? elseif thisisthevariable == 5 then
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??""..user.sName" enters shouting? Look... I am not stupid, you know. They cannot make things like that yet")

function deathfunction(']['h????r][V][??) 
	dead = random(5)
? ? ? ? ? ? ? ? SendC(bot,"']['h????r][V][??",""..user.sName"has killed their self, and fell out the hub")? ? ? ? ? ? ? ? 	
? ? ? ? elseif dead == 2 then
? ? ? ? ?	SendC(bot,"']['h????r][V][??",""user.sName.." has killed their self, what a pillock")
	elseif dead == 3 then
		SendC(bot,"']['h????r][V][??",""user.sName.." is a total nutter, they killed em'self")
	elseif dead == 4 then
		SendC(bot,"']['h????r][V][??",""user.sName.." is now dead, falling from the hub")
	elseif dead == 5 then
		SendC(bot,"']['h????r][V][??",""user.sName.." jumps a mile high with a rope around their nech and drops down a hole, thats the last we seen of em")
']['h????r][V][??:Disconnect()

end


function DataArrival(user,data)
? ? ? ? if string.sub(data, 1, 1) == "<" then
	? ? ? ? data=string.sub(data,1,strlen(data)-1)
	? ? ? ? s,e,cmd = string.find(data,"%b<>%s+(%S+)")
? ? ? ? ? ? ? ? for key,checkWordin TheBadWords do
? ? ? ? ? ? ? ? 	if (stringfind(data, checkWord, 1, 1)) then
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BadWord[user.sName]=0
				elseif BadWord[user.sName]== 3 then
					user:Disconnect()
				else
					BadWord[user.sName]=BadWord[user.sName]+1
				end
? ? ? ? ? ? ? ? ? ? ? ? return 1
? ? ? ? ? ? ? ? ? ? ? ? end
? ? ? ? ? ? ? ? end
? ? ? ? ? ? ? ? if cmd == "!version" then
			user:SendData(Bot,"']['h????r][V][??""This bot is version: "..1.0 by ((KMN))Gazza-95)
	? ? ? ? return 1
? ? ? ? ? ? ? ? elseif cmd == prefix.. "!help" then
? ? ? ? ? ? ? ? ? ? ? ? user:SendData(bot,"']['h????r][V][??","Type !regme <password> in main chat to register if you need any help doing this please pm a op (users with the keys next to there name) <password> means your atual password")
? ? ? ? ? ? ? ? return 1
? ? ? ? ? ? ? ? elseif cmd == prefix.. "!kill" then
? ? ? ? ? ? ? ? ? ? ? ? deathfunction(user)
	? ? ? ? return 1
? ? ? ? ? ? ? ? elseif (cmd==prefix.."mass") then
			if user.Operator then
				s,e,cmd,message = string.find(data,"%s+(%S+)%s+(.*)")
				if message == nil then
					user:SendData(Bot,"Please enter a message to mass")
					return 1
				end
				SendC(Bot,"']['h????r][V][??"" "..user.sName..": "..message)
				end
			end
		end 
	end
end


Code tags added by Mutor


Markitos

#4
Well, there were many issues in your script...i commented the code so you cold see what was the error(s)...
If you want to send certain msgs on connect for certain profiles for example for master's it should be something like this
function OpConnected(user)
	if user.iProfile == 0 then ----->>> 0 is the number of master profile
	--Send msgs here...
end

and for non ops the same thing but with the function NewUserConnected
bot = "']['h????r][V][???"

version = "1.0 by ((KMN))Gazza-95 & ideas from ((KMN))?h?i?"
NEWCON = 1
prefix = "!"
TimeMins = 10
TimeToBan = "120" ---???
SendC = SendToAll

MessageTimer = 1
BadWord = {}
TheBadWords = { "fuck", "twat", "suck", "fucker" }

function Main()
frmHub:RegBot(Bot) ----- Watch this
    SetTimer(TimeMins*60000)
    StartTimer()
end

function OnTimer() --This is what will be sent on the timer
    if MessageTimer == 1 then
		randomtimer = math.random(2) -- In Lua 5 "random" is "math.random"
		if randomtimer == 1 then
            SendC(bot,""..string.rep("-",15).."") --- You dont need to add ']['h????r][V][???" its already in Bot = "']['h????r][V][???"
            SendC(bot,"---Also Avalible In The Network---")
            SendC(bot,"---themusiccavern.servemp3.com----")
            SendC(bot,"---themusakpalace.servemp3.com----")
            SendC(bot,"---themusicshack.servemp3.com-----")
            SendC(bot,"---koolmusic.servemp3.com:422-----")
			SendC(bot,"----Hope you enjoy these hubs-----")
            SendC(bot,""..string.rep("-",15).."") --  use string.rep and it will make your djob easier :-) thats why i love LUA!
        elseif randomtimer == 2 then
			SendC(bot,""..string.rep("-",15).."")
			SendC(bot,"--This Bot Was Written By ((KMN))Gazza-95--")
            SendC(bot,"--------With ideas from ((KMN))?h?i?-------")
			SendC(bot,""..string.rep("-",15).."")
        end
	end
end


function NewUserConnected(user)
	user:SendData(bot,"Welcome our new guest "..user.sName..", we hope you enjoy your stay here if any help is needed pm a op")
end

function OpConnected(user)
    local Pillock,Random = GetProfileName(user.iProfile),math.random(5)
	if Random == 1 then
		SendC(bot,"Bow before our Op "..user.sName.." and make him feel welcome")
	elseif Random == 2 then
		SendC(bot,"Our allmighty op "..user.sName.." has entered")
	elseif Random == 3 then
        SendC(bot,"Playing on his PsP op "..user.sName.." walks into the hub")
	elseif Random == 4 then
		SendC(bot,"The Bodygaurd "..user.sName.." is here to protect us HORRAY")
	elseif Random == 5 then
		SendC(bot,"Mixing on his decks "..user.sName.." walks into the hub")
    end
end

function deathfunction(user)
	dead = math.random(5)
	if dead == 1 then
		SendC(bot,""..user.sName.."has killed their self, and fell out the hub")               
    elseif dead == 2 then
        SendC(bot,""..user.sName.." has killed their self, what a pillock")
	elseif dead == 3 then
		SendC(bot,""..user.sName.." is a total nutter, they killed em'self")
	elseif dead == 4 then
		SendC(bot,""..user.sName.." is now dead, falling from the hub")
	elseif dead == 5 then
		SendC(bot,""..user.sName.." jumps a mile high with a rope around their nech and drops down a hole, thats the last we seen of em")
	user:Disconnect()
	end
end


function ChatArrival(user,data) -- The new ptokax doesnt support "DataArrival" thats now "ChatArrival"
    local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
    for key,checkWord in ipairs(TheBadWords) do
		if (string.find(data, checkWord, 1, 1)) then -------->>>> "string.find" not "stringfind"
            BadWord[user.sName]=0
		elseif BadWord[user.sName]== 3 then
			user:Disconnect()
		else
			BadWord[user.sName]=BadWord[user.sName]+1
		end
        return 1
    end
	if cmd then
		local tCmds = {
			["version"] = function(user)
				user:SendData(bot,"This bot is version: "..version.."")
			end,
			["help"] = function(user)
				user:SendData(bot,"Type !regme <password> in main chat to register if you need any help doing this please pm a op (users with the keys next to there name) <password> means your atual password")
			end,
			["kill"] = function(user)
				deathfunction(user)
			end,
			["mass"] = function(user,data)-- Since its mass i think we should use "SendPM" so it could send in PM
				if user.Operator then
					local s,e,cmd,message = string.find(data,"b<>%s(%S+)%s+(.*)")
					if message == nil then
						user:SendData(Bot,"Please enter a message to mass")
					end
					SendPM(bot," "..user.sName..": "..message)
				end
				end,
			}
		if tCmds[cmd] then
			return tCmds[cmd](user,data),1
		end
	end
end

i removed some functions...and i  hope you re-add them correctley.

6Marilyn6Manson6

#5
Markitos post have small error in death == 1 :P... This is correct:

BotName = "']['h????r][V][???"
version = "1.0 by ((KMN))Gazza-95 & ideas from ((KMN))?h?i?"
NEWCON = 1
prefix = "!"
TimeMins = 10
TimeToBan = "120"
MessageTimer = 1

TheBadWords = { 
"fuck",
"twat",
"suck",
"fucker"
}

function Main()
	frmHub:RegBot(BotName) ----- Watch this
	SetTimer(TimeMins*60000)
	StartTimer()
end

function OnTimer() --This is what will be sent on the timer
	if MessageTimer == 1 then
	randomtimer = math.random(2) -- In Lua 5 "random" is "math.random"
		if randomtimer == 1 then
			SendToAll(BotName,""..string.rep("-",15).."") --- You dont need to add ']['h????r][V][???" its already in Bot = "']['h????r][V][???"
			SendToAll(BotName,"---Also Avalible In The Network---")
			SendToAll(BotName,"---themusiccavern.servemp3.com----")
			SendToAll(BotName,"---themusakpalace.servemp3.com----")
			SendToAll(BotName,"---themusicshack.servemp3.com-----")
			SendToAll(BotName,"---koolmusic.servemp3.com:422-----")
			SendToAll(BotName,"----Hope you enjoy these hubs-----")
			SendToAll(BotName,""..string.rep("-",15).."") --  use string.rep and it will make your djob easier :-) thats why i love LUA!
		elseif randomtimer == 2 then
			SendToAll(BotName,""..string.rep("-",15).."")
			SendToAll(BotName,"--This Bot Was Written By ((KMN))Gazza-95--")
			SendToAll(BotName,"--------With ideas from ((KMN))?h?i?-------")
			SendToAll(BotName,""..string.rep("-",15).."")
		end
	end
end

function NewUserConnected(user)
	user:SendData(BotName,"Welcome our new guest "..user.sName..", we hope you enjoy your stay here if any help is needed pm a op")
end

function OpConnected(user)
	local Pillock = GetProfileName(user.iProfile)
	local Random = math.random(5) ---- Remember??? 
	if Random == 1 then
		SendToAll(BotName,"Bow before our Op "..user.sName.." and make him feel welcome")
	elseif Random == 2 then
		SendToAll(BotName,"Our allmighty op "..user.sName.." has entered")
	elseif Random == 3 then
		SendToAll(BotName,"Playing on his PsP op "..user.sName.." walks into the hub")
	elseif Random == 4 then
		SendToAll(BotName,"The Bodygaurd "..user.sName.." is here to protect us HORRAY")
	elseif Random == 5 then
		SendToAll(BotName,"Mixing on his decks "..user.sName.." walks into the hub")
	end
end

function deathfunction(user)
	dead = math.random(5)
	if dead == 1 then
		SendToAll(BotName,""..user.sName.." has killed their self, and fell out the hub")               
	elseif dead == 2 then
		SendToAll(BotName,""..user.sName.." has killed their self, what a pillock")
	elseif dead == 3 then
		SendToAll(BotName,""..user.sName.." is a total nutter, they killed em'self")
	elseif dead == 4 then
		SendToAll(BotName,""..user.sName.." is now dead, falling from the hub")
	elseif dead == 5 then
		SendToAll(BotName,""..user.sName.." jumps a mile high with a rope around their nech and drops down a hole, thats the last we seen of em")
	user:Disconnect()
	end
end

function ChatArrival(user,data) -- The new ptokax doesnt support "DataArrival" thats now "ChatArrival"
	local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
	for key,checkWord in ipairs(TheBadWords) do
		if (string.find(data, checkWord, 1, 1)) then -------->>>> "string.find" not "stringfind"
			BadWord[user.sName]=0
		elseif BadWord[user.sName]== 3 then
			user:Disconnect()
		else
			BadWord[user.sName]=BadWord[user.sName]+1
		end
		return 1
	end
	if cmd then
		local tCmds = {
			["version"] = function(user)
				user:SendData(BotName,"This bot is version: "..version.."")
		end,
			["help"] = function(user)
				user:SendData(BotName,"Type !regme <password> in main chat to register if you need any help doing this please pm a op (users with the keys next to there name) <password> means your atual password")
			end,
			["kill"] = function(user)
				deathfunction(user)
			end,
			["mass"] = function(user,data)-- Since its mass i think we should use "SendPM" so it could send in PM
				if user.Operator then
					s,e,cmd,message = string.find(data,"%s+(%S+)%s+(.*)")
					if message == nil then
						user:SendData(BotName,"Please enter a message to mass")
					end
					SendPM(BotName," "..user.sName..": "..message)
					end
				end,
				}
				if tCmds[cmd] then
					return tCmds[cmd](user,data),1
				end
		end
end

Markitos

#6
Thanks by the way tabb well your script, i know you did "copy & paste"  ;)
And there's no need to add prefix = "!" since local s,e,cmd = string.find(data,"%b<>%s%p(%w+)") ;D

Edit--// Generated an error [11:07] Syntax ...trador\Desktop\Ptokax 0.3.4.0f1.dbg\scripts\test.lua:86: attempt to perform arithmetic on field '?' (a nil value)



Help fixing plz

((KMN))Gazza-95


((KMN))Gazza-95

[19:41] Syntax D\scripts\The DoorMan V1.0.lua:2: function arguments expected near `='

((KMN))Gazza-95


SMF spam blocked by CleanTalk