Community Forum

moving a simple stand up and down

Forum Overview >> Scripting

CategoryScripting
Created04.07.2013 15:34


Jonathan Cronje (Unknown) 04.07.2013 15:43
Please help i'm lost what to move a trailer stand up when attached to a tractor. Try with the new fs2013 script but nothings happens

here is the FS2011 script

local standNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.stand#index"));
if standNode ~= nil then
self.stand = {};
self.stand.node = standNode;
local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.stand#minTrans"));
self.stand.minTrans = {};
self.stand.minTrans[1] = Utils.getNoNil(x, 0);
self.stand.minTrans[2] = Utils.getNoNil(y, 0);
self.stand.minTrans[3] = Utils.getNoNil(z, 0);

local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.stand#maxTrans"));
self.stand.maxTrans = {};
self.stand.maxTrans[1] = Utils.getNoNil(x, 0);
self.stand.maxTrans[2] = Utils.getNoNil(y, 0);
self.stand.maxTrans[3] = Utils.getNoNil(z, 0);

self.stand.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.stand#transTime"), 2)*1000;
self.stand.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.stand#touchTransLimit"), 10);
if self.attacherVehicle ~= nil then
-- Stand
self.standMax = true;
else
self.standMax = false;
end;

if self.standMax ~= nil then
local x, y, z = getTranslation(self.stand.node);
local trans = {x,y,z};
local newTrans = Utils.getMovedLimitedValues(trans, self.stand.maxTrans, self.stand.minTrans, 3, self.stand.transTime, dt, not self.standMax); setTranslation(self.stand.node, unpack(newTrans));
end;


Thk Liwile

Sven2157 (Unknown) 04.07.2013 18:51
You may want to start a bit more simple ...

Open the trailer's .i3d file, and find the 'attachpoint' transform node; by looking at the front of the trailer hitch. Try moving that first, then if it doesn't quite look right, let's jump into the scripts.

Hope that helps! ;-)

Sven2157

Jonathan Cronje (Unknown) 06.07.2013 06:34
Sven2157 Thk for the reply.

What I did so far. I've added a 'supportpoint' transform node on the trailer. And added this to the <modname>.xml file

<movingTools>
<!-- support -->
<movingTool index="0>3" componentJointIndex="0" anchorActor="0"/>
</movingTools>

<animations>
<!-- move support down/up -->
<animation name="moveSupport">
<part node="0>3" startTime="0" duration="0.2" startRot="90 0 90" endRot="90 90 90" />
<part node="0>3|0|0" startTime="0.2" duration="0.4" startTrans="0 0.34 0" endTrans="0 0 0" />
</animation>
</animations>

<support animationName="moveSupport" />

With the vehicle type set to trailer then its working 100% but when I change it to sprayer. The support is not lifting up.

What is the rightway to do it with playanimation in a Lua file

Thanks

Marcus H (Xentro) 06.07.2013 12:40
sprayer type do not have all specializations that are needed for what you need, change it to sprayer_animated instead and it will work.


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