Another issue ...

Gokudo01

Emperor
Joined
Apr 12, 2014
Messages
1,044
Location
Toulouse(France)
I don't find the lua function to set player's science per turn value.

I've got setFaith(), setGold(), changeGold(), getScience() but I can't find setScience()


Code:
function AddOrbitalScience(playerID, unitID)
	
	local science = playerID:getScience();

	if isOrbital(unitID) then
	--Add Science to the player
		science = science + 3;
		playerID:setScience(science);
	end
end
 
player:GrantScience()

Note that this works differently from setGold() etc. - it doesn't override the base value, but instead adds to what the player already produces - so the number between the brackets has to be the amount of science you want to add, not the amount of science that you want the player to end up with.
 
player:GrantScience()

Note that this works differently from setGold() etc. - it doesn't override the base value, but instead adds to what the player already produces - so the number between the brackets has to be the amount of science you want to add, not the amount of science that you want the player to end up with.

ok so If i use playedID:GrantScience(3) and his science income was 67, after the function, it will be 70 or does it only work once ?

Because I want to change the income, not just grant an "one time" bonus.
 
Science Income is still 67, but the player will have gained 70 science that turn. As far as I know there's no actual way to influence the direct income.

However, if you fire the function every turn, then it will practically have the same effect.
 
Will it do the trick ?

Code:
--OrbitalToScience

function IsOrbital(unitID)

	if GameInfo.Units[unitID].Orbital == "NULL" then
		return false;
	end

	return true;
end

function CountOrbital(playerID)

	local somme = 0;

	for unit in playerID:Units() do

		local unitID = unit:getID();

		if isOrbital(unitID) then
			somme = somme + 1;
		end
	end
	return somme;

end

function AddOrbitalScience(playerID)
	
	local bonus = CountOrbital(playerID)*3;
	playerID:GrantScience(bonus);
end

function CanGetOrbitalScience(playerID)
	if(playerID:HasPolicy(GameInfo.Policies["POLICY_INDUSTRY_9"].ID))then
		AddOrbitalScience(playerID);
	end	
end
--Test fonctionnel

GameEvents.PlayerDoTurn.Add(CanGetOrbitalScience);

--I will add later the initialisation check

And how can I test my function and script ?
 
Top Bottom