PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Not on 13 November, 2003, 17:39:55

Title: Open a new window.
Post by: Not on 13 November, 2003, 17:39:55
Hi, all  :]

I'm a newbie (bigtime he he) with scripting. I've been trying to get my helpfiles to open in a new popup window, and not in main (private message bla bla). The script i'm using looks like this:

Trigger = "!rules"
operatorFile = "rules.txt"
userFile = "rules.txt"

function DataArrival(curUser, data)
  if (strsub(data, 1, 1) == "<") then
    data = strsub(data, 1, strlen(data)-1)
    if (strfind(strlower(data), strlower(Trigger))) then
      if (curUser.bOperator) then
        ReadHelpFile(curUser, operatorFile)
      else
        ReadHelpFile(curUser, userFile)
      end
    end
  end
end

function ReadHelpFile(curUser, theFile)
  local handle = openfile(theFile, "r")
  if (handle ~= nil) then
    local line = read(handle)
    while line do
      curUser:SendData("   "   ..line)
      line = read(handle)
    end
    closefile(handle)
  end
end


I use the same script for getting different helpfiles, and it has to work with testdrive 4.99

I've downloaded script after script, but they all write the file in main, and not a new popup window... I've also tried (trial and error) changing some myself, but with no success  :(  

Could someone please help me with this one?
Title:
Post by: [T-G-T]M@sto on 13 November, 2003, 18:07:38
QuoteOriginally posted by Not
Hi, all  :]

I'm a newbie (bigtime he he) with scripting. I've been trying to get my helpfiles to open in a new popup window, and not in main (private message bla bla). The script i'm using looks like this:

Trigger = "!rules"
operatorFile = "rules.txt"
userFile = "rules.txt"

function DataArrival(curUser, data)
  if (strsub(data, 1, 1) == "<") then
    data = strsub(data, 1, strlen(data)-1)
    if (strfind(strlower(data), strlower(Trigger))) then
      if (curUser.bOperator) then
        ReadHelpFile(curUser, operatorFile)
      else
        ReadHelpFile(curUser, userFile)
      end
    end
  end
end

function ReadHelpFile(curUser, theFile)
  local handle = openfile(theFile, "r")
  if (handle ~= nil) then
    local line = read(handle)
    while line do
      curUser:SendData("   "   ..line)
      line = read(handle)
    end
    closefile(handle)
  end
end


I use the same script for getting different helpfiles, and it has to work with testdrive 4.99

I've downloaded script after script, but they all write the file in main, and not a new popup window... I've also tried (trial and error) changing some myself, but with no success  :(  

Could someone please help me with this one?
Maybe try replase:
curUser:SendData(" " ..line)

with this
curUser:SendPrivateMessage(" " ..line)
Title:
Post by: Optimus on 13 November, 2003, 18:11:40
curUser:SendPM(" " ..line)


thats the 1 to use
Title: new window
Post by: Not on 13 November, 2003, 18:26:17
Wow, that was quick :)

No pop up window, tried both suggestions, but didn't work...
looks like this:

Trigger = "!test"
operatorFile = "test.txt"
userFile = "test.txt"

function DataArrival(curUser, data)
  if (strsub(data, 1, 1) == "<") then
    data = strsub(data, 1, strlen(data)-1)
    if (strfind(strlower(data), strlower(Trigger))) then
      if (curUser.bOperator) then
        ReadHelpFile(curUser, operatorFile)
      else
        ReadHelpFile(curUser, userFile)
      end
    end
  end
end

function ReadHelpFile(curUser, theFile)
  local handle = openfile(theFile, "r")
  if (handle ~= nil) then
    local line = read(handle)
    while line do
      curUser:SendPM(" " ..line)
      line = read(handle)
    end
    closefile(handle)
  end
end

Does it matter that it's a privatehub with only regusers?
Title:
Post by: NightLitch on 13 November, 2003, 19:01:09
Here:

BotName = "-Txt-Bot-"

Trigger = "!test"
operatorFile = "test.txt"
userFile = "test.txt"

function Main()
frmHub:RegBot(BotName)
end

function DataArrival(curUser, data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data, 1, strlen(data)-1)
if (strfind(strlower(data), strlower(Trigger))) then
if (curUser.bOperator) then
ReadHelpFile(curUser, operatorFile)
else
ReadHelpFile(curUser, userFile)
end
end
end
end

function ReadHelpFile(curUser, theFile)
local handle = openfile(theFile, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
curUser:SendPM(BotName, line)
line = read(handle)
end
closefile(handle)
end
end

Try this one....
Title:
Post by: Optimus on 13 November, 2003, 19:21:53
Yups we forgot to do the (BotName) lol

Have a good 1
Title: new window
Post by: Not on 13 November, 2003, 21:10:19
Wiiiiiiii!    :D

The new one worked right away! Thanks a *lot*, guys!

Now it looks a lot more "proffessional", he he...  8)