Jump to content

Recommended Posts

Posted (edited)

I was reading through the code to make an update to the farming section of the wiki and realized that one of the functions to signify the progression of a given disease is nonfunctioning.

 

The file media/lua/client/Farming/ISUI/ISFarmingInfo.lua which handles hud elements related to Farming has the function ISFarmingInfo:getDiseaseColor() that due to a coding oversight doesn't fully work.

 

-- we show color of disease with 3 farming skill
function ISFarmingInfo:getDiseaseColor(diseaseLvl, index, info)
    ISFarmingInfo:getWhite(disease_rgb, index);
    if(CFarmingSystem.instance:getXp(self.character) >= 6 and (info.plant.state ~= "dry" or info.plant.state ~= "rotten" or info.plant.state ~= "destroyed")) then
        local disease = farming_vegetableconf.calcDisease(diseaseLvl);
        ISFarmingInfo:getGreen(disease_rgb, index);
        if(diseaseLvl > 0) then -- orange
            ISFarmingInfo:getOrange(disease_rgb, index);
        elseif(disease == -2) then -- red
            ISFarmingInfo:getRed(disease_rgb, index);
        end
    else
        ISFarmingInfo:getWhite(disease_rgb, index);
    end
end

 

The error is with the line: if(diseaseLvl > 0) 
For disease to be equal to -2 diseaseLvl already needs to be greater than 60, meaning that the code will never get to the next segment of the code. A simple fix would be doing something like this:
 

        if(diseaseLvl > 0 and disease ~= -2) then -- orange

 

I don't know if this is the right spot to put code errors, so please inform me if it is not the case.

Edited by ShyPie
Small typo

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...