I am trying to code an articulated road vehicle that will obey the following logic:
first vehicle: no cargo
(add trailers)
if cargo type is coal:
build 4 trailers
else:
build 2 trailers
The vehicle will only carry one cargo type, there is no requirement for mixed cargoes.
The following code fails. I think it's valid code, but the wrong implementation for what I am trying to achieve. My guess is that because the first vehicle has no cargo, variable 47 will never return 01, so action C2 will always be used.
What would be a better implementation?
thanks,
Andy
Code: Select all
806 * 26 02 01 C3 // Action 2
81 10 00 FF //check byte value of variable 10 (no bit shift, FF andmask)
04 //check four ranges
03 80 01 01 //give callback result of 03 for value 01
01 80 02 02 //give callback result of 00 for value 02
03 80 03 03 //give callback result of 03 for value 03
01 80 04 04 //give callback result of 00 for value 04
FF FF // end the callback chain
807 * 26 02 01 C2 // Action 2
81 10 00 FF //check byte value of variable 10 (no bit shift, FF andmask)
02 //check four ranges
03 80 01 01 //give callback result of 03 for value 01
00 80 02 02 //give callback result of 00 for value 02
FF FF // end the callback chain
808 * 14 02 01 C1 // Action 2
81 47 00 FF //check byte value of variable 47 (no bit shift, FF andmask)
01 //check one range
C3 00 01 01 // go to ID C3 for value 01 - cargo is coal
C2 00 // go to ID C2 for default
809 * 14 02 01 C0 // Action 2
81 0C 00 FF //check byte value of variable 81 (no bit shift, FF andmask)
01 //check one range
C1 00 16 16 //go to ID C1 for value 16 (ie. go to the articulated vehicle building instructions)
A0 00 //otherwise go to ID A0 (ie. apply vehicle graphics)
810 * 7 03 // Action 3
01 // RV
01 // Number of vehicles this action associate graphics with
06 // Vehicle ID
00 // only use default cargo
C0 00 // Action 2 ID for default cargo