diff --git a/lua/wire/client/customspawnmenu.lua b/lua/wire/client/customspawnmenu.lua index 9d025a21ad..651c2d3c12 100644 --- a/lua/wire/client/customspawnmenu.lua +++ b/lua/wire/client/customspawnmenu.lua @@ -26,18 +26,14 @@ local function expandall( bool, nodes ) end end -local function expandbycookie( nodes ) - for i=1,#nodes do - local b = cookie.GetNumber( nodes[i].WireCookieText ) - - if b and b == 1 then - nodes[i]:SetExpanded( b and b == 1 ) +local function expandbycookie(nodes) + for _, node in ipairs(nodes) do + if node.WireCookieText then + node:SetExpanded(cookie.GetNumber(node.WireCookieText) == 1) + end - if nodes[i].ChildNodes then - expandbycookie( nodes[i].ChildNodes:GetChildren() ) - end - else - nodes[i]:SetExpanded( false ) + if node.ChildNodes then + expandbycookie(node.ChildNodes:GetChildren()) end end end