Counting units is how I would implement that functionality. I counted settlers and engineers for SorFox earlier <a href="https://forums.civfanatics.com/threads/lua-scripting-possibilities.627220/page-6#post-15188320">Lua Scripting Possibilities</a> Try writing the code from scratch. Look at the code to understand how it works (I offer fairly detailed explanation on a slightly incorrect version of the code a few posts up), but don't just try to replace the "key bits." Practice thinking about the instructions you must give the computer to get it to do what you want. In fact, start first by writing a function that counts the number of 7s in a table.