Author Topic: Module Script By American Idiot.  (Read 3271 times)

0 Members and 1 Guest are viewing this topic.

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Module Script By American Idiot.
« on: 11 September, 2009, 08:59:55 »
Hello Friends,
This was a help from American Idiot.
Actually i wanted a script for loading another scripts from a folder like in AOI. So American Idiot helped me for it a few weeks back but now i actually have started working on to it.
What i am doing here is using this module as a test. and made a directory called test as per the script requires and i added a simple script to reg the bot in the hub.And placed the script in the script folder using name as per script Module  as Script1.lua.

but when i start the module the bot is not registered.
It is giving me a error in  as
Quote
[12:33] Syntax [string "Modules = {..."]:21: attempt to index global 'Core' (a nil value)

Quote
[12:20] Syntax cannot open D:/My test Hub/scripts/test/Settings.ini: No such file or directory

Actually i have no idea what to do with it since am learning it and trying it out for the first time cant even look into other AOI since its very high level for me and i am on the basics level.
Please help me understand this problem.

Oops this the Script That American Idiot gave me:
Code: [Select]
Modules = {
"Script1.lua",
"Script2.lua",
"Script3.lua",
}
LoadModules = function()
local path,s = Core.GetPtokaXPath().."scripts/test/","\r\n\r\n"
for i,v in ipairs(Modules) do
local status = "loaded"
v = path..v
if loadfile(v) then
dofile(v)
else
status = "not loaded"
end
s = s.."\t"..v.." was "..status.."\r\n"
end
return s
end

Path = Core.GetPtokaXPath().."scripts/test/"
OnStartup = function ()
dofile(Path.."Settings.ini")
end
« Last Edit: 11 September, 2009, 09:03:58 by TZB »

PtokaX forum

Module Script By American Idiot.
« on: 11 September, 2009, 08:59:55 »

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: Module Script By American Idiot.
« Reply #1 on: 11 September, 2009, 11:00:21 »
Sorry I had not posted the Module which i was trying to load
Its actually i read it by going through Flexo made by Madman.And i am using it learn about the plugins.
This is the module

Quote
Modules ["Script1"] = {
         ["Config"] = {
                       ["Bot"] = "Test",
                       ["Reg"] = true,
                      },
         ["OnStartup"] = function()
                Modules.Script1.Func.CheckReg()
         end,
         ["Func"] = {
                  ["CheckReg"] = function()
                             if Modules.Script1.Config.Reg then
                                 Core.RegBot(Modules.Script1.Config.Bot,"","",true)
                             else
                                 Modules.Script1.Config.Bot = SetMan.GetString(21)
                             end
                         end,
                        }
}

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Module Script By American Idiot.
« Reply #2 on: 11 September, 2009, 20:55:23 »
'Core' is a nil value (non-existing) until OnStartup has been called.

use below code instead

Code: [Select]
Modules = {
"Script1.lua",
"Script2.lua",
"Script3.lua",
}
LoadModules = function()
local path,s = Core.GetPtokaXPath().."scripts/test/","\r\n\r\n"
for i,v in ipairs(Modules) do
local status = "loaded"
v = path..v
if loadfile(v) then
dofile(v)
else
status = "not loaded"
end
s = s.."\t"..v.." was "..status.."\r\n"
end
return s
end

OnStartup = function ()
Path = Core.GetPtokaXPath().."scripts/test/"
dofile(Path.."Settings.ini")
end

PtokaX forum

Re: Module Script By American Idiot.
« Reply #2 on: 11 September, 2009, 20:55:23 »