G-Bot v1.0 AIO in making.
 

G-Bot v1.0 AIO in making.

Started by TZB, 23 January, 2010, 21:48:30

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TZB

Sharing the finished script for people who are interested in learning about script.
Also have attached test script which i used to understand the layout of Module making.
Hope it helps you guys.
Will continue this work.
This Script Contains Simple Settings.ini
and 1 Login info Module.

P.S - Mr.Dreams Please Don't post for any requests here.Or any unrelated questions.

Madman

Nice work.
One thing tho. NewUserConnected is from old API it's been replaced by UserConnected and RegConnected in the new API
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

TZB

Thanks Madman.
The Attachment above updated with RegConnected.
Going for another Module Now.

TZB

#3
Was Just thinkingif i can load both the Modules in the Module folder at a same time so just few here and there in the main script figured out how to bring it on.
It loads the Message in the Test.lua along with LoginInfo.lua
--------------------------------------------------------------------------------------------
-- G-Bot v1.0 ||-T-z-B-|| (24/1/2010)
-- Its Learning and Developing Project Thanks to CrazyGuy,TTB,Flexo
-- Those who want to learn about AIO can use it since CrazyGuy and TTB have made it simpler.
-- Will be trying on more modules to join with this offcourse with help till then enjoy.
-- G-Bot v1.0a ||-T-z-B-|| (24/1/2010)
-- Loads Both Logininfo.lua and Test.lua from Modules Folder.
--------------------------------------------------------------------------------------------

OnStartup = function()
	local sPath = Core.GetPtokaXPath().."scripts/GBOT/"  --[Path of G-Bot Folder for Modules and settings table]
	pcall(dofile,sPath.."settings.ini")                  --[Settings.ini Containing BOT info table]
	sPath = sPath.."Modules/"                            --[Path For Modules Table]
	pcall(dofile,sPath.."LoginInfo.lua")                 --[Call the Module inside Module folder]
        pcall(dofile,sPath.."Test.lua")

	if tSettings and tLoginInfo then
		Core.RegBot(tSettings.sBot.RegName,tSettings.sBot.Description,tSettings.sBot.Email,tSettings.sBot.Op)
		local sInit = " LoginInfo Module"
		if tLoginInfo.Init() == true then
			sInit = sInit.."was successfully loaded."        --[Message After loading the Module]
		else
			sInit = sInit.."was NOT successfully loaded."
		end
		Core.SendToAll(tSettings.sBot.Name..sInit)

	else
		OnError()     
		ScriptMan.StopScript("G-BOT.lua")
	end

          if tSettings and tTest then
               local sInit = " Test Module"
          if tTest.Init() == true then
                     sInit = sInit.."was successfully loaded."
          else
                     sInit = sInit.."was NOT successfully loaded."
          end
          Core.SendToAll(tSettings.sBot.Name..sInit)
          tTest.Message()
       else
              OnError()
              ScriptMan.StopScript("G-BOT.lua")
       end
end

Please help me if i can improve on this.

TZB

--------------------------------------------------------------------------------------------
-- G-Bot v1.0 ||-T-z-B-|| (24/1/2010)
-- Its Learning and Developing Project Thanks to CrazyGuy,TTB,Flexo
-- Those who want to learn about AIO can use it since CrazyGuy and TTB have made it simpler.
-- Will be trying on more modules to join with this offcourse with help till then enjoy.
-- G-Bot v1.0a ||-T-z-B-|| (24/1/2010)
-- Loads Both Logininfo.lua and Test.lua from Modules Folder.
-- G-Bot v2.0  (27/1/2010)
-- New Edits made By CrazyGuy *Marked As New*
-- Collects Error and reports in Main Chat for all the errors in modules with Details.
--------------------------------------------------------------------------------------------
OnStartup = function()
	local tErrors = {}		--NEW test !
	local useless = false	--NEW test !
	local sPath = Core.GetPtokaXPath().."scripts/GBOT/"  --[Path of G-Bot Folder for Modules and settings table]
	
	useless,tErrors["Settings"] = pcall(dofile,sPath.."settings.ini")
        
	if useless == true then tErrors["Settings"] = nil end
	sPath = sPath.."Modules/"                            --[Path For Modules Table]
	
	
	useless,tErrors["LoginInfo"] = pcall(dofile,sPath.."LoginInfo.lua")    --NEW
        
        if useless == true then tErrors["LoginInfo"] = nil end					--NEW
        useless,tErrors["Test"] = pcall(dofile,sPath.."Test.lua")			   --NEW
       
        if useless == true then tErrors["Test"] = nil end						--NEW
	
        local i = 0
	for k in pairs(tErrors) do i = i + 1 end
	if i > 0 then
		local bot = "<G-Bot> "
		Core.SendToAll(bot.."At least 1 module failed to load:|")
		for k in pairs(tErrors) do
			Core.SendToAll(bot.."Module: "..k.."  -->  "..tErrors[k].."|")
			-- Or you can use OnError(tErrors[k])
			end
                        ScriptMan.StopScript("G-BOT.lua")

	
	else
		Core.RegBot(tSettings.sBot.RegName,tSettings.sBot.Description,tSettings.sBot.Email,tSettings.sBot.Op)
		local sInit = " LoginInfo Module "
		if tLoginInfo.Init() == true then
			sInit = sInit.."was successfully loaded."        --[Message After loading the Module]
		else
			sInit = sInit.."was NOT successfully loaded."
		end
		Core.SendToAll(tSettings.sBot.Name..sInit)
	end
           if tSettings and tTest then
                local sInit = " Test Module"
          if tTest.Init() == true then
               sInit = sInit.."was successfully loaded."
          else
               sInit = sInit.."was NOT successfully loaded."
          end
          Core.SendToAll(tSettings.sBot.Name..sInit)
          tTest.Message()
       end
end

SMF spam blocked by CleanTalk