wagons.lua 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. local S = dlxtrains_support_wagons.S
  2. local use_attachment_patch = advtrains_attachment_offset_patch and advtrains_attachment_offset_patch.setup_advtrains_wagon
  3. local mod_name = "dlxtrains_support_wagons"
  4. dlxtrains.register_mod(mod_name)
  5. -- ////////////////////////////////////////////////////////////////////////////////////
  6. local livery_scheme_support_wagon_caboose_type1 = {
  7. filename_prefix = "dlxtrains_support_wagons_caboose_type1",
  8. [0]={code="t"},
  9. [1]={code="dlx"},
  10. [2]={code="nr"},
  11. [3]={code="tt"},
  12. count = 4,
  13. }
  14. local livery_scheme_support_wagon_escort_type1 = {
  15. filename_prefix = "dlxtrains_support_wagons_escort_type1",
  16. [0]={code="wf"},
  17. [1]={code="t"},
  18. [2]={code="dz"},
  19. [3]={code="zr"},
  20. count = 4,
  21. }
  22. -- ////////////////////////////////////////////////////////////////////////////////////
  23. local livery_templates = {
  24. ["dlxtrains_support_wagons:caboose_type1"] = {
  25. dlxtrains.init_livery_template(mod_name, 0, dlxtrains.livery_type.standard, "T", "caboose_type1_t"),
  26. dlxtrains.init_livery_template(mod_name, 1, dlxtrains.livery_type.middle_era, "DL&X", "caboose_type1_dlx"),
  27. dlxtrains.init_livery_template(mod_name, 2, dlxtrains.livery_type.middle_era, "NR", "caboose_type1_nr"),
  28. dlxtrains.init_livery_template(mod_name, 3, dlxtrains.livery_type.middle_era, "TT", "caboose_type1_tt"),
  29. },
  30. ["dlxtrains_support_wagons:escort_type1"] = {
  31. dlxtrains.init_livery_template(mod_name, 0, dlxtrains.livery_type.standard, "WF", "escort_type1_wf"),
  32. dlxtrains.init_livery_template(mod_name, 1, dlxtrains.livery_type.standard, "T", "escort_type1_t"),
  33. dlxtrains.init_livery_template(mod_name, 2, dlxtrains.livery_type.standard, "DZ", "escort_type1_dz"),
  34. dlxtrains.init_livery_template(mod_name, 3, dlxtrains.livery_type.standard, "ZR", "escort_type1_zr"),
  35. },
  36. }
  37. -- ////////////////////////////////////////////////////////////////////////////////////
  38. local meshes_support_wagon_caboose_type1 = {
  39. default = "dlxtrains_support_wagons_caboose_type1.obj",
  40. }
  41. local meshes_support_wagon_escort_type1 = {
  42. default = "dlxtrains_support_wagons_escort_type1.obj",
  43. }
  44. -- ////////////////////////////////////////////////////////////////////////////////////
  45. if dlxtrains_support_wagons.max_wagon_length >= 6 then
  46. local wagon_type = "dlxtrains_support_wagons:caboose_type1"
  47. dlxtrains.register_livery_templates(wagon_type, mod_name, livery_templates)
  48. local wagon_def = {
  49. mesh = meshes_support_wagon_caboose_type1.default,
  50. textures = {dlxtrains.get_init_texture()},
  51. set_textures = function(wagon, data)
  52. dlxtrains.set_textures_for_livery_scheme(wagon, data, livery_scheme_support_wagon_caboose_type1, meshes_support_wagon_caboose_type1)
  53. end,
  54. custom_may_destroy = function(wagon, puncher, time_from_last_punch, tool_capabilities, direction)
  55. return not dlxtrains.update_livery(wagon, puncher, livery_scheme_support_wagon_caboose_type1)
  56. end,
  57. drives_on={default=true},
  58. seats = {
  59. {
  60. name = "Left seat in cabin",
  61. attach_offset = use_attachment_patch and {x=-4.2, y=-2, z=-18.2} or {x=-3.5, y=-2, z=-19.5},
  62. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=0, y=-3, z=0},
  63. advtrains_attachment_offset_patch_attach_rotation = use_attachment_patch and {x=0, y=90, z=0} or nil,
  64. group = "cabin",
  65. },
  66. {
  67. name = "Right seat in cabin",
  68. attach_offset = use_attachment_patch and {x=4.0, y=-2, z=-18.2} or {x=3.5, y=-2, z=-19.5},
  69. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=0, y=-3, z=0},
  70. advtrains_attachment_offset_patch_attach_rotation = use_attachment_patch and {x=0, y=270, z=0} or nil,
  71. group = "cabin",
  72. },
  73. {
  74. name = "Left seat in Cupola",
  75. attach_offset = {x=-3.8, y=6, z=-2},
  76. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=-3.9, y=7, z=-1.5},
  77. group = "cupola",
  78. },
  79. {
  80. name = "Right seat in Cupola",
  81. attach_offset = use_attachment_patch and {x=3.8, y=6, z=2} or {x=3.8, y=6, z=-2},
  82. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=3.9, y=7, z=-1.5},
  83. advtrains_attachment_offset_patch_attach_rotation = use_attachment_patch and {x=0, y=180, z=0} or nil,
  84. group = "cupola",
  85. },
  86. },
  87. seat_groups = {
  88. cabin={
  89. name = "Cabin",
  90. access_to = {"cupola"},
  91. require_doors_open = false,
  92. },
  93. cupola={
  94. name = "Cupola",
  95. access_to = {"cabin"},
  96. require_doors_open = false,
  97. },
  98. },
  99. assign_to_seat_group = {"cabin", "cupola"},
  100. max_speed=25,
  101. visual_size = {x=1, y=1},
  102. wagon_span=3,
  103. wheel_positions = {1.625, -1.625},
  104. collisionbox = {-1.0,-0.5,-1.0,1.0,2.5,1.0},
  105. coupler_types_front = {knuckle=true},
  106. coupler_types_back = {knuckle=true},
  107. drops={dlxtrains.materials.steelblock},
  108. has_inventory = false,
  109. }
  110. if use_attachment_patch then
  111. advtrains_attachment_offset_patch.setup_advtrains_wagon(wagon_def);
  112. end
  113. advtrains.register_wagon(wagon_type, wagon_def, S("Wooden Caboose with Cupola"), "dlxtrains_support_wagons_caboose_type1_inv.png")
  114. end
  115. if dlxtrains_support_wagons.max_wagon_length >= 4.875 then
  116. local wagon_type = "dlxtrains_support_wagons:escort_type1"
  117. dlxtrains.register_livery_templates(wagon_type, mod_name, livery_templates)
  118. local wagon_def = {
  119. mesh = meshes_support_wagon_escort_type1.default,
  120. textures = {dlxtrains.get_init_texture()},
  121. set_textures = function(wagon, data)
  122. dlxtrains.set_textures_for_livery_scheme(wagon, data, livery_scheme_support_wagon_escort_type1, meshes_support_wagon_escort_type1)
  123. end,
  124. custom_may_destroy = function(wagon, puncher, time_from_last_punch, tool_capabilities, direction)
  125. return not dlxtrains.update_livery(wagon, puncher, livery_scheme_support_wagon_escort_type1)
  126. end,
  127. seats = {
  128. {
  129. name = "Rear right seat in cabin",
  130. attach_offset = {x=3.2, y=-2, z=-5.6},
  131. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=0, y=-3, z=0},
  132. group = "cabin",
  133. },
  134. {
  135. name = "Front left seat in cabin",
  136. attach_offset = {x=-3.2, y=-2, z=4},
  137. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=2.6, y=-3, z=13},
  138. advtrains_attachment_offset_patch_attach_rotation = use_attachment_patch and {x=0, y=180, z=0} or nil,
  139. group = "cabin",
  140. },
  141. {
  142. name = "On propane cabinet on veranda",
  143. attach_offset = {x=-2.6, y=-2, z=-13},
  144. view_offset = use_attachment_patch and {x=0, y=0, z=0} or {x=2.6, y=-3, z=13},
  145. advtrains_attachment_offset_patch_attach_rotation = use_attachment_patch and {x=0, y=180, z=0} or nil,
  146. group = "veranda",
  147. },
  148. },
  149. seat_groups = {
  150. cabin={
  151. name = "Cabin",
  152. access_to = {"veranda"},
  153. require_doors_open = false,
  154. },
  155. veranda={
  156. name = "Veranda",
  157. access_to = {"cabin"},
  158. require_doors_open = false,
  159. },
  160. },
  161. assign_to_seat_group = {"cabin", "veranda"},
  162. drives_on={default=true},
  163. max_speed=20,
  164. visual_size = {x=1, y=1},
  165. wagon_span=2.4375,
  166. wheel_positions = {1.2, -1.2},
  167. collisionbox = {-1.4,-0.5,-1.4,1.4,2.5,1.4},
  168. coupler_types_front = {chain=true},
  169. coupler_types_back = {chain=true},
  170. drops={dlxtrains.materials.steelblock},
  171. has_inventory = false,
  172. }
  173. if use_attachment_patch then
  174. advtrains_attachment_offset_patch.setup_advtrains_wagon(wagon_def);
  175. end
  176. advtrains.register_wagon(wagon_type, wagon_def, S("European Escort Wagon"), "dlxtrains_support_wagons_escort_type1_inv.png")
  177. end