Need more Events

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)
 
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)

If you look at the Firaxis Lua files, for some reason they always use the period operator when working with Map methods. I don't know exactly why since other single-instance objects like Game seem to work fine with either periods or colons. But given the problems you've seen with using "Map:" I'd say you want to follow their example and thus use code like the following:

Code:
testplot = Map.GetPlot(5,5) -- Always use period with Map
x = testplot:GetX()
y = testplot:GetY()

FWIW, I have taken to always going with the period on any single-instance object (Map, Game, PreGame, etc.) and haven't noticed any major problems.
 
I thought this snippet might be useful to you, from the Inca scenario:
Code:
local numDirections = DirectionTypes.NUM_DIRECTION_TYPES;
			for direction = 0, numDirections - 1, 1 do

				local adjacentPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), direction);
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.
 
I thought this snippet might be useful to you, from the Inca scenario:
Code:
local numDirections = DirectionTypes.NUM_DIRECTION_TYPES;
			for direction = 0, numDirections - 1, 1 do

				local adjacentPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), direction);
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.

This looks to be perfect for what I need! Using my existing snippet of code it's supposed to iterate over the 8 surrounding tiles (with a check to skip the 2 non-adjacent ones), but for some reason the code within that loop only gets called once.

Thanks a bunch.
 
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 GiveExperience 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.
 
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.
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.

The return value we just don't know the meaning for, but there are various cases I've seen in scenario code of a 'true' return value meaning 'yes, I did something'.
 
Actually, thinking about it, it seems likely that the boolean listed in the docs is from C/++ code, and might actually be typedefed to an integer type...
 
Back
Top Bottom