Skip to content

Commit b332494

Browse files
committed
Add: Extend FEAT_TRAIN track_type for prop 34
1 parent 03705d2 commit b332494

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nml/actions/action0properties.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,24 @@ 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, 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": {"custom_function": lambda value: single_or_list("track_type", 0x05, 0x34, value)},
423433
"ai_special_flag": {"size": 1, "num": 0x08},
424434
"speed": {
425435
"size": 2,

0 commit comments

Comments
 (0)