whoward69
DLL Minion
Anybody who's ever used pPlot:SetResourceType(-1) to remove a resource from a plot will know that while it works and the resource is removed, the resource icon for the plot remains.
To fix this
The LuaEvents.RIM_ResetPlayerResources(iPlayer) event can be used to remove all resource icons for a player, useful after hiding all hexes from the player, for example, if changing their start position.
To fix this
- Add an "Assets" folder to your mod, with a "UI" sub-folder, with an "InGame" sub-sub-folder (exclude the doube quotes but make sure you get the case correct!)
- Into the "Assets/UI/InGame" sub-folder, add the "ResourceIconManager.lua" file from the core game directory
- Set "Import into VFS" to true for this file
- Edit the file and add the following to the very end
Code:------------------------------------------------- ------------------------------------------------- function OnResourceRemoved(hexPosX, hexPosY) local iPlayerID = Game.GetActivePlayer() if (g_PerPlayerResourceTables[iPlayerID] ~= nil) then local gridX, gridY = ToGridFromHex(hexPosX, hexPosY) local index = IndexFromGrid(gridX, gridY) DestroyResource(index) for iPlayerID, playerResourceTable in pairs(g_PerPlayerResourceTables) do playerResourceTable[index] = nil end end end LuaEvents.SerialEventRawResourceIconDestroyed.Add(OnResourceRemoved) ------------------------------------------------- ------------------------------------------------- function ResetPlayerResources(iActivePlayer) for index, pResource in pairs(g_ActiveSet) do DestroyResource(index) end g_PerPlayerResourceTables[iActivePlayer] = nil end LuaEvents.RIM_ResetPlayerResources.Add(ResetPlayerResources)
- After your pPlot:SetResourceType(-1) add
Code:pPlot:SetResourceType(-1) LuaEvents.SerialEventRawResourceIconDestroyed(iHexX, iHexY)
The LuaEvents.RIM_ResetPlayerResources(iPlayer) event can be used to remove all resource icons for a player, useful after hiding all hexes from the player, for example, if changing their start position.