Skip to content

editor_vehicleEditor_staticEditor_vePartTree

File: lua/ge/extensions/editor/vehicleEditor/staticEditor/vePartTree.lua · VM: Game Engine (GE) · 680 lines · BeamNG.drive 0.40.5 (buildbot 302427 on GitLab)

Access: extension editor_vehicleEditor_staticEditor_vePartTree: extensions.load("editor_vehicleEditor_staticEditor_vePartTree"), then the global editor_vehicleEditor_staticEditor_vePartTree

"Part Tree" window of the Static Editor. It reads the JBeam file of the selected part, parses it into an AST (json-ast, with the Lua data in ast.transient.luaData / luaDataRaw) and displays it as a tree (key, value, elements). For each table, you can select it (highlights the matching AST nodes in Part Text View), hide it, or send it to Part Properties. It also draws the part's nodes and beams in the static render view (debugDrawer) and lets you pick them with the mouse (Shift for multi-selection); nodes that are referenced but defined in other parts are looked up and drawn in transparent blue ("virtual"). A "Spawn" button re-instantiates the vehicle with the selected part as the main part.

Example

extensions.load('editor_vehicleEditor_staticEditor_vePartTree')
editor_vehicleEditor_staticEditor_vePartTree.open()

Notes

  • Writes into the shared vEditor state: ast, astFilename, selectedASTNodeMap, scrollToNode, selectedBeams, propertyTableEditTarget; reads vEditor.selectedPart, vehicle, vehData.ioCtx.
  • The internal fields __astNodeIdx, __selected, __hidden, __schemaProcessed, maxIDs and validTables are written into the data tables and hidden in the display.
  • Drawing radii: nodes 0.02 m (hover 0.04, selection 0.03, collision 0.035); beams 0.0025 m (hover 0.01, collision 0.01).
  • getNodefromAllParts iterates over all available parts, copying them and applying jbeam/tableSchema; nodes that cannot be found are remembered in brokenNodes so the warning is not repeated.
  • The "Spawn" button modifies playerVehicle.config.mainPartName, serializes the config into veh.partConfig and respawns the object (spawnObjectWithPosRot) at the initial position of the reference node.
  • The "Sync with AST" button exists but its body is empty in the code.
  • Bug: the context menu 'part_tree_ctx_menu' reads rightClickedPart, which is not defined in this file (nil global variable); this menu is never opened in this file and would raise an error if it were.
  • The file is re-read when the part's file name changes or when vEditor.ast is nil (for example after "Reload" in Part Text View).

Functions

Function Description Line
editor_vehicleEditor_staticEditor_vePartTree.onEditorGui() Editor hook called every frame: loads the AST of the selected part, draws the tree and calls the node and beam rendering/picking in the static view. No effect without a vehicle, vehData or selected part. (internal) (hook) 560
editor_vehicleEditor_staticEditor_vePartTree.onEditorInitialized() Editor hook called at initialization: registers the window (500x400, vehicleEditor tool). (internal) (hook) 662
editor_vehicleEditor_staticEditor_vePartTree.onFileChanged(filename, type) Extension hook called when a watched file changes on disk. If it is the currently loaded JBeam file, invalidates the AST (ast = nil, vEditor.ast = nil) so it is re-read on the next frame. (internal) (hook) 666
editor_vehicleEditor_staticEditor_vePartTree.open() Shows the "Part Tree" window (editor.showWindow). 658

Parameter details

editor_vehicleEditor_staticEditor_vePartTree.onFileChanged(filename, type)

Extension hook called when a watched file changes on disk. If it is the currently loaded JBeam file, invalidates the AST (ast = nil, vEditor.ast = nil) so it is re-read on the next frame.

  • filename (string) : path of the modified file
  • type (string) : change type (unused)

Fields

Field Type Description
menuEntry string Apps menu entry text: "Part Tree".

Calls into the engine (C++)

  • debugDrawer: drawCylinder, drawLine, drawSphere, drawTextAdvanced

tim19Atlas (Tim0219800) — derived from BeamNG GmbH Lua code (bCDDL 1.1, see LICENSE). Source: lua/ge/extensions/editor/vehicleEditor/staticEditor/vePartTree.lua.