Unsolved Adjust beamStrength

Discussion in 'Mod Support' started by bidwars, Sep 27, 2017.

  1. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    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]])
     
  2. meywue

    meywue
    Expand Collapse
    Administrator
    BeamNG Team

    Joined:
    Nov 19, 2015
    Messages:
    339
    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!
     
  3. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    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?
     
  4. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    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?
     
  5. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    Any update on this? I am able to use setBeam with -1 without errors but it does not do anything.
     
  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