PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: jiten on 28 February, 2005, 10:40:07

Title: Compiled Texter to LUA 5 ?
Post by: jiten on 28 February, 2005, 10:40:07
I converted this script to LUA 5 using plop's 425 converter and i didn't get any error when loading it. But, when i type in main something like !911 or !mznet, I don't get any response. Can someone help me on this?
Here's the supposed LUA 5 version:


botname = "?bot?"
file1 = "txt/ophelp.txt"
file2 = "txt/safenet.txt"
file3 = "txt/viphelp.txt"
file4 = "txt/userhelp.txt"
file5 = "txt/mznet.txt"
file6 = "txt/911.txt"

function DataArrival(user,data)
if string.sub(data, 1, 1) == "<" then
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")

if cmd == "!extrahelp" and (user.bOperator) then
readfrom(file1)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1

elseif cmd == "!safenet" then
readfrom(file2)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1

elseif cmd == "!extrahelp" and (user.iProfile == 2) then
readfrom(file3)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1

elseif cmd == "!extrahelp" and (user.iProfile == 3 or user.iProfile == -1) then
readfrom(file4)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1

elseif cmd == "!mznet" then
readfrom(file5)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1

elseif cmd == "!911" then
readfrom(file6)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1

end
end;
end;
Title:
Post by: bastya_elvtars on 28 February, 2005, 11:06:15
Replace the following 2 lines:

function DataArrival(user,data)

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

to

function ChatArrival(user,data)
Title:
Post by: Skrollster on 28 February, 2005, 11:11:45
you need to have a look at the new api:

function DataArrival(user,data) doesnt exist anylonger

Functions
---------
Main()
OnExit()
NewUserConnected(User)
UserDisconnected(User)
OpConnected(User)
OpDisconnected(User)
OnError(ErrorMsg)
SupportsArrival(User, Data)
ChatArrival(User, Data)            - if script return 1 hub don't process data.
KeyArrival(User, Data)
ValidateNickArrival(User, Data)
PasswordArrival(User, Data)
VersionArrival(User, Data)
GetNickListArrival(User, Data)
MyINFOArrival(User, Data)
GetINFOArrival(User, Data)
SearchArrival(User, Data)         - if script return 1 hub don't process data.
ToArrival(User, Data)            - if script return 1 hub don't process data.
ConnectToMeArrival(User, Data)         - if script return 1 hub don't process data.
MultiConnectToMeArrival(User, Data)      - if script return 1 hub don't process data.
RevConnectToMeArrival(User, Data)      - if script return 1 hub don't process data.
SRArrival(User, Data)            - if script return 1 hub don't process data.
KickArrival(User, Data)            - if script return 1 hub don't process data.
OpForceMoveArrival(User, Data)         - if script return 1 hub don't process data.
UserIPArrival(User, Data)         - if script return 1 hub don't process data.
UnknownArrival(User, Data)         - if script return 1 hub don't process data (don't disconnect user).
Title:
Post by: jiten on 28 February, 2005, 11:24:42
I made the replacements just like bastya_elvtars said, but, when I typed a command in mainchat i got this error:

Syntax ...rai\Desktop\16.04rls\scripts\cmdcompiler.lua_5.0.lua:65: attempt to call global `readfrom' (a nil value)
Title:
Post by: bastya_elvtars on 28 February, 2005, 11:31:26
This, and similar codes have to be replaced too:

readfrom(file5)

while 1 do

line = read()

if line == nil then break end

user:SendPM(botname,line)

end

readfrom()

to

local f,e = io.open(file5,"r")
if f then
while 1 do
local line = f:read("*l")
if line ==  nil then
break
end
                        user:SendPM(botname,line)
end
f:close(f)
end
Title:
Post by: jiten on 28 February, 2005, 13:18:11
Thanks for the hints, bastya_elvtars. It worked perfectly...  :D
Title:
Post by: plop on 28 February, 2005, 17:05:16
it should work fine with 425.lua and the newolddataarrival scripts i posted.
but they should be really converted.
any volunteers??  lol

plop