Hi all,
I'd like to ask why a code like this will produce exit with an error like unable to find global b():
Lua Code:
local function a()
-- code
end
local function b()
-- code
end
local function c()
-- code
b()
end
This because if I change my functions to local:
RemGank_Validate_DB,
RemGank_Check_Player,
RemGank_Add_Player and
RemGank_Record_Player
this doesn't work anymore:
Lua Code:
-- code
local function RemGank_Record_Player(name, note)
if note == nil or note == "" then note = default_note end
RemGank_Validate_DB(name)
RemGankDB[name]["name"] = name:lower()
RemGankDB[name]["desc"] = string.sub(note,1,25)
RemGankDB[name]["lastloc"] = GetZoneText() .. "/" .. GetSubZoneText() .. " - " .. date("%d.%m.%Y %H:%M:%S")
RemGankDB[name]["nrkill"] = ( RemGankDB[name]["nrkill"] + 1 )
print(string_format("%s: adding %s [ %s ] [ kills: %i ] ", prgname, name, note, RemGankDB[name]["nrkill"]))
end
local function RemGank_Validate_DB(name)
RemGankDB[name] = RemGankDB[name] or {}
RemGankDB[name]["name"] = RemGankDB[name]["name"] or {}
RemGankDB[name]["desc"] = RemGankDB[name]["desc"] or {}
RemGankDB[name]["lastloc"] = RemGankDB[name]["lastloc"] or {}
RemGankDB[name]["nrkill"] = RemGankDB[name]["nrkill"] or 0
end
-- code
If I declare them not local everything works.
I'll attach the full code if someone wants to check it.
As usual thanks in advance to everyone.