@@ -66,6 +66,10 @@ if apiVersion >= 1.016 then
6666 inc .y (lineSpacing * 0.4 )
6767end
6868
69+ if apiVersion >= 1.043 then
70+ fields [# fields + 1 ] = { t = " Rates Type" , x = x , y = inc .y (lineSpacing ), sp = x + sp , min = 0 , max = 4 , vals = { 23 }, table = { [0 ] = " BF" , " RF" , " KISS" , " ACTUAL" , " QUICK" }, postEdit = function (self ) self .updateRatesType (self , true ) end }
71+ end
72+
6973if apiVersion >= 1.016 then
7074 labels [# labels + 1 ] = { t = " Throttle" , x = x , y = inc .y (lineSpacing ) }
7175 fields [# fields + 1 ] = { t = " Mid" , x = x + indent , y = inc .y (lineSpacing ), sp = x + sp , min = 0 , max = 100 , vals = { 7 }, scale = 100 }
@@ -91,4 +95,49 @@ return {
9195 minBytes = 12 ,
9296 labels = labels ,
9397 fields = fields ,
98+ ratesType ,
99+ getRatesType = function (self )
100+ for i = 1 , # self .fields do
101+ if self .fields [i ].vals and self .fields [i ].vals [1 ] == 23 then
102+ return self .fields [i ].table [self .fields [i ].value ]
103+ end
104+ end
105+ end ,
106+ updateRatesType = function (self , applyDefaults )
107+ local ratesTable = assert (loadScript (" RATETABLES/" .. self .getRatesType (self ).. " .lua" ))()
108+ for i = 1 , # ratesTable .labels do
109+ self .labels [i ].t = ratesTable .labels [i ]
110+ end
111+ for i = 1 , # ratesTable .fields do
112+ for k , v in pairs (ratesTable .fields [i ]) do
113+ self .fields [i ][k ] = v
114+ end
115+ end
116+ if applyDefaults and self .ratesType ~= self .getRatesType (self ) then
117+ for i = 1 , # ratesTable .defaults do
118+ local f = self .fields [i ]
119+ f .value = ratesTable .defaults [i ]
120+ for idx = 1 , # f .vals do
121+ self .values [f .vals [idx ]] = bit32.rshift (math.floor (f .value * (f .scale or 1 ) + 0.5 ), (idx - 1 )* 8 )
122+ end
123+ end
124+ else
125+ for i = 1 , 9 do
126+ local f = self .fields [i ]
127+ f .value = 0
128+ for idx = 1 , # f .vals do
129+ local raw_val = self .values [f .vals [idx ]] or 0
130+ raw_val = bit32.lshift (raw_val , (idx - 1 )* 8 )
131+ f .value = bit32.bor (f .value , raw_val )
132+ end
133+ f .value = f .value / (f .scale or 1 )
134+ end
135+ end
136+ self .ratesType = self .getRatesType (self )
137+ end ,
138+ postLoad = function (self )
139+ if apiVersion >= 1.043 then
140+ self .updateRatesType (self )
141+ end
142+ end ,
94143}
0 commit comments