Wobzter
Chieftain
- Joined
- Mar 24, 2020
- Messages
- 4
Hello all,
i am trying to work with LUA and I run into the issue as described in the title.
For whatever reason I cannot acces the instance "Map". For example, when I do "Map.GetPlot(3,3)" in FireTuner while playing a normal (non-modded!) game, I get the following error:
From my understanding the instance Map should always be created, no?
This error persisted even upon restarting Civ 5, playing with mods and playing for more than 0 turns.
I have no extra mods in the DLC folder (like TakMod), so it's all "clean" in that sense.
Bonus info: I am trying to give a new Civ "Thule" a bonus of +1 food on snow and tundra. As a matter of practice I try to do this with LUA rather than XML (the prints are to see how far I can get without errors - it prints 2, but not 2.5):
Thank you very much for your attention!
Cheers
Wobzter
i am trying to work with LUA and I run into the issue as described in the title.
For whatever reason I cannot acces the instance "Map". For example, when I do "Map.GetPlot(3,3)" in FireTuner while playing a normal (non-modded!) game, I get the following error:
Code:
> Map.GetPlot(3,3)
Runtime Error: _cmdr = {Map.GetPlot(3,3)}:1: attempt to index global 'Map' (a nil value)
stack traceback:
_cmdr = {Map.GetPlot(3,3)}:1: in main chunk
From my understanding the instance Map should always be created, no?
This error persisted even upon restarting Civ 5, playing with mods and playing for more than 0 turns.
I have no extra mods in the DLC folder (like TakMod), so it's all "clean" in that sense.
Bonus info: I am trying to give a new Civ "Thule" a bonus of +1 food on snow and tundra. As a matter of practice I try to do this with LUA rather than XML (the prints are to see how far I can get without errors - it prints 2, but not 2.5):
Code:
print("1")
function ThuleSnowTundra(iHexX,iHexY,iPlayer,bunknown)
print("2")
local plotX, plotY = ToGridFromHex(iHexX, iHexY);
local pplot = Map.GetPlot(plotX, plotY)
plot("2.5")
if pplot:GetPlotType() == PlotTypes.PLOT_TUNDRA or pplot:GetPlotType() == PlotTypes.PLOT_SNOW then
print("3")
local pPlayer = Players[iPlayer]
if pPlayer:GetCivilizationType() == GameInfo.Civilizations.CIVILIZATION_THULE.ID then
Game.SetPlotExtraYield(x,y,YIELD_FOOD,1)
print("4")
else
Game.SetPlotExtraYield(x,y,YIELD_FOOD,-1)
print("5")
end
end
end
Events.SerialEventHexCultureChanged.Add(ThuleSnowTundra)
Thank you very much for your attention!
Cheers
Wobzter