Lua Exporter Code

From Automation Game Wiki
Revision as of 14:56, 3 November 2021 by Caswal (talk | contribs)

Overview

The Exporter dll passes to Automation any number of Lua files to be loaded into a self contained Lua environment. There must be a global DoExport function, with CarCalculator and CarFile as an arguments. DoExport returns 2 tables (effectively a Lua Dictionary) of Files and Data.

Here is a good resource for quickly covering how Lua works: https://learnxinyminutes.com/docs/lua/

Arguments

  • CarCalculator is the massively overweight 'class' that contains all simulation data about the currently exported car, but no mesh data. That is all in C++.
  • CarFile is the contents of a normal Automation .car file. This should be copied into the returned Files list. So the original car can be easily bought back into Automation and edited. In the example file you can see it being copied into the Files list by a file name generated from the Car's Model and Trim Name

Results

  • The files table has the filename as the key, and the file contents as the value.
    • In the BeamNG.drive exporter, this is the camso_engine.jbeam file containing all the engine and drivetrain performance .
  • The Data table has the data name as a key, and the data (either string or number) as the value.
    • In the BeamNG.drive exporter, this contains data for weights, wheel data, stiffness values that the C++ code uses when creating the node and beam geometry required for the physics simulation of the car soft body.