I am trying to adjust the strength of a beam from a lua script. I get an error on the line obj:setBeam() "bad argument #8 to 'setBeam' (number expected, got nil)" . What are the parameters that setBeam takes? Also could I just set the entire breakGroup to the math.huge beamStrength using setBeam? helper.queueLuaCommandByName(vName, [[for _,b in pairs(v.data.beams) do if b.breakGroup ~= nil then local breakGroups = type(b.breakGroup) == "table" and b.breakGroup or {b.breakGroup} for _, g in pairs(breakGroups) do if type(g) == 'string' and (string.find(g, "hinge") ~= nil or string.find(g, "latch") ~= nil) then b.beamStrength = math.huge obj:setBeam(-1, b.id1, b.id2, b.beamStrength, b.beamSpring, b.beamDamp, b.beamDeform, b.deformLimit, b.deformLimitExpansion, b.beamPrecompression) end end end end]])
Well... I can just assume for now tbh but at least I can help you out with the arguments a bit: Code: setBeam( int id, int nid1, int nid2, float strength, float spring, float damp, float deform, float precomp ); So I assume that if id is set to -1 that you create a new beam between given nodes. Otherwise you can set the parameters of the beam with the given id. But do not nail me down on that!
Well I found out part of the problem "bad argument #8 to 'setBeam' (number expected, got nil)" error is caused by having nil for the b.deformLimit so I just set that to math.huge. Also it looks like -1 as beam number appends it What does obj:breakBeam(bcid) code do on the c++ side? Does it set the beamStrength to zero?
Well it looks like the code still does not work in the scenario. I am trying to weld the hinges on the car but they still open. If I setBeam and use a 1 or 0 it causes the parts to blow up. Do you have a function to weld hinges?