G-Bot
 

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

G-Bot

Started by TZB, 23 January, 2010, 12:45:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TZB

Hello Everyone i am here trying to learn and make AOI.Crazyguy helped me with most of this.Now i am stuck with few things in module.I am pasting the main code and the module to be loaded.I am having error in tables which i am not able to get it. Please if someone can help me make this things right and also help me how to improve the script since i am just a beginner.
Main script.
OnStartup = function()
	local sPath = Core.GetPtokaXPath().."scripts/GBOT/"
	pcall(dofile,sPath.."settings.ini")
	sPath = sPath.."Modules/"
	pcall(dofile,sPath.."LoginInfo.lua")


	if tSettings and tLoginInfo then
		Core.RegBot(tSettings.sBot.RegName,tSettings.sBot.Description,tSettings.sBot.Email,tSettings.sBot.Op)
		local sInit = "tLoginInfo Init "
		if tLoginInfo.Init() == true then
			sInit = sInit.."was successful."
		else
			sInit = sInit.."was NOT successful."
		end
		Core.SendToAll(tSettings.sBot.Name..sInit)
		tLoginInfo.Display()
                tLoginInfo.Function()
	else
		OnError()        
		ScriptMan.StopScript("G-BOT.lua")
	end
end


Settings.ini is loaded perfectly thanks to crazyguy. the another module is having some problem which i can't make it out.
tLoginInfo = {
		Init = function()
			local sPath = Core.GetPtokaXPath().."scripts/GBOT/Modules"
		end,
            Display = {
                     Hubs = true,
                     Profile = true,
                     IP = true,
                     Desc = true,
                     },
            Function = {
            Info = function(user)
                   Core.GetUserAllData(user)
                   Msg = Msg.. "\r\n\tInformation"
                   Msg = Msg.. " Nick: " ..user.sNick
                   
               if tLoginInfo.Display.Profile then
                  Prof = ProfMan.GetProfile(user.iProfile)
                  if Prof then
                      Msg = Msg.. " Profile: " ..Prof.sProfileName
                  else
                      Msg = Msg.. " Profile: User "  
                  end
                end
               if tLoginInfo.Display.IP then
                      Msg = Msg.. " IP: " ..(user.sIP or "Unknown")
                end
               if tLoginInfo.Display.Desc then
                      Msg = Msg.. " Description: " ..(user.sDescription)
               end
               tCore.Send(user,Msg,1)
             end,
             },
                   
}


the error message is
Quote[17:13] Syntax D:\0.4.1.2-5.2.0-W2_2\scripts\G-BOT.lua:17: attempt to call field 'Display' (a table value)

TTB

#1
You're calling a function which is not a function. You can't run a table value as a function.

What does it do when deleting this line?
tLoginInfo.Display()
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

TZB

I am still trying to get a grip on it TTB can you help me understand this.
Please.

TTB

A little help:

OnStartup = function()
	local sPath = Core.GetPtokaXPath().."scripts/GBOT/"
	pcall(dofile,sPath.."settings.ini")
	sPath = sPath.."Modules/"
	pcall(dofile,sPath.."LoginInfo.lua")


	if tSettings and tLoginInfo then
		Core.RegBot(tSettings.sBot.RegName,tSettings.sBot.Description,tSettings.sBot.Email,tSettings.sBot.Op)
		local sInit = "tLoginInfo Init "
		if tLoginInfo.Init() == true then
			sInit = sInit.."was successful."
		else
			sInit = sInit.."was NOT successful."
		end
		Core.SendToAll(tSettings.sBot.Name..sInit)
	else
		--OnError()    DEFINE!        
		ScriptMan.StopScript("G-BOT.lua")
	end
end

-- Sorry, lazy to check the core thingie of PtokaX api. Fix it on your own :)
RegConnected = function(user)
		tLoginInfo.Info(user)
end
OpConnected = RegConnected


