It is difficult to determine (in lua) what level infinite researches are, particularly if they switch between regular (-1, -2 etc) to the infinite (-5 to -10).
Example: "worker-robots-speed-6".
When it's researched (you have level 6 worker robot speed), .level returns 7 and .researched returns false.
What this means is there's an extra +1 in the math somewhere, and to fix it you need to -1.
Example of how to do this:
Code: Select all
if(tonumber(tech.name:sub(-1,-1))==tech.level-1)then if(tech.researched)then is_full_researched=true research_level=tech.level else is_partially_researched=true research_level=tech.level-1 end end
A LuaTechnology.is_partially_researched would make this a lot easier and a lot less confusing (particularly when dealing with migrations that change technologies like this)
Adding also LuaTechnology.researched_level that automatically gives you the "Real" research level would also be appreciated.
An alternate to this would be to give LuaForce a .get_technology_level() that lets you use "worker-robots-speed" and it adds the -1, -2 etc internally for its checks (however it would do them).