Community Forum

Creating new componentJoint

Forum Overview >> Farming Simulator 15

CategoryFarming Simulator 15
Created06.04.2015 19:43

Adam Plachta (unknown) 06.04.2015 19:48
I want to write script that remowe old componentJoint and create new, with changed values.
I wrote this code:
if self.isServer then

local constr = JointConstructor:new();

local jointDesc = {};
jointDesc.jointNode = self.extraJointNode;

constr:setActors(self.components[1].node, self.components[2].node);
constr:setJointTransforms(jointNode, jointNode);
for i=1, 3 do
constr:setRotationLimit(i-1, 0, self.componentJoints[1].rotLimit);
self.extraJointNode.jointIndex = constr:finalize(); -- this is line 55
in function update, and this line:
self.extraJointNode = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.extraJoint#index"));

in function load.

When I try that in game, in log shows:
Error: Running LUA method 'update'.
.../.lua:55: attempt to index field 'extraJointNode' (a number value)

I know, that my english isn't excellent, but I hope that you understand me ;)

Emil Drefers (giants.edrefers) 07.04.2015 09:01

seems like you should start with something simpler to learn lua ;)

This line:
self.extraJointNode = Utils.indexToObject(......

assigns the variable a number.

But later on you try to use it as a table:
self.extraJointNode.jointIndex = ...

That can't work.

By the way ... why do you want to edit a componentJoint?
You can set a lot of (all!) properties in the xml file for a componentJoint, so it does not make sense to destruct it and recreate it.


Adam Plachta (unknown) 08.04.2015 15:22
Stupid mistake :P
I 've found another solution to that.
Thanks for help.

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