PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: zinden on 07 October, 2005, 18:57:21

Title: Search inside txt file.
Post by: zinden on 07 October, 2005, 18:57:21
Hello, got a request here, need a script that can search inside a txt file and show the hits on what it found in pm.

The txt file will look like this:

http://www.gamespot.com/AVP.htm      Alien Versus Predator
http://www.gamespot.com/Beatles.htm     Beatles, action
http://www.gamespot.com/victory.htm       Victory challenge



something like that it will look like inside the text file.
Then the script can handle like: !search Alien
And a pm pops up with this:


http://www.gamespot.com/AVP.htm      Alien Versus Predator

Found 1 match.



I thought there was a script for lua4 before, because i requested it before. But cant find it anywhere.
So i hope someone can make this script for me.
Title:
Post by: bastya_elvtars on 09 October, 2005, 13:31:27
Got 404 errors, but if you post a textfile for real, it is easy to make. :)
Title:
Post by: zinden on 09 October, 2005, 17:25:08
here is a text file:
http://dcmods.mine.nu/games.txt
Title:
Post by: zinden on 30 October, 2005, 09:05:53
anyone?
Title:
Post by: zinden on 12 November, 2005, 15:09:52
function Search(curUser,aFile,aString)
local f,e = io.open(aFile,"games.txt")
local message = "\r\n---===Search Results===---\r\n"
while 1 do
local line = f:read("*l")
if line == nil then break
elseif string.find(line,aString) then
message = message..line.."\r\n"
end
end
f:close(f)
curUser.SendData("SearchBot",message)
return 1
end


thats what i got so far.
can anyone help me make it complete?
Title:
Post by: bastya_elvtars on 12 November, 2005, 16:25:10
for line in f:lines() do
  if string.find(line,"wanna look 4 this",1,true) then
  -- found
end
Title:
Post by: zinden on 13 November, 2005, 18:46:00
that didnt make so much sence to me   :))
i hope someone can make it complete with a command too.
like +search ****
and pops up some search hits.