I don't know if I'm just being an idiot (very possible) or if some of these function parameters are dyslexic.
From what I can tell using print (and looking at the MapGen scripts for some parameter guidance) Map:GetPlotXY() has the x and y flipped and Map:GetPlot() is just broken.
Lua script to be included into a temp mod like usual and recommended duel size map with no barbs or city states and a settler tier ai. Logs at the end of player turns only.
From what I can tell using print (and looking at the MapGen scripts for some parameter guidance) Map:GetPlotXY() has the x and y flipped and Map:GetPlot() is just broken.
Lua script to be included into a temp mod like usual and recommended duel size map with no barbs or city states and a settler tier ai. Logs at the end of player turns only.
Code:
local Settler = "UNIT_SETTLER"
function BackwardsParameters(playerID)
if (playerID ~= 0) then return end -- Ignore AIs
local playerUnits = Players[playerID]:GetUnits()
local plot_One, plot_Two, plot_Three, plot_Four
local plot_X, plot_Y
local unit_Main, unit_X, unit_Y
local plotTerrain
local unitTypeName
for i, unit_Main in playerUnits:Members() do
if (unit_Main ~= nil) then
unitTypeName = UnitManager.GetTypeName(unit_Main);
if (unitTypeName == ("LOC_" .. Settler .. "_NAME")) then
unit_X = unit_Main:GetX() -- These are fine according to debug tooltips
unit_Y = unit_Main:GetY() -- These are fine according to debug tooltips
print("Unit Found:\t\t\t\t\t" .. tostring(unitTypeName))
print("Unit X:\t\t\t\t\t\t" .. tostring(unit_X))
print("Unit Y:\t\t\t\t\t\t" .. tostring(unit_Y))
plot_One = Map:GetPlotXY(unit_X, unit_Y) -- How it should work
plot_Two = Map:GetPlotXY(unit_Y, unit_X) -- How it actually works
plot_Three = Map:GetPlot(unit_X, unit_Y) -- 0s the 1st parameter and possibly backwards too
plot_Four = Map:GetPlot(unit_Y, unit_X) -- 0s the 1st parameter and possibly backwards too
print("=-= GetPlotXY =-=")
if (plot_One ~= nil) then
print("======= 1 =======")
plotTerrain = plot_One:GetTerrainType()
plot_X = plot_One:GetX()
plot_Y = plot_One:GetY()
print("\tMapPlot X:\t\t\t\t\t" .. tostring(plot_X))
print("\tMapPlot Y:\t\t\t\t\t" .. tostring(plot_Y))
print("\tplotTerrain.Name:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Name))
print("\tplotTerrain.Index:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Index))
print("\tplotTerrain.Water:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Water))
print("\tplotTerrain.ShallowWater:\t"..tostring(GameInfo.Terrains[plotTerrain].ShallowWater))
print("=================")
else
print("======= 1 =======")
print("\tplot_One = nil")
print("=================")
end
if (plot_Two ~= nil) then
print("======= 2 =======")
plotTerrain = plot_Two:GetTerrainType()
plot_X = plot_Two:GetX()
plot_Y = plot_Two:GetY()
print("\tMapPlot X:\t\t\t\t\t" .. tostring(plot_X))
print("\tMapPlot Y:\t\t\t\t\t" .. tostring(plot_Y))
print("\tplotTerrain.Name:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Name))
print("\tplotTerrain.Index:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Index))
print("\tplotTerrain.Water:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Water))
print("\tplotTerrain.ShallowWater:\t"..tostring(GameInfo.Terrains[plotTerrain].ShallowWater))
print("=================")
else
print("======= 2 =======")
print("\tplot_Two = nil")
print("=================")
end
print("=-=- GetPlot -=-=")
if (plot_Three ~= nil) then
print("======= 3 =======")
plotTerrain = plot_Three:GetTerrainType()
plot_X = plot_Three:GetX()
plot_Y = plot_Three:GetY()
print("\tMapPlot X:\t\t\t\t\t" .. tostring(plot_X))
print("\tMapPlot Y:\t\t\t\t\t" .. tostring(plot_Y))
print("\tplotTerrain.Name:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Name))
print("\tplotTerrain.Index:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Index))
print("\tplotTerrain.Water:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Water))
print("\tplotTerrain.ShallowWater:\t"..tostring(GameInfo.Terrains[plotTerrain].ShallowWater))
print("=================")
else
print("======= 3 =======")
print("\tplot_Three = nil")
print("=================")
end
if (plot_Four ~= nil) then
print("======= 4 =======")
plotTerrain = plot_Two:GetTerrainType()
plot_X = plot_Four:GetX()
plot_Y = plot_Four:GetY()
print("\tMapPlot X:\t\t\t\t\t" .. tostring(plot_X))
print("\tMapPlot Y:\t\t\t\t\t" .. tostring(plot_Y))
print("\tplotTerrain.Name:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Name))
print("\tplotTerrain.Index:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Index))
print("\tplotTerrain.Water:\t\t\t"..tostring(GameInfo.Terrains[plotTerrain].Water))
print("\tplotTerrain.ShallowWater:\t"..tostring(GameInfo.Terrains[plotTerrain].ShallowWater))
print("=================")
else
print("======= 4 =======")
print("\tplot_Four = nil")
print("=================")
end
else
--print("Other Unit Found:\t"..unitTypeName)
end
end
end
end
Events.PlayerTurnDeactivated.Add(BackwardsParameters)