Some help understanding CIV6 Lua

ChrisWJN

Chieftain
Joined
Mar 12, 2019
Messages
43
Location
Canada
Just started on LUA scripting. I am fairly experienced in programming in general and got the basics of how LUA works from LeeS' pdf guide, but I just am wondering a few things in general.
1. Is there a more updated or comprehensive list of the objects available to us? I've been using the doc by Chimp for SQL stuff so far, but the LUA part seems to be missing arguments/information.
2. Is there a way to access column information when iterating through a table? For example, if I wanted to grant the player yields for every luxury resource, is there a way to do that via a for loop that iterates through GameInfo.Resources, and picks out each one that has the ResourceClassType "RESOURCECLASS_LUXURY"?
Thanks.
 
1) See the section on Special Use Systems : GameInfo

2)
Code:
local tAlwaysConstructionItems = {}
local tListOfWorldWonders = {}
local tListOfNationalWonders = {}
local tListOfDistricts = {}
local tMustBePurchased = {}
for row in GameInfo.Districts() do
	if (row.DistrictType ~= "DISTRICT_CITY_CENTER") and (row.DistrictType ~= "DISTRICT_WONDER") then
		tAlwaysConstructionItems[row.DistrictType] = row.Index
		tListOfDistricts[row.DistrictType] = row.Index
	end
end
for row in GameInfo.Buildings() do
	if ((row.IsWonder == true) or (row.IsWonder == "true") or (row.IsWonder == "1") or (row.IsWonder == 1)) and (row.MaxWorldInstances == 1) then
		tAlwaysConstructionItems[row.BuildingType] = row.Index
		tListOfWorldWonders[row.BuildingType] = row.Index
	elseif (row.MaxPlayerInstances == 1) and (row.BuildingType ~= "BUILDING_PALACE") then
		tAlwaysConstructionItems[row.BuildingType] = row.Index
		tListOfNationalWonders[row.BuildingType] = row.Index
	end
	if (row.MustPurchase == true) then
		if (row.PurchaseYield == "YIELD_GOLD") or (row.PurchaseYield == "YIELD_FAITH") then
			tMustBePurchased[row.BuildingType] = row.Index
		end
	end
end
 
Top Bottom