DarkScythe
Hunkalicious Holo
- Joined
- May 6, 2014
- Messages
- 804
That looks like it might be it, yeah.
local g_SVStrikeIM = InstanceManager:new( "SVRangeStrikeButton", "Anchor", Controls.StrategicViewStrikeButtons );
SVInstances[playerID][cityID] = nil;
Events.SerialEventCityDestroyed(nil, iPlayer, iCity, -1);
LuaEvents.RemoveCityBanner.Add(function (iPlayer, iCity) OnCityDestroyed(nil, iPlayer, iCity, -1) end);
LuaEvents.RemoveCityBanner(iPlayer, iCity)
The usual praise be unto the Much-Knowing whowardYou're going to have to supply a modified version of CityBannerManager.lua with your mod, as all the instance managers you need are hidden inside it from other Lua contexts.
now, you could just do
to remove the city banner, BUT, any other mod/core system listening on that event would think that the city had been destroyed - probably not what you wanted to achieve!Code:Events.SerialEventCityDestroyed(nil, iPlayer, iCity, -1);
The replacement CityBannerManager.lua file only needs one extra line
Code:LuaEvents.RemoveCityBanner.Add(function (iPlayer, iCity) OnCityDestroyed(nil, iPlayer, iCity, -1) end);
and you can then remove city banners within your own lua file with
Code:LuaEvents.RemoveCityBanner(iPlayer, iCity)
Note that as a saved game is loaded all banners are recreated, so you're code will need to take steps to remove them again
Also note, that in hotseat, you'll have to remove the banner for all players during their turn (thanks to the Game.GetActiveTeam() call in the listener)
Thank you kindly, sir; I'll give this a try.Outside of the function, after the other ".Add" line
LuaEvents.ReAddCityBanner.Add(function (iPlayer, iCity) OnCityCreated(nil, iPlayer, iCity) end);
We determined this is possible to remove just the city from view, and then launched into the whole "banner not disappearing" problem.8) Using methods such as [Pazyryk's method of subscribing to SerialEvents], is it possible to make City X, a city of Player X, appear invisible to Player Y if Player Y does not have a unit adjacent to City X?
for pRingPlot in Map.GetPlot((pPlot:GetX() + math.ceil(math.random(-1,1))), (pPlot:GetY() + math.ceil(math.random(-1,1)))) do
...
iRadius = 3
function Sukritact_PlaceResource(pCity)
local pPlot = pCity:Plot()
local tPlots = {}
local iNumtoPlace = 1
for pLoopPlot in PlotAreaSweepIterator(pPlot, iRadius, SECTOR_NORTH, DIRECTION_CLOCKWISE, DIRECTION_OUTWARDS, CENTRE_EXCLUDE) do
table.insert(tPlots, pLoopPlot)
end
...
local function RandomResourceSeed()
local iMaxX, iMaxY = Map.GetGridSize()
local bValidPlotFound
while not bValidPlotFound do
local iX = math.random(iMaxX)
local iY = math.random(iMaxY)
local pPlot = Map.GetPlot(iX, iY)
if pPlot then
-- Plot exists; stuff additional terrain/feature checks here as necessary
local tempPlotTable = {pPlot}
-- Fill in the table with adjacent tiles
for i = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1 do
local pAdjacentPlot = Map.PlotDirection(iX, iY, i)
if pAdjacentPlot then
--Plot Exists
-- Stuff more terrain/feature checks here if you need all surrounding plots to abide by the same rules as well
if pAdjacentPlot:GetTerrainType() == TerrainTypes.TERRAIN_TUNDRA then
table.insert(tempPlotTable, pAdjacentPlot)
end
end
end
if #tempPlotTable > 3 then
-- This would only run if the table has more than 3 entries in it (Worst case, a corner tile would only be able to find 2 other adjacent tiles.)
-- You can increase the number to however many tiles you need at minimum.
local iResourceCount = 3 -- However many copies you need to place
-- This is where you can place JFD's table randomization code
for i = 1, iResourceCount do
local bResourcePlaced
while not bResourcePlaced and #tempPlotTable > 0 do
local iRandomIndex = math.random(#tempPlotTable)
local pTargetPlot = tempPlotTable[iRandomIndex]
-- Additional checks here if you want, if you didn't already filter them in the previous loop
pTargetPlot:SetResourceType(GameInfoTypes.RESOURCE_SECRET, 1)
bResourcePlaced = true
table.remove(tempPlotTable, iRandomIndex)
end
end
local bValidPlotFound = true
end
end
end
end