Help Lua.....

Padre19

Warlord
Joined
Oct 4, 2016
Messages
247
Location
Usa
Why this not work ?

function PadreResourceScarce(iPlayer)
local player = Players[iPlayer]
if(player:GetNumResourceAvailable(GameInfoTypes["RESOURCE_SLAVES"], true) >= 0) then return;
end
for unit in player:Units() do
if unit:GetUnitType() == GameInfoTypes.UNIT_SLAVE and
(player:GetNumResourceAvailable(GameInfoTypes["RESOURCE_SLAVES"], true) < 0) then
unit:WorkRate(50);
end
end
end
GameEvents.PlayerDoTurn.Add( PadreResourceScarce );
 
I'm not sure what your code is supposed to do (it's always good to include such information when looking for help :)), but I don't think the WorkRate function works as you think it does. It returns the current work rate of the unit, not changes it. Actually I don't think there is a function that allows you to set the work rate of a unit, so instead you should replace the unit with another unit type that has a different work rate.
 
Back
Top Bottom