Hi all
I've got this weird problem and I thought that some extra opinions would help me with it, so I have an external function called getIndex that just simply returns the index of an item in a table. Weird part is is that it's called in another file of mine and works just fine but when I call it for this other purpose I get the following error
[ERROR] addons/hydra_ttt/lua/hydra_ttt/framework/sh_groups.lua:23: attempt to call global 'getIndex' (a nil value)Here's the code of the function
function getIndex(tbl, value)
for k, v in pairs(tbl) do
tbl[v] = k
end
return tbl[value]
end
Here's a working example of it's use in a file I call sh_playerstuff.lua
table.insert(args, getIndex(args, v), funny_words[math.random(1, #funny_words)])
And then here's an example where I get the error above in a file called sh_groups.lua
local group_name = string.Split(self:GetUserGroup(), "") --Just incase you're wondering what some of the variables below were for/from
table.insert(group_name, getIndex(group_name, "m"), string.upper(v))
I've tried using AddCSLuaFile but oddly enough in first file, where it works, doesn't require it.
Any help/input would be appreciated, thanks.
If you need anymore info just let me know