That function never seemed to work right for me. I always end up going through the Teams and TeamTechs functions instead, since they seem much more stable.
Also, you should note that most of those sorts of Lua checks need ID numbers, and NOT the "TECH_XXX" name. It's easy enough to convert through the GameInfoTypes functions (for techs you know the name of) and/or GameInfo.Technologies (for trying to match an arbitrary string), but it's something you have to account for. A similar problem comes up with functions like InitUnit; while it wants the unit's type, it only works with an integer ID and not a text string.
I'm very sorry but I just don't get it. Just spent the entire morning trying to get the tech requirements to work and all I got was frustrations...
Looked through your mod for examples of how Teams and TeamTechs functions work but as the structure thre is so different from this I really have no idea of where to begin and where to end.
Then I tried messing about with
I also spent a lot of time trying to figure out how Gameinfo and GameInfoTypes work.
The original condition function went like this
Spoiler :
Code:
function NewIronCond( player, city, unit, plot )
return city and not plot:IsCity() and plot:GetResourceType() == -1 and _PlayerHasTech( player, "TECH_IRON_WORKING") and not plot:IsFlatlands() and plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_MINE" ].ID;
end
[/SPOILER]
As I understood your last post nr.1 priority was using the Teams and TeamTechs functions but if I did use _PlayerHasTech I had to mess around with the GameInfoTypes functions and/or GameInfo.Technologies. Unfortunately I haven't been able to understand exactly what they do so I had to try and learn from examples from mods/threads and trial and error.
I tried changing the code to:
Spoiler :
Code:
function NewIronCond( player, city, unit, plot )
local thisTech = GameInfo.Technologies[0].ID;
return plot and not plot:IsCity() and _PlayerHasTech( player, thisTech ) and plot:GetResourceType() == -1 and plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_MINE" ].ID;
end
[/SPOILER]
Thereby trying to make Agriculture the requirement for the function (as Agriculture has ID 0..?) and it seemed to work.
In the firetuner I could see the ID for alle the techs I needed, e.g. Iron Working had ID 17, so I changed all the the condition functions to something similar to the one below
Spoiler :
Code:
function NewIronCond( player, city, unit, plot )
local thisTech = GameInfo.Technologies[0].ID;
return plot and not plot:IsCity() and _PlayerHasTech( player, thisTech ) and plot:GetResourceType() == -1 and plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_MINE" ].ID;
end
[/SPOILER]
and now it doesn't work...
I'm really puzzled here. Is there any chance you could give an example of how you'd do the tech prereqs in a function like toe one above? Either change the line given above and paste it here or look at the mod in its current state (attached to post)
\Skodkim