Author Topic: G-Bot  (Read 3045 times)

0 Members and 1 Guest are viewing this topic.

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
G-Bot
« on: 23 January, 2010, 12:45:23 »
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.
Code: [Select]
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.
Code: [Select]
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)

PtokaX forum

G-Bot
« on: 23 January, 2010, 12:45:23 »

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Re: G-Bot
« Reply #1 on: 23 January, 2010, 14:01:36 »
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?
Code: [Select]
tLoginInfo.Display()
« Last Edit: 23 January, 2010, 14:05:07 by TTB »
TTB

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

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: G-Bot
« Reply #2 on: 23 January, 2010, 14:03:55 »
I am still trying to get a grip on it TTB can you help me understand this.
Please.

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Re: G-Bot
« Reply #3 on: 23 January, 2010, 14:40:56 »
A little help:

Code: [Select]
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 <-.??.???)

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: G-Bot
« Reply #4 on: 23 January, 2010, 15:19:03 »
Main == >
Code: [Select]
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 ==>
Code: [Select]
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.

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Re: G-Bot
« Reply #5 on: 23 January, 2010, 15:54:14 »
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 <-.??.???)

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: G-Bot
« Reply #6 on: 23 January, 2010, 21:42:47 »
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.

PtokaX forum

Re: G-Bot
« Reply #6 on: 23 January, 2010, 21:42:47 »