diff --git a/nml/actions/action0properties.py b/nml/actions/action0properties.py index 5d931858e..edcab2574 100644 --- a/nml/actions/action0properties.py +++ b/nml/actions/action0properties.py @@ -412,6 +412,16 @@ 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) # @@ -419,7 +429,9 @@ def prop_test(value): # 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, diff --git a/regression/013_train_callback.nml b/regression/013_train_callback.nml index 2286f24d9..28873ffb3 100644 --- a/regression/013_train_callback.nml +++ b/regression/013_train_callback.nml @@ -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; diff --git a/regression/expected/013_train_callback.grf b/regression/expected/013_train_callback.grf index d1daeed35..fd8c1f115 100644 Binary files a/regression/expected/013_train_callback.grf and b/regression/expected/013_train_callback.grf differ diff --git a/regression/expected/013_train_callback.nfo b/regression/expected/013_train_callback.nfo index 96ffa9ae1..5eb06da92 100644 --- a/regression/expected/013_train_callback.nfo +++ b/regression/expected/013_train_callback.nfo @@ -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 @@ -249,6 +249,9 @@ FF 09 \wx0000 1C 28 05 00 +05 00 +34 \b2 +00 01 0B \wx0000 0E \dx00004C30 14 1E