Help Lua.....

Discussion in 'Civ5 - SDK / LUA' started by Padre19, Jan 28, 2017.

  1. Padre19

    Padre19 Warlord

    Joined:
    Oct 4, 2016
    Messages:
    215
    Gender:
    Male
    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 );
     
  2. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    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.
     

Share This Page