I want to create a LUA Trigger that will "Break" or "Explode" a vehicle when it enters the LUA. I have made a Fire LUA, and I understand the Gravity LUA Trigger, and I understand how to Teleport, but I cant figure out the Script for a Break/Explode LUA triger? Can anyone help me...Thanks to all
Check the core_vehicle "package" in the lua folder. Probably there are a few functions to do similar things to what you want. Alternatively, you can do a comprehensive search for specifics words within files. On windows: Open powershell as admin; Navigate to the Lua folder inside the game folder Run the powershell code below, changing the "dummy" word to what you are looking for. Study the files (and functions) before calling them inside the game Code: Get-ChildItem -Recurse | Select-String "dummy" -List | Select Path I hope that helps!
Hi, in the trigger event code block insert the following: Code: vehObj = be:getObjectByID(data.subjectID) -- Get Vehicle Object vehObj:queueLuaCommand('beamstate.breakAllBreakgroups()') -- Break vehObj:queueLuaCommand('fire.explodeVehicle()') -- Explode that's all...
Hello BeamNG.drive community, I've been trying for quite some time to create a way to dynamically detach specific vehicle parts, such as a single wheel (e.g., wheel_FL), through a Lua trigger script in the World Editor. I tried different commands in my Lua trigger scripts. Error 1 in console: attempt to call global 'be' (a nil value) Error 2 in console: (R): Unknown command setDamage. (My understanding was that maybe these commands weren't being used in the right way or in the right context within the trigger script itself.) Current Lua Trigger Script I'm Testing: This is the latest script I'm trying in a World Editor trigger zone. I'm trying to use beamstate.breakGroup() to detach a specific wheel, similar to how the explosion command works. local function detachFrontLeftWheelTrigger(data) if data.event == 'enter' and data.subjectName and data.subjectName ~= '' and data.subjectName ~= 'scenario_player0' then local veh = be:getPlayerVehicle(0) if veh then local breakGroupName = "wheel_FL" local luaCommandToExecute = string.format( 'local success, err = pcall(function() beamstate.breakGroup("%s") end);' .. 'if success then ' .. ' -- print("Lua Script (Trigger): Success - Wheel \\"%s\\" detached!"); ' .. 'else ' .. ' -- print("Lua Script (Trigger): Error detaching wheel \\"%s\\": " .. tostring(err)); ' .. 'end;', breakGroupName, breakGroupName, breakGroupName ) veh:queueLuaCommand(luaCommandToExecute) end end end return detachFrontLeftWheelTrigger Problem with this script: When I use this, I get the following in the console: Lua (FL) Помилка: [string "string"]:1: attempt to call field 'breakGroup' (a nil value) (This seems to mean that beamstate.breakGroup is not found or cannot be called in this way, even though a general "break all breakgroups" function exists elsewhere in the game.) My Question to the Community: I can successfully make a car explode using veh:queueLuaCommand('fire.explodeVehicle()'). However, I cannot figure out how to specifically detach a single part like wheel_FL using a Lua trigger script. Given that a general "break all breakgroups" function seems to exist in the game's code: How can I correctly write a Lua trigger script to detach/break a specific breakGroup (like "wheel_FL")? Is there a different command or a specific way to call functions for individual parts? Any simple working code examples or advice would be greatly appreciated. Thank you for your time and help!