-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathac_car_scriptable_display.lua
61 lines (52 loc) · 2.15 KB
/
ac_car_scriptable_display.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
__source 'extensions/car_instruments/car_scriptable_display.cpp'
__allow 'csd'
--[[? ctx.flags.withoutIO = true; ?]]
require './common/internal_import'
require './common/ac_audio'
require './common/ac_light'
require './common/ac_ui'
require './common/ac_display'
require './common/ac_particles'
require './common/ac_scene'
require './common/ac_ray'
require './common/ac_car_control'
require './common/ac_car_control_physics'
require './common/ac_physics_raycast'
require './common/ac_extras_binaryinput'
require './car_scriptable_display/car_scriptable_display_structs'
require './car_scriptable_display/car_scriptable_display_utils'
require './common/secure'
-- automatically generated entries go here:
__definitions()
-- extra additions:
---Reference to information about state of associated car.
---@type ac.StateCar
car = nil
---Reference to information about state of simulation.
---@type ac.StateSim
sim = nil
function __script.__init__()
car = ac.getCar(__carindex__ - 1)
sim = ac.getSim()
end
---Returns values from section which defined current display. Use `layout` to specify which
---values are needed, with their corresponding default values to determine types. This function
---can be used to configure script from config, allowing to create customizable scripts which
---would act as new types of displays, especially if used with INIpp templates.
---
---Note: consider using lowerCamelCase for keys to make sure there wouldn’t be a collision with
---CSP parameters for scriptable displays, as well as with INIpp template parameters (which use UpperCamelCase).
---
---You can achieve the same results by using `ac.getCarConfig()` (name of section which creates script
---is available in `__cfgSection__` global variable). This is just a shortcut to make things nicer.
---@generic T
---@param layout T
---@return T
function ac.configValues(layout)
return table.map(layout, function (item, index) return ac.getCarConfig(__carindex__ - 1, __cfgSection__, index, item), index end)
end
-- script format:
---@class ScriptData
---@field update fun(dt: number) @Called each frame. Param `dt` is time since the last call of `.update()` in seconds.
---@single-instance
script = {}