bad argument
 

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

bad argument

Started by mime, 12 August, 2007, 14:39:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mime

i need help whit this script.
i get this error.  textPM.lua:64: bad argument #1 to 'len' (string expected, got nil)


-- texter bot by plop

-- thx 2 chilla for the faster routine for opening the files

-- shows text files from a folder named text.

-- doesn't mather what prefix it used.

-- if the file exist it shows.

--

-- Converted to LUA 5 by Mutor 2/28/05

--



Bot = "?[Bot]TexT?"

FDFolder = "textpm"



function Main()

   frmHub:RegBot(Bot)

end



function ChatArrival(user, data)

   data=string.sub(data,1,string.len(data)-1)

   if( string.sub(data, 1, 1) == "<" ) then

      s,e,cmd = string.find(data,"%b<>%s+(%S+)")

      cmd = string.sub(cmd, 2,string.len(cmd))

      if io.open(FDFolder.."/"..cmd..".txt",r) ~= nil then

         showtext(user, cmd)

         return 1

      end

   end

end



function ToArrival(user, data)

    if(string.sub(data, 1, 4)) == "$To:" and (string.sub(data, 6,string.len(Bot)+5))== Bot then

        s,e,cmd = string.find(data,"^$To:%s+%S+%s+From:%s+%S+%s+%$%b<>%s+(%S+)|$")

        cmd = string.sub(cmd, 2,string.len(cmd))

            if io.open(FDFolder.."/"..cmd..".txt",r) ~= nil then

                showtext(user, cmd)

                return 1

            end

   end

end



function showtext(user, file)

local contents ="\r\n\r\n"

	for line in io.lines(FDFolder.."/"..file..".txt") do

    	contents = contents..line.."\r\n"

    end

	user:SendPM(Bot, contents.."\r\n|")

end


function showtextold(user, cmd)

local lines="\r\n\r\n"

    for line in io.lines(file) do

        lines = lines..line.."\r\n"

    end

    user:SendData(Bot, lines.." |")

end







Psycho_Chihuahua

Thats because you did not create the FD Folder.

I have attached a complete version where you just need to create the needed textfiles (an example is included)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

mime

now i get this.  scripts\texter.lua:32: bad argument #1 to 'len' (string expected, got nil)

and i just copy in your file
i find the error.
i have the wrong BOT in the script.


Thx for the fast replay

SMF spam blocked by CleanTalk