Compiled Texter to LUA 5 ?
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Compiled Texter to LUA 5 ?

Started by jiten, 28 February, 2005, 10:40:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

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;

bastya_elvtars

Replace the following 2 lines:

function DataArrival(user,data)

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

to

function ChatArrival(user,data)
Everything could have been anything else and it would have just as much meaning.

Skrollster

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).

jiten

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)

bastya_elvtars

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
Everything could have been anything else and it would have just as much meaning.

jiten

Thanks for the hints, bastya_elvtars. It worked perfectly...  :D

plop

it should work fine with 425.lua and the newolddataarrival scripts i posted.
but they should be really converted.
any volunteers??  lol

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk