Moaf
Warlord
have you tried using instead of
Map:GetPlot(x, y);
using this
Map.GetPlot(x, y);
Map:GetPlot(x, y);
using this
Map.GetPlot(x, y);
Map:GetPlot() is required, as opposed to using a period. Best I can tell is the difference is that the : means GetPlot() is given the map as an argument, which ought to be a given but I guess that's just how the function is written.
Upon using the firetuner test I ran into this problem though, in using "testplot = Map:GetPlot(5,5)", "testplot:GetX()" returns 0, while "testplot:GetY()" returns 5. So GetY works, but GetX doesn't, which confuses the heck out of me and is preventing my code from working properly. Now, unitinstance:GetPlot:GetX() works, so it seems to be the problem is with Map:GetPot(x, y)
testplot = Map.GetPlot(5,5) -- Always use period with Map
x = testplot:GetX()
y = testplot:GetY()
local numDirections = DirectionTypes.NUM_DIRECTION_TYPES;
for direction = 0, numDirections - 1, 1 do
local adjacentPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), direction);
I thought this snippet might be useful to you, from the Inca scenario:
Map.PlotDirection(x,y,direction) seems to be the best way to do iteration of adjacent tiles... this could be wrapped in a utility function quite easily, producing a new iterator function for adjacent plots.Code:local numDirections = DirectionTypes.NUM_DIRECTION_TYPES; for direction = 0, numDirections - 1, 1 do local adjacentPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), direction);
Given how Lua interfaces with C(++), I'm guessing oddities come from however the implementation translates the lua parameters (which can, obviously, be of any type) into the C types expected. It might be that the names of parameters didn't get updated when the use of them did, I guess. Interestingly, if it were pure Lua, the 0 parameters wouldn't be treated as boolean - I'm guessing that the C part converts it to the most direct C equivalent (so an integer) and then evaluates that for truth C-style.This game continues to confound me! Changing the "if not a == b" to "if a ~= b" produces different results, it seems.
I also found out that apparently ChangeExperience isn't what I want, as that returns a boolean for some reason or another. ChangeExperience() works, but unlike what the wiki says, most of the arguments are not boolean. If I do ChangeExperience(1, -1, 1, 1, 1), the unit gets 1 experience, but the great general counter is incremented by 2! Replacing any of the last 3 numbers with a 0 results in no advancement in great general experience.
So, need to figure out how to resolve this so great general exp is incremented properly. I also need to figure out how to fetch the max_barbarian_exp number just to polish everything off.