Community Forum

Help with setting the cutting area

Forum Overview >> Scripting

CategoryScripting
Created18.02.2014 11:11


Shawn Cowman (Unknown) 18.02.2014 11:14
Hello,

I was wondering if someone here would have a few minutes to look at some script I'm trying to write?

Basically I am trying to make a John Deere 2410 cultivator change the terrainDetail to unfertilized.

The code I have so far does change the terrainDetail but the cuttingArea is wrong. It is cutting a diaginol strip across the entire filed (map) and I can't figure out how to set it correctly.

Thanks for any help or guidance you can give.

Shawn

[code]
function JD_2410:update(dt)
if self:getIsActiveForInput() then
if InputBinding.hasEvent(InputBinding.LOWER_IMPLEMENT) then
self:setPoints(not self.isPointDown);
end;
end;
if self:getIsActive() then
if self.isClient then
if self.isPointDown then
for _,area in pairs(self.cuttingAreas) do
if self:getIsAreaActive(area) then
local detailId = g_currentMission.terrainDetailId;
local x, y, z = getWorldTranslation(area.start)
local x1, y1, z1 = getWorldTranslation(area.width)
local x2, y2, z2 = getWorldTranslation(area.height)
setDensityParallelogram(detailId, x, z, x1, z1, x2, z2, g_currentMission.sprayChannel, 1, 0);
end;
end;
end;
end;
end;
end;
[\code]

Here is the XML
[code]
<cuttingAreas count="3">
<cuttingArea1 startIndex="0>0|10" widthIndex="0>0|11" heightIndex="0>0|12" foldMinLimit="0" foldMaxLimit="1" />
<cuttingArea2 startIndex="2>0|8" widthIndex="2>0|9" heightIndex="2>0|10" foldMinLimit="0" foldMaxLimit="0.2" />
<cuttingArea3 startIndex="3>0|8" widthIndex="3>0|9" heightIndex="3>0|10" foldMinLimit="0" foldMaxLimit="0.2" />
</cuttingAraes>
[/code]

Lucy Green (Unknown) 22.02.2014 08:24
foldMaxLimit="0.2" />
</cuttingAraes>
[/code]

Manuel Leithner - GIANTS Software 26.02.2014 07:34
Hi,

setDensityParallelogram uses the real width and height of the parallelogram. actually you store the positions.

Try this:
...
local detailId = g_currentMission.terrainDetailId;
local x, y, z = getWorldTranslation(area.start)
local x1, y1, z1 = getWorldTranslation(area.width)
local x2, y2, z2 = getWorldTranslation(area.height)
local x,z, widthX,widthZ, heightX,heightZ = Utils.getXZWidthAndHeight(detailId, x, z, x1, z2, x1, z1);
setDensityParallelogram(detailId, x, z, widthX, widthZ, heightX, heightZ, g_currentMission.sprayChannel, 1, 0);





Jake Huff (The_0mega1) 24.10.2023 06:12
Can someone explain to me what the "widthIndex" is in the XML?


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