Disclaimer: This post is AI generated. If you are anti-AI, then please keep your hate to yourself.
Hey! I maintain Multi-Team Support and gave Gridlocked a try with it over the weekend. Mostly works great. Your handlers don't filter by surface name so per-team chunk claiming works out of the box. Hit four things I wanted to flag.
1. Save crash when a team's surface gets deleted
This one took the save down. My mod deletes a team's surfaces when the slot is released. Got this on the next tick:
LuaRenderObject API call when LuaRenderObject was invalid.
__gridlocked__/control.lua:700: in function 'update_recent_claims'
storage.recent_claims still has render references after the surface is gone. Your on_surface_deleted clears storage.renders, storage.tints etc. but recent_claims isn't in there. Adding it to that handler should do it:
script.on_event(e.on_surface_deleted, function(event)
storage.renders[event.surface_index] = nil
storage.tints[event.surface_index] = nil
storage.redraw[event.surface_index] = nil
storage.default_tint_surfaces[event.surface_index] = nil
-- new:
for k, claim in pairs(storage.recent_claims) do
if claim.surface and not claim.surface.valid then
for _, render in pairs(claim.renders) do
if render.valid then render.destroy() end
end
storage.recent_claims[k] = nil
end
end
end)
A render.valid check inside update_recent_claims would be belt-and-suspenders, but the missing on_surface_deleted cleanup is the root cause. For now I'm telling people to flip gl-allow-unclaim on as a workaround. That avoids populating recent_claims at all.
2. Tooltip flicker on unclaimed chunks (joined players in MP)
In multiplayer, when a non-host player has an empty cursor and hovers any unclaimed chunk, the entity tooltip on the right flickers on and off every tick. Only joined players see it. Caused by this at control.lua:271-274:
if selected.name == "gl-unclaimed-chunk" then
player.selected = nil
end
Factorio re-selects the entity each tick because the cursor is over it, your code nulls it, Factorio re-selects, repeat.
The simplest fix would be to just drop those four lines. Letting an empty cursor leave the chunk entity selected only shows a harmless "Unclaimed chunk" tooltip. Nothing else seems to depend on the entity being unselectable when the tool isn't out:
else
-- removed: nulling player.selected here caused a per-tick flicker
-- in MP because Factorio re-selects the chunk entity next tick.
end
If something does rely on the selection being clear, selectable_in_game = false on the prototype with an alternate "select me when the tool is in cursor" mechanism would also work, but more invasive. You'll know better than I do which path is right for your code.
Workaround for users in the meantime is "keep any item in your cursor."
3. HUD chunk points label is stale after a force change
The "Chunk points: N" label is built once at on_player_created against whatever force the player is on then, and never rebuilds. In my mod players move from spectator to team-N when they claim a slot, so the HUD keeps showing spectator's points until research finishes on the new force and triggers your existing per-force update path.
Pretty sure 4 lines fixes it:
script.on_event(defines.events.on_player_changed_force, function(event)
local player = game.get_player(event.player_index)
local frame = player and player.gui.screen.gl_points
if frame and frame.flow and frame.flow.label then
frame.flow.label.caption = "Chunk points: " .. (storage.points[player.force.index] or 0)
end
end)
4. Discoverability of the claim tool
Bunch of new players have asked me "how do I claim a chunk?" They'd done the research, they could see the unclaimed grid everywhere, but no idea ALT+K spawned the tool. The shortcut bar icon is easy to miss too. Even one line on the unclaimed-chunk entity tooltip would cover most of these.
Smallest possible change is in locale/en/config.cfg:
[entity-description]
gl-unclaimed-chunk=Press __CONTROL__gl-give-chunk-claim-tool__ to get the chunk-claim tool.
That uses Factorio's control-name interpolation so the rebound key shows up correctly if a player has remapped ALT+K.
Thanks for the mod, I think we would enjoy it a lot once it works with MTS. Let me know if you'd like me to test fixes or split these into separate posts.