How to use densityMaskedParallelograms?

Your forum for all discussions around Modding.
timmiej93
Posts: 68
Joined: Thu Apr 07, 2011 10:19 pm

How to use densityMaskedParallelograms?

Post by timmiej93 »

I have been trying to use the densityMaskedParallelogram functions, with varying success.
All functions can be found here, for reference: https://gdn.giants-software.com/documen ... nction=289

At the moment, what I'm trying to do, is to increase the fertilization layer on the map, and also make the soil look darker (like fertilizing normally does in FS). I want to do this masked by a fruit, so that if I cultivate that fruit into the soil, the fertilization level increases and the soil turns darker (yes, I know there are probably easier ways of doing this, but I want to understand these functions, and they're needed in a more complicated situation). Increasing the fertilization layer works fine when I use the following code:

Code: Select all

    local detailId = g_currentMission.terrainDetailId
    local sprayLevelFirstChannel = g_currentMission.sprayLevelFirstChannel
    local sprayLevelNumChannels = g_currentMission.sprayLevelNumChannels
    local x,z, widthX,widthZ, heightX,heightZ = Utils.getXZWidthAndHeight(detailId, x,z, x1,z1, x2,z2)

    local fruitIdOil = g_currentMission.fruits[FruitUtil.FRUITTYPE_OILSEEDRADISH].id

    addDensityMaskedParallelogram(
        detailId,
        x,z, widthX,widthZ, heightX,heightZ,
        sprayLevelFirstChannel, sprayLevelNumChannels,
        fruitIdOil, 
        0, 1,
        1
    )
However, when I try to make the soil look darker with the code below, it simply doesn't work:

Code: Select all

    local detailId = g_currentMission.terrainDetailId
    local sprayLevelFirstChannel = g_currentMission.sprayLevelFirstChannel
    local sprayLevelNumChannels = g_currentMission.sprayLevelNumChannels
    local x,z, widthX,widthZ, heightX,heightZ = Utils.getXZWidthAndHeight(detailId, x,z, x1,z1, x2,z2)

    local fruitIdOil = g_currentMission.fruits[FruitUtil.FRUITTYPE_OILSEEDRADISH].id

    setDensityMaskedParallelogram(
        detailId,
        x,z, widthX,widthZ, heightX,heightZ,
        g_currentMission.sprayFirstChannel, g_currentMission.sprayNumChannels,
        fruitIdOil,
        0, g_currentMission.numFruitStateChannels,
        1
    )
Is there anything obviously wrong with the code above?

Now in a more general way, how should / can I use the "setDensityMaskParams" and "setDensityCompareParams"? I understand how they should be used (id, comparator, value), but I don't know what they do. If somebody could give me a general explanation of these function, and the density functions in general, that would be great
User avatar
deutz fahr austria
Posts: 81
Joined: Tue Aug 06, 2013 11:09 am

Re: How to use densityMaskedParallelograms?

Post by deutz fahr austria »

Have you tried looking at Chopped Straw?
If you cultivate the chopped straw it fertilises (ground turns dark)
timmiej93
Posts: 68
Joined: Thu Apr 07, 2011 10:19 pm

Re: How to use densityMaskedParallelograms?

Post by timmiej93 »

I have indeed, but somehow I can't accomplish the same effect. The only difference between what CS is doing and what I'm trying to do, is that they have a 'foliage id' instead of the fruit id I use. I don't know if that results in the darkening effect not happening for me, but it could very well be. I haven't got a clue how to get that foliage id for an existing fruit though, they seem to get it as a return value from the "g_currentMission:loadFoliageLayer" function.
Post Reply