TheOneHitPupper
Chieftain
- Joined
- Jun 15, 2017
- Messages
- 98
I'm trying to make a tech tree overhaul mod and have certain early-game resources that I want to disappear/change to another resource from the map. This is the code I have so far.
I have Iron set as the resource for testing purposes. It doesn't seem to execute at all. None of the print lines are making their way into the Lua.log and I'm at a loss. I'm sure there's multiple errors in my code as I struggle with Lua. Anyone have any ideas?
Code:
GameEvents.TeamSetHasTech.Add(function(iTeam, iTech, bAdopted)
local pTeam = Teams[iTeam]
local iPlayer = Game.GetActivePlayer()
local pPlayer = Players[iPlayer]
if iTech == GameInfoTypes.TECH_BIOLOGY then
print ("Obsolete");
pTeam(ChangeResource(pPlot))
end
end
function ChangeResource(pPlot)
if (pPlot:GetResourceType() == GameInfoTypes.RESOURCE_IRON) then --Get resource type
print ("ChangeResource: iron found");
local quantity = {}
quantity[1] = 1;
quantity[2] = 1;
quantity[3] = 1;
quantity[4] = 1;
quantity[5] = 2;
quantity[6] = 2;
quantity[7] = 2;
quantity[8] = 3;
print ("ChangeResource: quantity set");
local spawn = {}
spawn[1] = GameInfoTypes.RESOURCE_PEARLS;
spawn[2] = GameInfoTypes.RESOURCE_CRAB;
spawn[3] = GameInfoTypes.RESOURCE_FISH;
spawn[4] = GameInfoTypes.RESOURCE_WHALE;
spawn[5] = GameInfoTypes.RESOURCE_OIL;
print ("ChangeResource: resource set");
pPlot:SetResourceType(spawn[math.random(1,5)], quantity[math.random(1,8)]);
print ("ChangeResource: new resource spawned");
end
end
I have Iron set as the resource for testing purposes. It doesn't seem to execute at all. None of the print lines are making their way into the Lua.log and I'm at a loss. I'm sure there's multiple errors in my code as I struggle with Lua. Anyone have any ideas?