How to open doors with LUA or Flowgraph?

Discussion in 'Programming' started by jamessimo, Oct 26, 2024.

  1. jamessimo

    jamessimo
    Expand Collapse

    Joined:
    Nov 28, 2018
    Messages:
    104
    I am looking to open a car door in my flowgraph project but no idea how to get the door and set it to open? I cant find any nodes for it and tried to use the vehicle editor to try and find out what LUA I could call to do it but closest thing I found was ``` ui.inputActions.moonhawk.doorLatch_L.title ``` but not sure how to set it to OPEN. Better yet. I would like the command that's used when a player clicks on the car door handle as that also adds some force to swing the door open.

    I can use the "Vehicle Custom Lua" node but need to know the commands.
     
  2. r3eckon

    r3eckon
    Expand Collapse

    Joined:
    Jun 15, 2013
    Messages:
    595
    This is a single line command to open all doors:
    Code:
    for k,v in pairs(controller.getControllersByType("advancedCouplerControl")) do if string.find(v.name, "door") then v.detachGroup() end end
    If you want to see what kind of couplers the car has use this in console:
    Code:
    for k,v in pairs(controller.getControllersByType("advancedCouplerControl")) do print(v.name) end
    upload_2024-10-26_10-52-50.png

    If you want to open only a specific door you can use this when you know the name:
    Code:
    controller.getController("doorFLCoupler").detachGroup()
    Keep in mind that some cars may use different names for couplers so it might not work for all cars, for example the Piccolina:

    upload_2024-10-26_10-57-22.png

    In this case you should use the first function and add string.find calls to look for multiple names, like this:
    Code:
    for k,v in pairs(controller.getControllersByType("advancedCouplerControl")) do if (string.find(v.name, "doorFL") or string.find(v.name, "doorL")) then v.detachGroup() end end
     
    • Like Like x 6
  3. jamessimo

    jamessimo
    Expand Collapse

    Joined:
    Nov 28, 2018
    Messages:
    104
    THANK YOU SO MUCH!

    I will test this now!
     
  4. jamessimo

    jamessimo
    Expand Collapse

    Joined:
    Nov 28, 2018
    Messages:
    104
    Just to update this WORKS! You can use the 'Custom Vehicle LUA node' in flowgraph to trigger this code.
     
    • Like Like x 1
  5. jamessimo

    jamessimo
    Expand Collapse

    Joined:
    Nov 28, 2018
    Messages:
    104
    just wanted to add, if you want to open then CLOSE a door, you can use;

    Code:
    controller.getController("Car_Hinge_Name").toggleGroup()
    This is like interacting with a door in walking mode.
     
  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