Hey developers/fellow forum users, here is a list of suggestions that I've come up with that would assist the creation of custom Lua for vehicle content. obj:getBeam(node1,node2) This function would retrieve a beam reference from the compiled vehicle. It would return the reference to a beam from node1 to node2 or vice versa. Usage example: [xcode=lua] local beamRef = obj:getBeam("fb1","fb2") obj:setBeamSpringDamp(beamRef.cid,beamRef.beamSpring,-1,beamRef.beamDamp,-1) [/xcode] obj:getNode(nodeName) This function would retrieve a node reference by name from the compiled vehicle. Usage example: [xcode=lua] local nodeRef1 = obj:getNode("fb1") local nodeRef2 = obj:getNode("fb2") obj:addForce(nodeRef1.cid,NodeRef2.cid,1000) [/xcode] obj:setBeamDeformBreak(beamID,newDeform,newBreak) This function would allow the setting of deform/break values after the vehicle has been loaded Usage example: [xcode=lua] local beamRef = obj:getBeam("fb1","fb2") obj:setBeamDeformBreak(beamRef.cid,1000,2000) [/xcode] obj:setNodeMaterial(nodeID,material) This function would allow the coder to change the material after vehicle compilation Usage example: [xcode=lua] local nodeRef = obj:getNode("fb1") obj:setNodeMaterial(nodeRef,"|NM_METAL") [/xcode] obj:getNodePosition(nodeID) This function would allow someone to get a nodes position from the physics system in real time Usage example: [xcode=lua] local nodeRef = obj:getNode("fb1") local nodePosition = obj:getNodePosition(nodeRef.cid) print("node position is {x:" .. nodePosition.x .. ", y:" .. nodePosition.y .. ", z:" .. nodePosition.z .. "}")[/xcode]
I'll admit I'm not an expert with this kind of stuff, but I dedinately see the utility in these features. Also, I can be certain Dummie knows what he's talking about, dude's a wizard.
The first one would have a problem when there is more than one beam between the two nodes. You can do something similar with named beams, for example: [xcode=lua] jbeam: "beams": ["rad2","e3r", {"name":"radiatorDamage1"}], lua: for s,b in pairs(v.data.beams) do if b.name == "radiatorDamage1" then radiatorDamageBeam1 = b.cid end end [/xcode] Same thing with node names: [xcode=lua] for s,n in pairs(v.data.nodes) do if n.name == "fu1l" then fuelNode1 = n.cid elseif n.name == "fu1r" then fuelNode2 = n.cid end end [/xcode] Then you can use the beam or node name instead of ID. Otherwise useful suggestions, especially the last one about node positions. If that worked, maybe someone could make an app for suspension geometry, like camber, toe, etc.
I believe the game removes duplicate beams. Not too sure about that though. Edit : DrowsySam says "noop" in reply to that . Like I said, I wasn't sure.