Community Forum

How to use getDensity in LS09?

Forum Overview >> Farming Simulator 2009

CategoryFarming Simulator 2009
Created17.09.2009 21:54

Matthias B. (unknown) 17.09.2009 21:55

i have tested to use the Utils.getDensity, but it didnĀ“t works! So can you please tell me how it works? I also need some info to add a button and a checkbox for an ingamemenue?

Mfg. MxY.rlp

Matthias B. (unknown) 22.09.2009 14:45
no answer?


Stefan Geiger - GIANTS Software 23.09.2009 20:30
The prototype looks like this:
float Utils.getDensity(id, channel, startWorldX, startWorldZ, widthWorldX, widthWorldZ, heightWorldX, heightWorldZ)

The id is the entity id of the terrain detail object. You can get it like this:
local id = g_currentMission.fruits[fruitId].id

Check out the documentation on ls-mods to get some info about the start/width/height parameters:

You can create a new checkbox with:
OverlayCheckbox:new(Overlay onOverlay, Overlay offOverlay, bool isChecked, func callbackFunctionWhenClicked, object callbackTarget);

and a button with:
OverlayButton:new(Overlay buttonOverlay, func callbackFunctionWhenClicked, object callbackTarget);

onOverlay, offOverlay, buttonOverlay are overlays which describe how the button/checkbox look like. You can create it with:
local onOverlay = Overlay:new(name, imagefilename, posX, posY, sizeX sizeY)

The callbackFunctionWhenClicked looks like this for the checkbox:
function className:callbackFunctionWhenClicked(isChecked)


The function for the button is the same without the isChecked parameter.

Matthias B. (unknown) 23.09.2009 20:32
thank you, i will try it!

Heady Planet-ls (Headshot XXL) 26.09.2009 13:33
I have a similar question. How works the function "setDensityMaskedParallelogram"?

Pierre S (unknown) 28.09.2009 20:32
When you spray or seed or cut, you make a new texture over last texture !!


if you cut the maize, setDensityMaskedParallelogram replace texture with cuttedmaize in your file "fruit_density.grle" !!

setDensityMaskedParallelogram(cuttedMaizeID, x, z, widthDiffX, widthDiffZ, heightDiffX, heightDiffZ, 0, MaizeId, Chanel, 1.0)

it's the same things for texture cultivator !!

Stefan Geiger - GIANTS Software 29.09.2009 09:20
The difference between setDensityMaskedParallelogram and setDensityParallelogram is, that setDensityMaskedParallelogram only changes the value of the first id where the given maskId has some value != 0 in the channels firstMaskChannel to numMaskChannels.

Note that the sample code of Pierre S is missing the numChannels and numMaskChannels values. These are new in LS09. I think that this is some code from LS08.

The prototype looks like this:
setDensityMaskedParallelogram(id, x, z, widthX, widthZ, heightX, heightZ, firstChannel, numChannels, maskId, firstMaskChannel, numMaskChannels, value);

Pierre S (unknown) 29.09.2009 15:15
oh ok i understand the difference !! sorry for missing. yes its a code for ls08 !! i do not think this fonction change with ls09 ;)

thx for your answer.

Heady Planet-ls (Headshot XXL) 29.09.2009 16:49
Stefan, can you make a example to create e.g. grass_cut_long?

I dont know wich values for: 'id', 'firstChannel', 'numChannels', 'maskId', 'firstMaskChannel', 'numMaskChannels', 'value'

Note: Log in to post. Create a new account here.