Need help figuring out obj:attachCoupler

Discussion in 'Programming' started by Aerotactics, Mar 14, 2018.

  1. Aerotactics

    Aerotactics
    Expand Collapse

    Joined:
    Dec 23, 2015
    Messages:
    57
    So I found this callback in beamstate.lua, and need help deciphering it:

    Code:
    Original:
    obj:attachCoupler(val.cid, val.couplerTag or '', val.couplerStrength or 1000000, val.couplerRadius or 0.2, val.couplerTargets or 0)
    
    Mine:
    obj:attachCoupler('IntTruck', 'IntTrailer', 1000000, 0.2, 0)
    I'm pretty sure I have the wrong arguments, but it isn't crashing the game, so that's a plus.

    EDIT: The correct syntax would be:
    Code:
    obj:attachCoupler(val.couplerID (numerical), val.couplerTag (string), val.couplerStrength, val.couplerRadius, val.couplerTargets)
    So this would be a correct function:

    Code:
    obj:attachCoupler(243, '', 1000000, 0.2, 0)
    Thanks to @thomatoes50 for the clarification.
     
    #1 Aerotactics, Mar 14, 2018
    Last edited: Mar 15, 2018
  2. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    val.cid is an integer
    You can find the id by looping over nodes

    Code:
    for k,v in pairs(v.data.nodes) do
      if v.name == 'IntTruck' then
         --do
      end
    end
     
  3. Aerotactics

    Aerotactics
    Expand Collapse

    Joined:
    Dec 23, 2015
    Messages:
    57
    Ok, that answers my question, thanks.
     
  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