Lua Suggestions

Discussion in 'Ideas and Suggestions' started by Dummiesman, Feb 25, 2015.

  1. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,700
    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]
     
    #1 Dummiesman, Feb 25, 2015
    Last edited by a moderator: Feb 25, 2015
  2. Again_Dejavu

    Again_Dejavu
    Expand Collapse

    Joined:
    Dec 26, 2013
    Messages:
    717
    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.
     
  3. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,700
    I am. In fact, here's a leaked photo of me

    (imported from here)
     
  4. CarlosAir

    CarlosAir
    Expand Collapse

    Joined:
    Nov 16, 2013
    Messages:
    336
    What about using v.data.nodes and v.data.beams
     
  5. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,700
    ids on the compiled vehicle seem to be changed when removing parts
     
  6. Miura

    Miura
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    311
    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.
     
  7. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,700
    I believe the game removes duplicate beams. Not too sure about that though.

    Edit : DrowsySam says "noop" in reply to that :p. Like I said, I wasn't sure.
     
    #7 Dummiesman, Feb 25, 2015
    Last edited by a moderator: Feb 26, 2015
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice