Need help please convert to lua 5
 

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

Need help please convert to lua 5

Started by AMediaMan, 16 November, 2005, 04:15:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMediaMan

yes i know this is an old script, but its had many changes and the people in my hub love it but i am currently running PtokaX 0.3.3.1 and this script is for lua 4 :( any help would be great :)


-- TrickerBot2.lua, created by Ptaczek Dec-24, 2002
-- Just see how to implement the NMDC TriggerBot in LUA :)	
-- changes
-- Feb-24, 2003, v2.0 Modification for DataArrival return value.
-- Tiny changes by VidFamne with lot of help by Piglja
-- VidFamne added Pigljas time-function, and some more trigs
-- A bug-fix by VidFamne, hopefully. And added some more triggs ;)
-- A new bug-fix ( for the "!me-command" ) by VidFamne, added ( 09.04.2003 ).
-- Added MatrixX On/Off function. Just type +quiet in mainchat to stop the Bot,
-- and +talk to start the Bot again. By VidFamne ( 05.05.2003 )
-- Bug-fix by [AF]Mike

botname = "[TPN]M?. ???b??"

trigall=1

trigs = {
              
			
			["*wassup"]={
     	"hunting crocodiles",
     	"nothing at the moment",
     	"eating",
     	"eating pizza :)",
     	"changing the tires on my dodge",
     	"juggling chainsaws",
     	"drinking beer",
     	"smoking up a storm",
     	"belly-dancing",
     	"hacking microsoft.com",
     	"trying to keep awake!",
     	"watching television",
     	"I am doing homework",
     	"what do you think!",
     	"building a spice rack",
     	"taking a shower",
     	"drinking myself to death",
     	"drinking myself to oblivian",
     	"making origami swans",
     	"feeding my ducks",
     	"learning latin",
     	"programming",
     	"play the basoon",
     	"program in Assembly",
     	"program in C++"
                        	},
                 
			["*are you"]={ 
	"does it matter if I am ?",
	"what difference does it make whether or not I am",
	"of course not, don't be silly",
	"Whether I'm or not is my secret",
	"why do you want to know?",
	"why are you so nosy?",
	"perhaps I am ",
	"none of your business",
	"I think you are ",
	"does it matter if I am or not?",
	"why do you ask?",
	"I might be",
	"No, I am not ",
	"of course",
	"never have been",
	"why, are you?"
                            	},
                    
                    
			["*yeah"]={
	"yes",
	"yep",
	"uh huh",
	"100%",
	"bang on!",
	"you bet",
	"uh-hu",
	"yes",
	"of course!",
	"you-betcha",
	"affirmative",
	"10-4 good buddy!",
	"correct",
	"yeah",
	"that's right!",
	"you got it!",
	"sure",
	"precisely right",
	"that sounds right",
	"exactly!",
	"you know it!",
	"yeppers"
                           	}     		
	           
	}



--//edit this junk
botname = "[TPN]M?. ???b??" --//set the reply name
OneRandomName ="?k?ll?" --//put a random name here.. (anything) to populate the random table, and avoid errors.

--//ok stop,
-----------------------
function Main()
   frmHub:RegBot(botname)
end
trigall=1   
onlineUsers = {[OneRandomName] = 1}
sAnswer={}
sTrig = nil
function NewUserConnected(user)
   onlineUsers[user.sName] = 1
end
function OpConnected(user)
   onlineUsers[user.sName] = 1
end
function UserDisconnected(user)
   onlineUsers[user.sName] = nil
end
function OpDisconnected(user)
   onlineUsers[user.sName] = nil
end
function randomName()
   local n = 0
   for k,v in onlineUsers do n=n+1 end
   n = random( n ) 
   for k,v in onlineUsers do
      if n == 1 then
         k = k or ""
         return k 
      end
      n = n - 1
   end
end
function DataArrival(curUser, data)
   if( strsub(data, 1, 1) == "<" ) then
      status=strsub(data,1,strlen(data)-1) 
      if not onlineUsers[curUser.sName] then onlineUsers[curUser.sName] = 1 end --//trying to populate the random list faster.
      -- parse the command 
      s,e,cmd = strfind( status, "%b<>%s+(%S+)" ) 
      if (cmd=="!quiet") then 
         trigall=0 
         SendToAll(botname, " Hmf, Okidoki I will be quiet :(( ") 
         return 1
      elseif (cmd=="!talk") then 
         trigall=1 
         SendToAll(botname, " Okay, I will talk to you again :-)") 
         return 1
      end 
      -- get the msg only using regular expression
      s,e,msg = strfind(status, "%b<>%s+(.+)")                                        
      -- look in the table
      if strfind(msg, "^%pme .+") then
         t="**"..curUser.sName
         data=gsub (msg, "%pme", t, 1 )
         SendToAll( data )
         return 1
      end
      msg = strlower(msg)
      if trigall==1 then
         findTriggers(msg, curUser)
      end
   end
end
function findTriggers(d,u)
   for key, value in trigs do
      if strsub(key,1,1) == "*" then
         trigFound = nil
         x = gsub(key,"*","")
         local m = gsub(d,"(%S+)",
         function (w)
            if w == x then trigFound =  1 end
         end)
         if trigFound then
            SetTimer(1000)
            StartTimer()
            answer = gsub(trigs[key][random(1,getn(value))], "%[CURUSER%]", u.sName)
            answer = gsub(answer, "(%[RNDUSER%])", randomName())
            if sTrig == nil then sTrig = {} end
            sTrig[clock() + random(1,6)] = {[1] = answer}            
            break
         end
      else
         if(strfind(msg, key) ) then
            SetTimer(1000)
            StartTimer()
            answer = gsub(trigs[key][random(1,getn(value))], "%[CURUSER%]", u.sName)
            answer = gsub(answer, "(%[RNDUSER%])", randomName())
            if sTrig == nil then sTrig = {} end
            sTrig[clock() + random(1,6)] = {[1] = answer}
            break
         end
      end
   end
end
function OnTimer()
   if sTrig ~= nil then
      for k,v in sTrig do
         if k < clock() then
            SendToAll( botname, v[1])
            sTrig[k] = nil
         end
     end
      if sTrig == nil then StopTimer() end 
  end
end


Thnx, AMediaMan

Tw?sT?d-d?v

#1
search and you will find      click me  :D

DJ Bert

Download here for the bot with key or here without key


Grtzzz

DJ Bert

AMediaMan

#3
TY both :) i didnt realize it was tricker bot now lol.
i will grab one from the links posted thnx again.




P.S. is there a way to add random user in as well ? the script i posted used random user as well as current user, or maybe just make the script i posted in lua 5:o)


AMediaMan

DJ Bert

The links of bot what i given has al random in it. It ans wered the users. Example: wenn User say: Hello then the bot response: User, do I know you?

It randomize all.

AMediaMan

Im sorry DJ Bert you might not understand
i will give you an example :)
<<>> thats crazy.
<<>> you think thats crazy (random user) is a nut case.
(random user) = anyone in the user list but me :)

Also in the script i posted it is word specific.
meaning in this script if you type hi the bot responds,
if you type think the bot responds with the same hi answers, because hi is also in the word think.
thats why i thought it might be easier to just change the one i posted to lua 5 seems how these changes are already there :)

sorry if i seem a pest :( and ty for your input :)


AMediaMan

SMF spam blocked by CleanTalk