JA_Lamb
Warlord
Hi everyone, wonder if you can help?
1) I'd like to spread a new Feature at the beginning of the game after Resource and placement allocations but before Turn1.
The function I found may or may not work, but I would also like a critique of the whole code and my thinking.
2) The code is amply commented. There are at least 3 methods that I think are usable in the 'spread', and I present them all I would be grateful if the 'best' is highlighted for me. (One I think is wrong).
3) The feature should spread over every Desert Terrain plot inclusive of Improvements and Resources already placed, but not on Mountains or other Features. This I endeavour to do.
4) Once this is done, must this Lua be contained in it's own independent file or can it be part of other Lua codes that have nothing to do with it at all? eg. Where buildings are manipulated?
Thanks i advance.
1) I'd like to spread a new Feature at the beginning of the game after Resource and placement allocations but before Turn1.
The function I found may or may not work, but I would also like a critique of the whole code and my thinking.
2) The code is amply commented. There are at least 3 methods that I think are usable in the 'spread', and I present them all I would be grateful if the 'best' is highlighted for me. (One I think is wrong).
3) The feature should spread over every Desert Terrain plot inclusive of Improvements and Resources already placed, but not on Mountains or other Features. This I endeavour to do.
4) Once this is done, must this Lua be contained in it's own independent file or can it be part of other Lua codes that have nothing to do with it at all? eg. Where buildings are manipulated?
Code:
function realstart () -- Start @ Turn < 1. And do this once.
print("Begin Game!"); -- Print Test
for iPlot = 0, Map.GetNumPlots() - 1 do -- Map Plot itteration
local plot = Map.GetPlotByIndex(iPlot)
if plot:GetTerrainType() == (GameInfoTypes.TERRAIN_DESERT) then -- If Terrain is Desert
if plotType == PlotTypes.PLOT_MOUNTAIN then -- If Mountain (true)
return; -- stop. Next Plot ?? or continue (if)
if (plot:GetFeatureType() == FeatureTypes.NO_FEATURE) then -- 'elseif' required here or 'if' suffices?
if (plot:GetImprovementType() == ImprovementTypes.IMPROVEMENT_GOODY_HUT) -- Only Improvement. No stop
plot:SetFeatureType(GameInfoTypes.FEATURE_LMD_DESERT) -- Set new Feature method1
-- OR AS:
--2 plot:SetFeatureType(FeatureTypes.FEATURE_LMD_DESERT, 1); -- Set new Feature method2
-- OR AS:
--3 plot:SetFeatureType(FeatureTypes.FEATURE_LMD_DESERT, -1); -- Set new Feature method3
end
end
end
end
end
end
Events.SequenceGameInitComplete.Add ( realstart );
Thanks i advance.