tLoginInfo = {
		Init = function()
			local sPath = Core.GetPtokaXPath().."scripts/GBOT/Modules"
		end,
		Display = {
			Hubs = true,
			Profile = true,
			IP = true,
			Desc = true,
		},
		Info = function(user)
			Core.GetUserAllData(user)
			Msg = ""
			Msg = Msg.. "\r\n\tInformation"
			Msg = Msg.. " Nick: " ..user.sNick
			if tLoginInfo.Display.Profile then
				Prof = ProfMan.GetProfile(user.iProfile)
				if Prof then
					Msg = Msg.. " Profile: " ..Prof.sProfileName
				else
					Msg = Msg.. " Profile: User "  
				end
			end
			if tLoginInfo.Display.IP then
				Msg = Msg.. " IP: " ..(user.sIP or "Unknown")
			end
			if tLoginInfo.Display.Desc then
				Msg = Msg.. " Description: " ..(user.sDescription)
			end
		tCore.Send(user,Msg,1)
		end
	}
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

TZB

Main == >
OnStartup = function()
	local sPath = Core.GetPtokaXPath().."scripts/GBOT/"
	pcall(dofile,sPath.."settings.ini")
	sPath = sPath.."Modules/"
	pcall(dofile,sPath.."LoginInfo.lua")


	if tSettings and tLoginInfo then
		Core.RegBot(tSettings.sBot.RegName,tSettings.sBot.Description,tSettings.sBot.Email,tSettings.sBot.Op)
		local sInit = "tLoginInfo Init "
		if tLoginInfo.Init() == true then
			sInit = sInit.."was successful."
		else
			sInit = sInit.."was NOT successful."
		end
		Core.SendToAll(tSettings.sBot.Name..sInit)
                tLoginInfo.Info(user)
	else
		OnError()     
		ScriptMan.StopScript("G-BOT.lua")
	end
end


Module ==>
tLoginInfo = {
		Init = function()
			local sPath = Core.GetPtokaXPath().."scripts/GBOT/Modules"
		end,
		Display = {
			Hubs = true,
			Profile = true,
			IP = true,
			Desc = true,
		},
        OpConnected = function(user)
		tLoginInfo.Info(user)
	end,
	UserConnected =  function(user)
		tLoginInfo.Info(user)
	end,
	RegConnected = function(user)
		tLoginInfo.Info(user)
	end,
		Info = function(user)
			Core.GetUserAllData(user)
			Msg = ""
			Msg = Msg.. "\r\n\tInformation"
			Msg = Msg.. " Nick: " ..user.sNick
			if tLoginInfo.Display.Profile then
				Prof = ProfMan.GetProfile(user.iProfile)
				if Prof then
					Msg = Msg.. " Profile: " ..Prof.sProfileName
				else
					Msg = Msg.. " Profile: User "  
				end
			end
			if tLoginInfo.Display.IP then
				Msg = Msg.. " IP: " ..(user.sIP or "Unknown")
			end
			if tLoginInfo.Display.Desc then
				Msg = Msg.. " Description: " ..(user.sDescription)
			end
		tCore.Send(user,Msg,1)
		end
	}

I know i am doing it too much going for this.
The error when i have this thing loaded is the core thing.
Quote[19:44] Syntax D:/0.4.1.2-5.2.0-W2_2/scripts/GBOT/Modules/LoginInfo.lua:22: bad argument #1 to 'GetUserAllData' (table expected, got nil)

and when i omit the tLoginInfo.Info(user) then the script shows no error though but the script sends a message of not loading.
Quote[19:44:50] <G-Bot> LoginInfo Init was NOT successful.
and now again i am stuck again with tables trying to figure out if anyone can send me some hints please.

TTB

Like I told you... the OnStartup() is not user defined! The user is unknown so you can't call your module in your Startup function!
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

TZB

Thanks Guy for all the help i am really very thankful.
TTB i am sharing the files so that others can also learn as you said.
Thanks CrazyGuy will be troubling you with another module soon. :P
I am sharing the files in finished scripts.

SMF spam blocked by CleanTalk