conversion please
 

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

conversion please

Started by damo, 20 April, 2005, 21:16:16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

damo

i got this script that i could do with converting if any could please i tryed but failed to work.
function Main()
frmHub:RegBot(botname)
end

function DataArrival(curUser, data)

status=string.sub(data,1,string.len(data)-1)
-- parse the command
s,e,cmd = string.find( status, "%b<>%s+(%S+)" )

if (cmd=="+quiet") then
trigall=0
SendToAll(botname, "Hmf, If you want me to be quiet you only have to ask Asshole :(( ")
return 1
elseif (cmd=="+talk") then
trigall=1
SendToAll(botname, "You are not worthy nor my Master, but as i'm a script i have no choice :-)")
return 1
end

       
   if( string.sub(data, 1, 1) == "<" ) then
      -- get the msg only using regular expression
      s,e,msg = string.find(data, "%b<>([%a ]+)")                                        
      -- look in the table
                if trigall==1 then
      for key, value in trigs do
                for key2, value2 in value do
                     
   if( string.find( string.lower(msg), key) ) then
                 else break  
   end

        if( string.find( string.lower(msg), "!me") ) then
                  t="**"..curUser.sName
                  data=string.gsub (msg, "!me", t, 1 )
   end

      SendToAll( data ) -- send the original data
                   
            SetTimer(1800)
                  StartTimer()
      answer, x = string.gsub(value[random(1,getn(value))], "%b[]", curUser.sName)

   return 1; -- tell the hub we have processed the data
   end
   end  
   end
end

function OnTimer()
   SendToAll( botname, answer ) -- send bot's answer
   StopTimer()
end
end

jiten

Try this (not tested):
-- converted to lua 5 by jiten

function Main() 
	frmHub:RegBot(botname) 
end 

function ChatArrival(curUser, data) 
	status=string.sub(data,1,string.len(data)-1) 
	-- parse the command 
	s,e,cmd = string.find( status, "%b<>%s+(%S+)" ) 
	if (cmd=="+quiet") then 
		trigall=0 
		SendToAll(botname, "Hmf, If you want me to be quiet you only have to ask Asshole :(( ") 
		return 1 
	elseif (cmd=="+talk") then 
		trigall=1 
		SendToAll(botname, "You are not worthy nor my Master, but as i'm a script i have no choice :-)") 
		return 1 
	end 

	-- get the msg only using regular expression 
	s,e,msg = string.find(data, "%b<>([%a ]+)") 
	-- look in the table 
	if trigall==1 then 
		for key, value in trigs do 
			for key2, value2 in value do 
				if( string.find( string.lower(msg), key) ) then 
				else break 
				end 

				if( string.find( string.lower(msg), "!me") ) then 
					t="**"..curUser.sName 
					data=string.gsub (msg, "!me", t, 1 ) 
				end 

				SendToAll( data ) -- send the original data 

				SetTimer(1800) 
				StartTimer() 
				answer, x = string.string.gsub(value[math.random(1,table.getn(value))], "%b[]", curUser.sName) 

				return 1; -- tell the hub we have processed the data 
			end 
		end 
	end 
end

function OnTimer() 
	SendToAll( botname, answer ) -- send bot's answer 
	StopTimer() 
end
Cheers

damo

sorry bro but an error
Syntax ...gs\Damo\Desktop\Copy of 0.3.3.0.b16\scripts\adda.lua:447: attempt to index field `string' (a nil value)

jiten

QuoteOriginally posted by damo
sorry bro but an error
Syntax ...gs\Damo\Desktop\Copy of 0.3.3.0.b16\scripts\adda.lua:447: attempt to index field `string' (a nil value)
Erm, there's no 447th line in the script I posted.
Btw, the script u gave me is very incomplete, so it may not work. Looks like wiseguy....

Cheers

[UK]Madman

Isnt there an extra sting in there.....

answer, x = string.string.gsub (value[math.random(1,table.getn(value))], "%b[]", curUser.sName)


Im guessinthat it should be string.gsub

jiten

QuoteOriginally posted by [UK]Madman
Isnt there an extra sting in there.....

answer, x = string.string.gsub (value[math.random(1,table.getn(value))], "%b[]", curUser.sName)


Im guessinthat it should be string.gsub
Indeed ;)

damo

thx guys is working fine now thanks for the help must have missed one on the converting

jiten

QuoteOriginally posted by damo
thx guys is working fine now thanks for the help must have missed one on the converting
yw :]

SMF spam blocked by CleanTalk