PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: damo on 20 April, 2005, 21:16:16

Title: conversion please
Post by: damo on 20 April, 2005, 21:16:16
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
Title:
Post by: jiten on 20 April, 2005, 21:42:19
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
Title: eroor nice try tho
Post by: damo on 20 April, 2005, 22:23:36
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)
Title:
Post by: jiten on 21 April, 2005, 12:57:50
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
Title:
Post by: [UK]Madman on 21 April, 2005, 13:08:19
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
Title:
Post by: jiten on 21 April, 2005, 14:10:48
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 ;)
Title: working
Post by: damo on 21 April, 2005, 14:39:08
thx guys is working fine now thanks for the help must have missed one on the converting
Title:
Post by: jiten on 21 April, 2005, 15:09:51
QuoteOriginally posted by damo
thx guys is working fine now thanks for the help must have missed one on the converting
yw :]