Garry's Mod

Garry's Mod

Tool Organizer
Marty 11 Jul, 2024 @ 7:57pm
Well
I didnt feel putting this into the comments would be valuable when considering in the future, but to put simple:

[ERROR] lua/toolorganizer/categories.lua:260: attempt to index local 'toolPanel' (a nil value)
1. addToolToCustomCategory - lua/toolorganizer/categories.lua:260
2. loadCustomCategories - lua/toolorganizer/persist.lua:137
3. initCustomToolsMenu - lua/toolorganizer/core.lua:57
4. __event - lua/autorun/client/toolorganizer_client.lua:22
5. unknown - gamemodes/sandbox/gamemode/spawnmenu/spawnmenu.lua:252
6. unknown - lua/includes/modules/concommand.lua:54

The error above is likely caused because one of the listed tools (from the data folder) doesnt exist inside of the gtable (low words: you have not installed the tool), causing a halt whenever the invalid tool is being loaded.

You can quickly test this following these steps:
- install a tool from the workshop (whatever, the smartweld, for example).
- sort it/put into a cat as you wish. Make sure its on top of everything else (for visual representation purposes). Add more tools below of it.
- exit the game and unistall said tool
- start a new game and check the spawnmenu, where the cat is located
- you will see the category wont show anything you put before, and the lua error will appear

You can also summon the error by refreshing the menu (spawnmenu_reload)

A quick fix for this situation is adding a check if the toolPanel actually exists or not. If it doesnt exist, then its skipped (dont load) and avoid the error completely.

"lua/toolorganizer/categories.lua"
....
---------------
-- Tool CRUD --
---------------

function TOOLORG:addToolToCustomCategory(catPanel, toolPanel)
if not toolPanel then return end --Note the check here

local isFavorite = toolPanel.Favorite
local srcCatName = toolPanel:GetParent():GetChild(0):GetText()
local destCatName = catPanel:GetChild(0):GetText()
local originalCatName = toolPanel._SourceCategory or srcCatName
local originalToolName = (toolPanel._Name or toolPanel.Name)
local newToolName = originalToolName .. "_" .. destCatName
....

Now, looks like its promising, but i don't know if its an intended behaviour that configured tools that are missing on the server are "deleted" from the data folder, forcing me to readd them to categories and desirable sort, if you edit them on the fly.

pd: i said this last thing, because i hope the organizer can dynamically keep my configured tools (assigned categories, sorting) that are not available on the server, ofc being hidden since they dont exist.

Let me know if you have more questions
Last edited by Marty; 11 Jul, 2024 @ 8:08pm