• spawnmenu.GetTools() is returning nil
    6 replies, posted
why do i get [CODE] [ERROR] gamemodes/zombie/gamemode/cl_menu.lua:405: attempt to index a nil value 1. Init - gamemodes/zombie/gamemode/cl_menu.lua:405 2. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:153 3. Call - gamemodes/zombie/gamemode/cl_menu.lua:1063 4. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:66 5. unknown - lua/includes/modules/concommand.lua:69 [/CODE] from [lua] if Loaded == false || Loaded == nil || Loaded == NULL || Loaded == "" then AllTools = spawnmenu.GetTools() local Loaded = true end local tTables = AllTools print(table.ToString( spawnmenu.GetTools(), "spawnmenu.GetTools()", true )) --This prints nothing if tTables then for k, v in pairs(tTables[1].Items) do --This is line405 if ( type( v ) == "table" ) then local Name = v.ItemName local Label = v.Text if table.HasValue(menu_Categorys, Name) then v.ItemName = nil v.Text = nil self:AddCategory( Name, Label, v ) end end end else LocalPlayer():ChatPrint("There has been an error loading your tools section, please rejoin the server or contact an administrator to fix this.") end [/lua]
Firstly, the loading thing you're doing could easily be causing problems, and you're making [i]Loaded[/i] local, so it won't be accessible outside of the [i]if[/i] block. A more ideal way to do this would be something like this: [lua]local AllTools = AllTools || spawnmenu.GetTools()[/lua] If this doesn't solve the your problem, you'll need to figure out why [i]tTables[1].Items[/i] is inexistent, but my guess is that your [i]if[/i] block isn't running in the first place.
[CODE]print(table.ToString( spawnmenu.GetTools(), "spawnmenu.GetTools()", true ))[/CODE] is returning nil [CODE] spawnmenu.GetTools() = { } [/CODE]
Heh that looks a lot like Flood's "custom" spawn menu, the way the spawn menu works has changed a lot, you're better off recreating this one rather than trying to port it to work with 13.
Try running that from the console ([i]lua_run_cl[/i]), and then again whilst in sandbox. What gamemode are you deriving from, if any?
I'm deriving it from a working gmod13 flood mod gamemode. I'm trying to make a working zombie Apocalypse like gamemode that's more about killing zombies than becoming them.
My guess is, it's the menu system in the gamemode you're deriving from or have implemented into your code. As Matt suggested, you'll be a lot better off building one yourself.
Sorry, you need to Log In to post a reply to this thread.