[Solved!] Knowing if door is open or window broken.

Discussion in 'Programming' started by TheStatPow, Nov 2, 2015.

  1. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    How would i go about knowing if a door window as broken or if a door is open? I could check if node is broken, but the nodesID are different for each car :\
     
  2. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    The game has no knowledge of whether a node is part of a door or not. The nodes and beams come together in a completely arbitrary way that we interpret as being a vehicle.

    So really, you cant.
     
  3. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    A damn :(

    Also, running Cefdev doesn't do anything anymore. no reload UI button.
     
  4. Michaelflat

    Michaelflat
    Expand Collapse

    Joined:
    Jul 10, 2014
    Messages:
    1,543
    this wouldn't be very useful, until it actually becomes a proper game and you can open and close doors, a door that is smashed open would probably not have the sensor working anyway
     
  5. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    I actually want it so when the door is open or the windows break the music in the car play louder.

    But guess ill scratch that.
     
  6. gabester

    gabester
    Expand Collapse
    Vehicle Director
    BeamNG Team

    Joined:
    Jun 6, 2012
    Messages:
    2,653
    You could check the state of the breakGroups. Every car has a "vehiclename_doorlatch_FR/FL" breakgroup, as well as a "vehiclename_doorglass_FR/FL" breakgroup for the glass.
     
  7. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Thanks
     
  8. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145

    Hey i found the break group, but how do i get the state?

    Code:
    for k, b in pairs(v.data.beams) do
            if b.breakGroup ~= nil and b.breakGroup ~= "" then
                print(b.breakGroup`.hatch_doorglass_L)
            end
        end

    It all prints out NIL, so i must be doing the wrong thing
     
    #8 TheStatPow, Nov 4, 2015
    Last edited by a moderator: Nov 4, 2015
  9. gabester

    gabester
    Expand Collapse
    Vehicle Director
    BeamNG Team

    Joined:
    Jun 6, 2012
    Messages:
    2,653
    This might help? From beamstate.lua

    Code:
    -- breakgroup handling
            if beam.breakGroup and beam.breakGroup ~= "" then
                -- find all beams with that breakgroup
                if beam.breakGroupType == 0 or beam.breakGroupType == nil then
                    -- break all beams in that group
                    for k, b in pairs(v.data.beams) do
                        if b.breakGroup == beam.breakGroup then
                            --log('D', "beamstate.beamBroken","  breakgroups: also breaking beam "..k.. " as in breakgroup ".. b.breakGroup)
                            obj:breakBeam(k)
                            luaBreakBeam(k)
                        end
                    end
     
  10. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    All that does is find the beam and break, which can't rally tell me if its broken, but yes i already went over that code and the most i can get out of it the screen below, its all the values for was seems to be the hatch window beams. Even have access to the CollTris but it only tells me the number of the colltris.

    nothing else in that seems to tell me any clue on if the glass broke.


    Im balls deep 6 for and if loops to get there, and i fear i just hit the bottom.

    theres a few tables in there, ill check them all and see if they tell me something.


    Good thing is that made me discover how to get nodes id out of vehicle part names so i can dynamicly control where the sound from the radio comes from, which the best is the front bumper so it feels as if its inside the car when you turn your head.
     

    Attached Files:

    • SAM.png
  11. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    No luck, im giving up for now, sorry to make you lose your time and thanks for the help!
     
  12. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    Just came across this thread now. This should be what you're looking for. :)
    Code:
    obj:beamIsBroken(beam.cid)
     
    • Like Like x 1
  13. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Im so dumb holycrap, the function's name speaks for itself.

    Thanks dummies, you're the man of the hour :D
     
  14. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    I was about to code a complex function that would check the G meters and try to predict if the door is broken by that.
    You just saved me a lot of work.
     
  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