Skip to content

Commit 1b86893

Browse files
authored
Add: Extend FEAT_TRAIN track_type for prop 34 (#390)
1 parent 03705d2 commit 1b86893

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

nml/actions/action0properties.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,26 @@ def prop_test(value):
412412
]
413413

414414

415+
def single_or_list(prop_name, single_num, multiple_num, value):
416+
if isinstance(value, ConstantNumeric):
417+
return [Action0Property(single_num, value, 1)]
418+
if isinstance(value, Array):
419+
if len(value.values) == 1:
420+
return [Action0Property(single_num, value.values[0].reduce_constant(), 1)]
421+
return [VariableByteListProp(multiple_num, [[type.reduce_constant().value for type in value.values]])]
422+
raise generic.ScriptError("'{}' must be a constant or an array of constants".format(prop_name))
423+
424+
415425
#
416426
# Feature 0x00 (Trains)
417427
#
418428

419429
# fmt: off
420430
properties[0x00] = {
421431
**general_veh_props,
422-
"track_type": {"size": 1, "num": 0x05},
432+
"track_type": {
433+
"custom_function": lambda value: single_or_list("track_type", 0x05, 0x34, value)
434+
},
423435
"ai_special_flag": {"size": 1, "num": 0x08},
424436
"speed": {
425437
"size": 2,

regression/013_train_callback.nml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ item(FEAT_TRAINS, bulk_wagon) {
136136
speed: 0;
137137
refit_cost: 40;
138138
track_type: RAIL;
139+
track_type: [RAIL];
140+
track_type: [RAIL, ELRL];
139141
power: 0;
140142
running_cost_base: RUNNING_COST_STEAM;
141143
cargo_capacity: 30;
6 Bytes
Binary file not shown.

regression/expected/013_train_callback.nfo

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ FF
223223
69 * 9 0D 7E \D<< 01 FF \dxFFFFFFF8
224224

225225
70 * 12 06
226-
7F 01 FF \wx004D
227-
7E 01 FF \wx004F
226+
7F 01 FF \wx0053
227+
7E 01 FF \wx0055
228228
FF
229229

230-
71 * 82 00 00 \b26 01 FF \wx0074
230+
71 * 88 00 00 \b28 01 FF \wx0074
231231
06 0F
232232
28 \wx0010
233233
1D \dx00000000
@@ -249,6 +249,9 @@ FF
249249
09 \wx0000
250250
1C 28
251251
05 00
252+
05 00
253+
34 \b2
254+
00 01
252255
0B \wx0000
253256
0E \dx00004C30
254257
14 1E

0 commit comments

Comments
 (0)