Some Lua questions and E&D troubleshooting

OTiger

Warlord
Joined
Aug 26, 2012
Messages
178
I got a bunch questions here that I hope that can be answered:

1.) It is possible to have a this for a Unique Ability:

"Cities that has more than 2 trading units that are trading to another city that's not yours generates Great Merchants 25% faster."

2.) Is it possible to have a worker unit to get Gold after they improve a Luxury Resource? I know that Tomatekh's Harappa Civ does that, but I'm having a tough time splitting up the code, since the UU there also can trade Luxury Resources.

3.) I've been putting E&D support to one of my mods, and I kinda got it to working, expect that the second decision isn't showing up. Here's the code:

Code:
--------------------------------------------------------------------------------------------------------------------------
-- Expand the Krusty Krab Talent Show
--------------------------------------------------------------------------------------------------------------------------
local Decisions_KrustyKrabTalentShow = {}
	Decisions_KrustyKrabTalentShow.Name = "TXT_KEY_DECISIONS_KRUSTYKRABTALENTSHOW"
	Decisions_KrustyKrabTalentShow.Desc = "TXT_KEY_DECISIONS_KRUSTYKRABTALENTSHOW_DESC"
	HookDecisionCivilizationIcon(Decisions_KrustyKrabTalentShow, "CIVILIZATION_KRUSTY_KRAB")
	Decisions_KrustyKrabTalentShow.CanFunc = (
	function(pPlayer)
		if pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_KRUSTY_KRAB then return false, false end
		if load(pPlayer, "Decisions_KrustyKrabTalentShow") == true then
			Decisions_KrustyKrabTalentShow.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_KRUSTYKRABTALENTSHOW_ENACTED_DESC")
			return false, false, true
		end
		
		local iCost = math.ceil(500 * iMod)
		Decisions_KrustyKrabTalentShow.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_KRUSTYKRABTALENTSHOW_DESC", iCost)	
		if (pPlayer:GetNumResourceAvailable(iMagistrate, false) < 2) then return true, false end
		if (Teams[pPlayer:GetTeam()]:IsHasTech(GameInfoTypes.TECH_ACOUSTICS)) and (pPlayer:GetGold() >= iCost) then
			return true, true
		else
			return true, false
		end
	end
	)

	Decisions_KrustyKrabTalentShow.DoFunc = (
	function(pPlayer)
		local iCost = math.ceil(500 * iMod)
		pPlayer:ChangeGold(-iCost)
		pPlayer:ChangeNumResourceTotal(iMagistrate, -2)
		pPlayer:SetNumFreePolicies(1)
		pPlayer:SetNumFreePolicies(0)
		pPlayer:SetHasPolicy(GameInfoTypes.POLICY_DECISIONS_KRUSTYKRABTALENTSHOW, true)
		save(pPlayer, "Decisions_KrustyKrabTalentShow", true)
	end
	)

	Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_KRUSTY_KRAB, "Decisions_KrustyKrabTalentShow", Decisions_KrustyKrabTalentShow)

	--------------------------------------------------------------------------------------------------------------------------
-- Turn the Krusty Krab into a Hotel
--------------------------------------------------------------------------------------------------------------------------
local eraModernlID	 = GameInfoTypes["ERA_MODERN"]
local policyKrustyTowers = GameInfoTypes["POLICY_DECISIONS_KRUSTYKRABKRUSTYTOWERS"]
local Decisions_KrustyKrabKrustyTowers = {}
	Decisions_KrustyKrabKrustyTowers.Name = "TXT_KEY_DECISIONS_KRUSTYKRABKRUSTYTOWERS"
	Decisions_KrustyKrabKrustyTowers.Desc = "TXT_KEY_DECISIONS_KRUSTYKRABKRUSTYTOWERS_DESC"
	HookDecisionCivilizationIcon(Decisions_KrustyKrabKrustyTowers, "CIVILIZATION_KRUSTY_KRAB")
	Decisions_KrustyKrabKrustyTowers.CanFunc = (
	function(pPlayer)
		if pPlayer:GetCivilizationType() ~= civilizationID then return false, false end
		if load(player, "Decisions_KrustyKrabKrustyTowers") == true then
			Decisions_KrustyKrabKrustyTowers.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_KRUSTYKRABKRUSTYTOWERS_ENACTED_DESC")
			return false, false, true
		end

		local playerID = player:GetID()
		local goldCost = mathCeil(650*iMod)
		Decisions_KrustyKrabKrustyTowers.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_KRUSTYKRABKRUSTYTOWERS_DESC", goldCost)
		if pPlayer:GetCurrentEra() < eraModernlID then return true, false end
		if pPlayer:GetNumResourceAvailable(iMagistrate, false) < 2 then return true, false end
		if pPlayer:GetGold() < goldCost then return true, false end
		return true, true
	end
	)
	
	Decisions_KrustyKrabKrustyTowers.DoFunc = (
	function(pplayer)
		local goldCost = math.ceil(650*iMod)
		pPlayer:ChangeNumResourceTotal(iMagistrate, -2)
		pPlayer:ChangeGold(-goldCost)
		pPlayer:SetNumFreePolicies(1)
		pPlayer:SetNumFreePolicies(0)
		pPlayer:SetHasPolicy(policyKrustyTowers, true)
		save(pPlayer, "Decisions_KrustyKrabKrustyTowers", true)
	end
	)

		Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_KRUSTY_KRAB, "Decisions_KrustyKrabKrustyTowers", Decisions_KrustyKrabKrustyTowers)

Here's the SQL file too:

Code:
--==========================================================================================================================
-- Policies
--==========================================================================================================================
INSERT INTO Policies 
			(Type, 											Description) 
VALUES		('POLICY_DECISIONS_KRUSTYKRABTALENTSHOW',	 	'TXT_KEY_DECISIONS_KRUSTYKRABTALENTSHOW'),
			('POLICY_DECISIONS_KRUSTYKRABKRUSTYTOWERS',		'TXT_KEY_DECISIONS_KRUSTYKRABKRUSTYTOWERS');

--==========================================================================================================================
-- Policy_BuildingClassYieldModifiers
--==========================================================================================================================
INSERT INTO Policy_BuildingClassYieldModifiers 
			(PolicyType, 									BuildingClassType,					YieldType, 				YieldMod)
VALUES 		('POLICY_DECISIONS_KRUSTYKRABTALENTSHOW', 		'BUILDING_OPERA_HOUSE',				'YIELD_GOLD',			20);
--==========================================================================================================================
-- Policy_BuildingClassTourismModifiers
--==========================================================================================================================
INSERT INTO Policy_BuildingClassTourismModifiers
		(PolicyType, 										BuildingClassType,			TourismModifier)
VALUES	('POLICY_DECISIONS_KRUSTYKRABKRUSTYTOWERS', 		'BUILDING_KRUSTY_KRAB',		10);

Also, i'm not sure that the POLICY_DECISIONS_KRUSTYKRABTALENTSHOW is working- There's doesn't seem to be increase of Gold when it's active.

4.) And finally, is it possible to have a decision where there's a temporary boost in Production for a few turns (Maybe around 20 to 30)?

That's alotta questions to answer, so take your time.
 
Back
Top Bottom