Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion nml/actions/action0properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,26 @@ def prop_test(value):
]


def single_or_list(prop_name, single_num, multiple_num, value):
if isinstance(value, ConstantNumeric):
return [Action0Property(single_num, value, 1)]
if isinstance(value, Array):
if len(value.values) == 1:
return [Action0Property(single_num, value.values[0].reduce_constant(), 1)]
return [VariableByteListProp(multiple_num, [[type.reduce_constant().value for type in value.values]])]
raise generic.ScriptError("'{}' must be a constant or an array of constants".format(prop_name))


#
# Feature 0x00 (Trains)
#

# fmt: off
properties[0x00] = {
**general_veh_props,
"track_type": {"size": 1, "num": 0x05},
"track_type": {
"custom_function": lambda value: single_or_list("track_type", 0x05, 0x34, value)
},
"ai_special_flag": {"size": 1, "num": 0x08},
"speed": {
"size": 2,
Expand Down
2 changes: 2 additions & 0 deletions regression/013_train_callback.nml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ item(FEAT_TRAINS, bulk_wagon) {
speed: 0;
refit_cost: 40;
track_type: RAIL;
track_type: [RAIL];
track_type: [RAIL, ELRL];
power: 0;
running_cost_base: RUNNING_COST_STEAM;
cargo_capacity: 30;
Expand Down
Binary file modified regression/expected/013_train_callback.grf
Binary file not shown.
9 changes: 6 additions & 3 deletions regression/expected/013_train_callback.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ FF
69 * 9 0D 7E \D<< 01 FF \dxFFFFFFF8

70 * 12 06
7F 01 FF \wx004D
7E 01 FF \wx004F
7F 01 FF \wx0053
7E 01 FF \wx0055
FF

71 * 82 00 00 \b26 01 FF \wx0074
71 * 88 00 00 \b28 01 FF \wx0074
06 0F
28 \wx0010
1D \dx00000000
Expand All @@ -249,6 +249,9 @@ FF
09 \wx0000
1C 28
05 00
05 00
34 \b2
00 01
0B \wx0000
0E \dx00004C30
14 1E
Expand Down
Loading