PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: FrAcTi0n on 07 April, 2005, 16:36:13

Title: need help,getting thiz: attempt to call global `readfrom' (a nil value
Post by: FrAcTi0n on 07 April, 2005, 16:36:13
attempt to call global `readfrom' (a nil value) on undermarked line... please help

function TextLoad(file,array,text) array[0]="" local x=0
   readfrom(file)
   repeat    if (text) then
         text=text..array      end
      x=x+1
      array   until (array   readfrom()
   return text
end

thanx for help...
Title:
Post by: Stravides on 07 April, 2005, 21:18:56
firstly try to use [ code] and [ /code] tags but with no space after the initial bracket..

What the program is looking for is a function called readfile using parameter file

function ReadFile(bot,user,file,output)
local handle = io.open(file, "r")
local contents = string.gsub(handle:read("*a"), string.char(10), "\r\n")
handle:close()
if output=="main" then
user:SendData(bot,"\r\n"..contents)
elseif output == "pm" then
user:SendPM(bot,"\r\n"..contents)
end
return contents
end

call the function with  
     ReadFile(bot, user, file, "pm") -- if outputting to PM
or
     ReadFile(bot, user, file, "main")  -- if to main chat
Title:
Post by: FrAcTi0n on 08 April, 2005, 07:55:53
hmm i am newbie in lua.. so i think i am not able to fix it...
would u please try to look on tho whole script?
script (http://junglist.cz/DB_v08-t.lua)
thx