Skip to content

Attribute

Ferdinand Calo edited this page Apr 7, 2021 · 24 revisions
# Feature Overview
Kind: Attribute
Extendable: yes/by code
JSON based: no
JSON config: yes

Attributes are a new feature added in FVTM 3!
Currently FVTM uses the 5th prototype of the Attribute System.

A Vehicle can store as many attributes as you give it.
Some attributes can change the vehicle's behaviour,
some other are locked from direct modification and hold
a copy of the vehicle's current status (throttle/wheel rot),
and some are purely just there because ... 🤔 you added them?

Besides the default attributes which any vehicle will have
for correct functionality by default, you can define your own.
Do that either in your Vehicle config directly or via Parts.
Also you can override default attributes in the vehicle config.

Attributes are defined in a config in JSON Object, usually you
place those into an JSON array called "Attributes" in either
your Vehicle or Part Config file.

Example config (taken from FVP):

{
    "__comment": "Vehicle JSON file.",
    "Attributes": [
    	{ "id":"weight", "type": "float", "value": 1480 },
    	{ "id":"constructor_length", "type": "float", "value": 3 },
    	{ "id":"constructor_height", "type": "float", "value": -9 },
    	{ "id":"constructor_wheel_offset", "type": "float", "value": 18 }
    ]
}

Here an overview of the fields:

  • id - the ID of the attribute
  • type - the value type of your attribute, available ones are:
    • string, text - the value of your attribute will be a java String
    • integer, number - the value of your attribute will be a java Integer
    • float, double - the value of you attribute will be a java Float
    • boolean, bool - the value of your attribute will be a java Boolean
    • tristate, ternary - the value of your attribute will be a java Boolean
      with optional null value as third state, an example usage of this is the default turn_lights attribute of cars
    • vector3, vec3 - the value of your attribute will be a 3 axe (x/y/z) Vec3f class
    • there are unimplemented but planned types also
      • string_array
      • boolean_array
      • integer_array
      • float_array
    • since 3.6.52 you can register new Attribute classes into FVTM
  • target - optional, the target of your attribute, in a vehicle config you can
    skip this, in a part config you can fine tune the desired target(s) as listed bellow
    note: you can define multiple targets by using commas, use an ! before the target
    to prevent addition into a specific target instead
    • vehicle - the attribute is targetted to the vehicle, default
      it will apply to whichever vehicle you install this part
    • <packid>:<vehicleid> - the attribute is targetted to a specific vehicle
    • <category> - the attribute is targetted to a vehicle having this category
    • pack-<packid> - the attribute is targetted to any vehicle from that pack
  • value - the default/initial value for the attribute, has to be of the correct type
  • min - the minimal value of the attribute (ignored for strings/booleans)
  • max - the maximal value of the attribute (ignored for strings/booleans)
  • editable - if the attribute is editable (ingame)
  • seat - optional, the seat the attribute is assigned to (ingame) since 3.6.52 can be also in form of a json array to specify multiple seats
  • hitbox - optional, makes the attribute toggable "physically" by the driver/passenger
    • can either have a single defined position, for any value, e.g.: "hitbox": [ x, y, z, size ]
    • or be different for specific attribute values, ("default" being the universal/fallback one)
      "hitbox":{
        "true": [ x, y, z, size ],
        "false": [ x, y, z, size ],
        "custom_string_value": [ x, y, z, size ],
        "default": [ x, y, z, size ]
      }
      
    • some fine example in the FVP C11 Config!
    • note: "x/y/z" is the position, as a marker in FMT or rotation point of a box would indicate,
      and the "size" is a "radius" for the bounding box around the x/y/z.
    • add before the "value" field external-, e.g. external-false to make the attribute accessible
      for players not sitting inside the vehicle (implemented v. 3.2.41)
    • number attributes, for number type (integer/float) attribute use the following
      values: "hitbox": [ x, y, z, size, increase_by, decrease_by, reset_value ],
      I hope they are self-explaining. (implemented v. 3.2.40b/41)
    • if you want a hitbox to follow a specific SwivelPoint add it's id as last value of the array
      e.g. "hitbox": [ x, y, z, size, point_id ]
  • external - if the attribute is to be accessed from outside (not passender/driver), default false
  • group - group of the attribute, to group multiple attributes together

Modifiers

Attributes can have Modifiers, those are added into the vehicle via Parts.
It happens in a similar manner as adding Attributes.

Modifiers allow for example to rise a specific value when a part is installed.
One example is the weight modifier found in some parts of FVP (addonpack).
For example vehicle weight matters in BasicSystem.
For more info on Modifiers check the Modifiers page!

Clone this wiki locally