What parts can you damage using damageTracker.setDamage()?

Discussion in 'Programming' started by Jack The Fox, Jun 21, 2025.

  1. Jack The Fox

    Jack The Fox
    Expand Collapse

    Joined:
    Jan 22, 2025
    Messages:
    22
    Hi,
    I'm working on a mod that simulates vehicle damage using damageTracker.setDamage(category, type, true), and I’ve run into a roadblock.

    So far, "engine" with "radiatorLeak" works perfectly. But other combinations like "wheel_FR" with "tireDeflated" or "door_FL" with "broken" don’t seem to do anything.

    Does anyone have a list (or partial list) of supported categories and types? Or is there a way to inspect what parts support this kind of simulated damage? The things I want to do with damageTracker.setDamage() are: Engine lock, Tire deflation, Door damage, and Driveshaft break.

    Thanks for any help you can provide!
     
  2. r3eckon

    r3eckon
    Expand Collapse

    Joined:
    Jun 15, 2013
    Messages:
    600
    Using Agent Ransack, set the "look in" folder to the lua subfolder of the game install folder and look for damageTracker.setDamage, it'll show you all vanilla instances of the function being used. I highly recommend that software if you're gonna be doing a lot of lua modding in BeamNG.
    upload_2025-6-27_21-28-31.png

    Keep in mind that while this may works for some components (afaik damageTracker is more for the UI damage app, not to add actual damage to the car), for a lot of parts you need to do more than that to actually break them. If you only set the damage tracker state for the driveshaft, it'll show in the UI app as broken but it'll still be working. Powertrain devices have a specific function to break them. For example the driveshaft:
    Code:
    powertrain.breakDevice(powertrain.getDevice("driveshaft"))
    You can take a look at the list of powertrain device names for a vehicle with this
    Code:
    for k,v in pairs(powertrain.getDevices()) do print(k) end
    upload_2025-6-27_21-40-15.png
    If I use spindleRR with the previous breakDevice function the rear right wheel just cleanly falls off, and it also updates the damage tracker for you.
    upload_2025-6-27_21-41-28.png
    To deflate tires, for example the front left tire:
    Code:
    beamstate.deflateTire(wheels.wheelIDs["FL"])
    upload_2025-6-27_22-1-3.png
    You can also take a look at my code for loading this type of damage, it's probably not perfect but I got a bunch of stuff in there that might help you out.
     
  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