PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: slick on 19 September, 2005, 00:57:19

Title: lua 4 to lua 5
Post by: slick on 19 September, 2005, 00:57:19
could somebody convert this script to lua 5 for me please & t/y


--Readme 1.0
--by Mutor
--
Command ="+commands"
TextFile ="commands.txt"
Send2All ="no" --Show all users? "yes"/"no"
--
function DataArrival(user, data)
   local s,e,cmd = strfind(data,"^%b<>%s(%S+)|")
      if cmd == Command then
         ReadText(user)
         return 1
      end
end

function ReadText(user)
readfrom(TextFile)
   while 1 do
      local line = read()
         if line == nil then break end
            if Send2All =="yes" then
               SendToAll(line)
            else
               user:SendData(line)
            end
         end
   readfrom()
end





Title:
Post by: bastya_elvtars on 19 September, 2005, 01:27:19
--Readme 1.0
--by Mutor
--
Command ="+commands"
TextFile ="commands.txt"
Send2All ="no" --Show all users? "yes"/"no"
--
function ChatArrival(user, data)
  local s,e,cmd = string.find(data,"^%b<>%s(%S+)|")
  if cmd == Command then
    ReadText(user)
    return 1
  end
end

function ReadText(user)
  local f=io.open(TextFile)
  if f then
    local contents = string.gsub(f:read("*a"),string.char(10), "\r\n")
    if Send2All =="yes" then
      SendToAll(contents)
    else
      user:SendData(contents)
    end
    f:close()
  end
end

You'd better use the builtin PtokaX textfile support.
Title:
Post by: slick on 19 September, 2005, 01:39:55
excellent t/y :)
Title:
Post by: slick on 19 September, 2005, 01:41:43
would you be interested in converting a few more if i need them ?
Title:
Post by: bastya_elvtars on 19 September, 2005, 01:58:43
QuoteOriginally posted by slick
would you be interested in converting a few more if i need them ?

Post them with CODE tag, there are many volunteers here, I go to sleep now.