1.How to use command?
These commands can be used in “System Console”.
You can open it by pressing ^ key when you play BeamNG.drive in freeroam mode.
If not working, let see [Option -> CONTROLS] and look for “console”.
“System Console” has two type of console, one for whole game and the other for each vehicle.
- “GE – Lua”: a console for whole game
- “BeamNG – XX”: a console for each vehicle
“GE – Lua” VS “BeamNG – XX”
If you want to execute command for all vehicles, use “GE – Lua” console, and execute command like this:
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("WHAT YOU WANT TO EXECUTE") end
For example, if you want to explode all vehicles, you can execute like this:
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("fire.explodeVehicle()") end
If you want to execute command for each vehicle, it is easier.
Select console for target vehicle, and execute just what you want to do.
For example, if you want to explode a vechivle, only you have to do is executing this command.
fire.explodeVehicle()
From here, I show you funny and convenience command examples.
These are mainly for all vehicles, so if you want to execute for each, please replace like above.
2.Funny Commands
Breaking All Hinges
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("beamstate.breakHinges()") end
Breaking Completely
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("beamstate.breakAllBreakgroups()") end
Deflate All Tires
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("beamstate.deflateTires()") end
Ignite All Vehicle
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("fire.igniteVehicle()") end
Explode All Vehicle
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("fire.explodeVehicle()") end
Extinguish All Vehicle
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("fire.extinguishVehicle()") end
3.Convenience Commands
Command for electrics( for ALL VECHICLE )
Toggle Left Signal
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.toggle_left_signal()") end
Toggle Right Signal
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.toggle_right_signal()") end
Toggle Warn Signal
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.toggle_warn_signal()") end
Turn ON a Light
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.setLightsState(1)") end
Turn ON a High Beam
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.setLightsState(2)") end
Turn OFF a Light
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.setLightsState(0)") end
Turn ON a Lightbar Signal
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.set_lightbar_signal(1)") end
If a vehicle has no lightbar, this command affects nothing.
Turn ON a Lightbar Signal and Sound a Siren
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.set_lightbar_signal(2)") end
If a vehicle has no lightbar, this command affects nothing.
Turn OFF a Lightbar and Siren
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("electrics.set_lightbar_signal(0)") end
If a vehicle has no lightbar, this command affects nothing.
Command for AI
Set AI path for all vehicles
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("ai.driveUsingPath{wpTargetList={'xx', 'yy'}, noOfLaps = 1, aggression = 1.0}")) end
Set AI mode for each vehicle
ai.setMode('<mode>')
mode: ‘flee’, ‘chase’, ‘follow’, ‘traffic’, ‘random’
Stop AI for each vehicle
ai.setMode('disabled')
Other
Reset All Vehicles (fix collapsed skin)
for vid, veh in activeVehiclesIterator() do veh:requestReset() veh:resetBrokenFlexMesh() end
4.Command for debug(draft)
TIPS for debugging table type.
# table of contents
for k, v in pairs(table01) do print(k) print(v) end
# table length
table.maxn(table01)
Vehicles information
# Player Vehicle
tbl1 = core_vehicle_manager.getPlayerVehicleData()
# Other Vehicle
tbl1 = core_vehicle_manager.getVehicleData(vid)
# list of traffic vid
tbl1 = extensions.gameplay_traffic.getTrafficList()
# Vehicle basic infomation
tbl1 = core_vehicles.getVehicleList()
# for example: get vehicle value
for k, v in pairs(tbl1['vehicles'][42]['model']['aggregates']['Value']) do print(k) print(v) end
# damage information
for vid, veh in activeVehiclesIterator() do veh:queueLuaCommand("damage_table = beamstate.getPartDamageData(); dump(damage_table)") end
# pursuit data
extensions.gameplay_traffic.getPursuitData()
Reference
- BeamNG.drive Lua AP
C:\Program Files (x86)\Steam\steamapps\common\BeamNG.drive\lua
- Other
c – How to inspect userdata in lua – Stack Overflow
https://noriok.hatenablog.com/entry/2012/03/27/002111
https://staff.aist.go.jp/yutaka.ueno/lua/tebiki3jp.html
コメント