init.lua 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. local mod_name = "classic_coaches"
  2. local S = minetest.get_translator(mod_name)
  3. local use_advtrains_livery_designer = minetest.get_modpath( "advtrains_livery_designer" ) and advtrains_livery_designer
  4. local door = 'default:steel_ingot'
  5. if minetest.get_modpath("doors") then
  6. door = 'doors:door_steel'
  7. end
  8. ----------------------------------------------------------------------------------------
  9. local default_roof_alpha = 230
  10. local default_seat_alpha = 245
  11. local default_wall_alpha = 253
  12. local wagons = {
  13. {
  14. wagon_type = "classic_coaches:corridor_coach_class1",
  15. mesh = "classic_coaches_corridor_coach_class1.b3d",
  16. textures = {"classic_coaches_corridor_coach_class1_001.png"},
  17. name = S("Intercity Corridor Coach Class 1"),
  18. inventory_image = "classic_coaches_corridor_coach_class1_inv.png",
  19. recipe = {
  20. {'default:goldblock'},
  21. {'classic_coaches:corridor_coach_class2'},
  22. },
  23. },
  24. {
  25. wagon_type = "classic_coaches:corridor_coach_class2",
  26. mesh = "classic_coaches_corridor_coach_class2.b3d",
  27. textures = {"classic_coaches_corridor_coach_class2_001.png"},
  28. name = S("Intercity Corridor Coach Class 2"),
  29. inventory_image = "classic_coaches_corridor_coach_class2_inv.png",
  30. recipe = {
  31. {'default:steelblock', 'dye:grey', 'default:steelblock'},
  32. {'default:glass', 'wool:blue', door},
  33. {'advtrains:wheel', 'default:steelblock', 'advtrains:wheel'},
  34. },
  35. },
  36. {
  37. wagon_type = "classic_coaches:open_coach_class1",
  38. mesh = "classic_coaches_open_coach_class1.b3d",
  39. textures = {"classic_coaches_open_coach_class1_001.png"},
  40. name = S("Intercity Open Coach Class 1"),
  41. inventory_image = "classic_coaches_open_coach_class1_inv.png",
  42. recipe = {
  43. {'default:goldblock'},
  44. {'classic_coaches:open_coach_class2'},
  45. },
  46. },
  47. {
  48. wagon_type = "classic_coaches:open_coach_class2",
  49. mesh = "classic_coaches_open_coach_class2.b3d",
  50. textures = {"classic_coaches_open_coach_class2_001.png"},
  51. name = S("Intercity Open Coach Class 2"),
  52. inventory_image = "classic_coaches_open_coach_class2_inv.png",
  53. recipe = {
  54. {'default:steelblock', 'dye:grey', 'default:steelblock'},
  55. {'default:glass', 'wool:cyan', door},
  56. {'advtrains:wheel', 'default:steelblock', 'advtrains:wheel'},
  57. },
  58. },
  59. }
  60. local livery_template_names = {
  61. [1] = {name = S("CC Stripe"), notes = "The livery features a medium width stripe with embedded logo. A narrow divider stripe can be added."},
  62. [2] = {name = S("CC Intercity Stripe"), notes = "The livery features a medium width stripe with embedded logo and the word, 'intercity'. The side doors are colored differently by default."},
  63. [3] = {name = S("CC Edged Stripe"), notes = "The livery features a medium width stripe with embedded logo. The stripe's edges are colored differently by default."},
  64. [4] = {name = S("CC Window Band"), notes = "A wide band of color spans the widow area for the length of the wagon."},
  65. [5] = {name = S("CC Solid Color"), notes = "The wagon sides are a solid color without stripes or other decoration."},
  66. [6] = {name = S("CC Colored Roof"), notes = "The roof and the lower edge of the wagon sides are colored. A wide light grey band spans the widow area for the length of the wagon."},
  67. [7] = {name = S("CC Express"), notes = "Thin stripes and the word, 'Express' are shown on both sides of the wagon."},
  68. }
  69. local livery_templates = {
  70. ["classic_coaches:corridor_coach_class1"] = {
  71. [1] = {
  72. base_texture = "classic_coaches_corridor_coach_class1_001.png",
  73. overlays = {
  74. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_001_class1_side_walls.png", alpha = default_wall_alpha},
  75. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_001_stripe.png", alpha = default_wall_alpha},
  76. [3] = {name = S("Stripe Divider"), texture = "classic_coaches_overlay_001_stripe_divider.png"},
  77. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  78. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  79. },
  80. },
  81. [2] = {
  82. base_texture = "classic_coaches_corridor_coach_class1_002.png",
  83. overlays = {
  84. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_002_class1_exterior_walls.png", alpha = default_wall_alpha},
  85. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_002_stripe.png", alpha = default_wall_alpha},
  86. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  87. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  88. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  89. },
  90. },
  91. [3] = {
  92. base_texture = "classic_coaches_corridor_coach_class1_003.png",
  93. overlays = {
  94. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_003_side_walls.png", alpha = default_wall_alpha},
  95. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_003_stripe.png", alpha = default_wall_alpha},
  96. [3] = {name = S("Stripe Edges"), texture = "classic_coaches_overlay_003_stripe_edges.png"},
  97. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_1.png"},
  98. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  99. },
  100. },
  101. [4] = {
  102. base_texture = "classic_coaches_corridor_coach_class1_004.png",
  103. overlays = {
  104. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_004_side_walls.png", alpha = default_wall_alpha},
  105. [2] = {name = S("Window Band"), texture = "classic_coaches_overlay_004_class1_window_band.png", alpha = default_wall_alpha},
  106. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_004_decoration.png"},
  107. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  108. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  109. },
  110. },
  111. [5] = {
  112. base_texture = "classic_coaches_corridor_coach_class1_005.png",
  113. overlays = {
  114. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_005_class1_side_walls.png", alpha = default_wall_alpha},
  115. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  116. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  117. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  118. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  119. },
  120. },
  121. [6] = {
  122. base_texture = "classic_coaches_corridor_coach_class1_006.png",
  123. overlays = {
  124. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_006_side_walls.png", alpha = default_wall_alpha},
  125. [2] = {name = S("Roof"), texture = "classic_coaches_overlay_006_roof.png", alpha = default_roof_alpha},
  126. [3] = {name = S("Trim"), texture = "classic_coaches_overlay_006_trim.png"},
  127. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  128. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  129. },
  130. },
  131. [7] = {
  132. base_texture = "classic_coaches_corridor_coach_class1_007.png",
  133. overlays = {
  134. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_007_class1_exterior_walls.png", alpha = default_wall_alpha},
  135. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  136. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_007_decoration.png"},
  137. [4] = {name = S("Label"), texture = "classic_coaches_overlay_007_label.png"},
  138. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  139. [6] = {name = S("Logo and Text"), texture = "classic_coaches_overlay_007_logo_text.png"},
  140. },
  141. },
  142. },
  143. ["classic_coaches:corridor_coach_class2"] = {
  144. [1] = {
  145. base_texture = "classic_coaches_corridor_coach_class2_001.png",
  146. overlays = {
  147. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_001_class2_side_walls.png", alpha = default_wall_alpha},
  148. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_001_stripe.png", alpha = default_wall_alpha},
  149. [3] = {name = S("Stripe Divider"), texture = "classic_coaches_overlay_001_stripe_divider.png"},
  150. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  151. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  152. },
  153. },
  154. [2] = {
  155. base_texture = "classic_coaches_corridor_coach_class2_002.png",
  156. overlays = {
  157. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_002_class2_exterior_walls.png", alpha = default_wall_alpha},
  158. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_002_stripe.png", alpha = default_wall_alpha},
  159. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  160. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  161. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  162. },
  163. },
  164. [3] = {
  165. base_texture = "classic_coaches_corridor_coach_class2_003.png",
  166. overlays = {
  167. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_003_side_walls.png", alpha = default_wall_alpha},
  168. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_003_stripe.png", alpha = default_wall_alpha},
  169. [3] = {name = S("Stripe Edges"), texture = "classic_coaches_overlay_003_stripe_edges.png"},
  170. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_1.png"},
  171. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  172. },
  173. },
  174. [4] = {
  175. base_texture = "classic_coaches_corridor_coach_class2_004.png",
  176. overlays = {
  177. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_004_side_walls.png", alpha = default_wall_alpha},
  178. [2] = {name = S("Window Band"), texture = "classic_coaches_overlay_004_class2_window_band.png", alpha = default_wall_alpha},
  179. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_004_decoration.png"},
  180. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  181. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  182. },
  183. },
  184. [5] = {
  185. base_texture = "classic_coaches_corridor_coach_class2_005.png",
  186. overlays = {
  187. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_005_class2_side_walls.png", alpha = default_wall_alpha},
  188. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  189. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  190. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  191. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  192. },
  193. },
  194. [6] = {
  195. base_texture = "classic_coaches_corridor_coach_class2_006.png",
  196. overlays = {
  197. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_006_side_walls.png", alpha = default_wall_alpha},
  198. [2] = {name = S("Roof"), texture = "classic_coaches_overlay_006_roof.png", alpha = default_roof_alpha},
  199. [3] = {name = S("Trim"), texture = "classic_coaches_overlay_006_trim.png"},
  200. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  201. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  202. },
  203. },
  204. [7] = {
  205. base_texture = "classic_coaches_corridor_coach_class2_007.png",
  206. overlays = {
  207. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_007_class2_exterior_walls.png", alpha = default_wall_alpha},
  208. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  209. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_007_decoration.png"},
  210. [4] = {name = S("Label"), texture = "classic_coaches_overlay_007_label.png"},
  211. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  212. [6] = {name = S("Logo and Text"), texture = "classic_coaches_overlay_007_logo_text.png"},
  213. },
  214. },
  215. },
  216. ["classic_coaches:open_coach_class1"] = {
  217. [1] = {
  218. base_texture = "classic_coaches_open_coach_class1_001.png",
  219. overlays = {
  220. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_001_class1_side_walls.png", alpha = default_wall_alpha},
  221. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_001_stripe.png", alpha = default_wall_alpha},
  222. [3] = {name = S("Stripe Divider"), texture = "classic_coaches_overlay_001_stripe_divider.png"},
  223. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  224. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  225. },
  226. },
  227. [2] = {
  228. base_texture = "classic_coaches_open_coach_class1_002.png",
  229. overlays = {
  230. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_002_class1_exterior_walls.png", alpha = default_wall_alpha},
  231. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_002_stripe.png", alpha = default_wall_alpha},
  232. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  233. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  234. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  235. },
  236. },
  237. [3] = {
  238. base_texture = "classic_coaches_open_coach_class1_003.png",
  239. overlays = {
  240. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_003_side_walls.png", alpha = default_wall_alpha},
  241. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_003_stripe.png", alpha = default_wall_alpha},
  242. [3] = {name = S("Stripe Edges"), texture = "classic_coaches_overlay_003_stripe_edges.png"},
  243. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_1.png"},
  244. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  245. },
  246. },
  247. [4] = {
  248. base_texture = "classic_coaches_open_coach_class1_004.png",
  249. overlays = {
  250. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_004_side_walls.png", alpha = default_wall_alpha},
  251. [2] = {name = S("Window Band"), texture = "classic_coaches_overlay_004_class1_window_band.png", alpha = default_wall_alpha},
  252. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_004_decoration.png"},
  253. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  254. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  255. },
  256. },
  257. [5] = {
  258. base_texture = "classic_coaches_open_coach_class1_005.png",
  259. overlays = {
  260. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_005_class1_side_walls.png", alpha = default_wall_alpha},
  261. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  262. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  263. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  264. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  265. },
  266. },
  267. [6] = {
  268. base_texture = "classic_coaches_open_coach_class1_006.png",
  269. overlays = {
  270. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_006_side_walls.png", alpha = default_wall_alpha},
  271. [2] = {name = S("Roof"), texture = "classic_coaches_overlay_006_roof.png", alpha = default_roof_alpha},
  272. [3] = {name = S("Trim"), texture = "classic_coaches_overlay_006_trim.png"},
  273. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  274. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  275. },
  276. },
  277. [7] = {
  278. base_texture = "classic_coaches_open_coach_class1_007.png",
  279. overlays = {
  280. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_007_class1_exterior_walls.png", alpha = default_wall_alpha},
  281. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  282. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_007_decoration.png"},
  283. [4] = {name = S("Label"), texture = "classic_coaches_overlay_007_label.png"},
  284. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class1_class_number.png"},
  285. [6] = {name = S("Logo and Text"), texture = "classic_coaches_overlay_007_logo_text.png"},
  286. },
  287. },
  288. },
  289. ["classic_coaches:open_coach_class2"] = {
  290. [1] = {
  291. base_texture = "classic_coaches_open_coach_class2_001.png",
  292. overlays = {
  293. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_001_class2_side_walls.png", alpha = default_wall_alpha},
  294. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_001_stripe.png", alpha = default_wall_alpha},
  295. [3] = {name = S("Stripe Divider"), texture = "classic_coaches_overlay_001_stripe_divider.png"},
  296. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  297. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  298. },
  299. },
  300. [2] = {
  301. base_texture = "classic_coaches_open_coach_class2_002.png",
  302. overlays = {
  303. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_002_class2_exterior_walls.png", alpha = default_wall_alpha},
  304. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_002_stripe.png", alpha = default_wall_alpha},
  305. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  306. [4] = {name = S("Side Doors"), texture = "classic_coaches_overlay_side_doors.png", alpha = default_wall_alpha},
  307. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  308. },
  309. },
  310. [3] = {
  311. base_texture = "classic_coaches_open_coach_class2_003.png",
  312. overlays = {
  313. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_003_side_walls.png", alpha = default_wall_alpha},
  314. [2] = {name = S("Stripe"), texture = "classic_coaches_overlay_003_stripe.png", alpha = default_wall_alpha},
  315. [3] = {name = S("Stripe Edges"), texture = "classic_coaches_overlay_003_stripe_edges.png"},
  316. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_1.png"},
  317. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  318. },
  319. },
  320. [4] = {
  321. base_texture = "classic_coaches_open_coach_class2_004.png",
  322. overlays = {
  323. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_004_side_walls.png", alpha = default_wall_alpha},
  324. [2] = {name = S("Window Band"), texture = "classic_coaches_overlay_004_class2_window_band.png", alpha = default_wall_alpha},
  325. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_004_decoration.png"},
  326. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  327. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  328. },
  329. },
  330. [5] = {
  331. base_texture = "classic_coaches_open_coach_class2_005.png",
  332. overlays = {
  333. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_005_class2_side_walls.png", alpha = default_wall_alpha},
  334. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  335. [3] = {name = S("Service Stripe"), texture = "classic_coaches_overlay_service_stripe.png"},
  336. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  337. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  338. },
  339. },
  340. [6] = {
  341. base_texture = "classic_coaches_open_coach_class2_006.png",
  342. overlays = {
  343. [1] = {name = S("Side Walls"), texture = "classic_coaches_overlay_006_side_walls.png", alpha = default_wall_alpha},
  344. [2] = {name = S("Roof"), texture = "classic_coaches_overlay_006_roof.png", alpha = default_roof_alpha},
  345. [3] = {name = S("Trim"), texture = "classic_coaches_overlay_006_trim.png"},
  346. [4] = {name = S("Logo"), texture = "classic_coaches_overlay_cc_logo_2.png"},
  347. [5] = {name = S("End Doors"), texture = "classic_coaches_overlay_end_doors.png", alpha = default_wall_alpha},
  348. },
  349. },
  350. [7] = {
  351. base_texture = "classic_coaches_open_coach_class2_007.png",
  352. overlays = {
  353. [1] = {name = S("Exterior Walls"), texture = "classic_coaches_overlay_007_class2_exterior_walls.png", alpha = default_wall_alpha},
  354. [2] = {name = S("Seats"), texture = "classic_coaches_overlay_seats.png", alpha = default_seat_alpha},
  355. [3] = {name = S("Decoration"), texture = "classic_coaches_overlay_007_decoration.png"},
  356. [4] = {name = S("Label"), texture = "classic_coaches_overlay_007_label.png"},
  357. [5] = {name = S("Class Number"), texture = "classic_coaches_overlay_class2_class_number.png"},
  358. [6] = {name = S("Logo and Text"), texture = "classic_coaches_overlay_007_logo_text.png"},
  359. },
  360. },
  361. },
  362. }
  363. -- Note: While all of the following predefined liveries will be registered
  364. -- for all of the wagon types defined in this mod, it is not required and
  365. -- might not be true if new wagons are added in the future.
  366. local predefined_liveries = {
  367. {
  368. name = S("CC Classic"),
  369. notes = "",
  370. livery_design = {
  371. livery_template_name = S("CC Window Band"),
  372. overlays = {
  373. [1] = {id = 1, color = "#FAF0E6"}, -- "Side Walls",
  374. [2] = {id = 2, color = "#202020"}, -- "Window Band",
  375. [3] = {id = 3, color = "#800000"}, -- "Decoration",
  376. -- [4] = {id = 4, color = "#000000"}, -- "Logo",
  377. [5] = {id = 5, color = "#FAF0E6"}, -- "Class Number",
  378. },
  379. },
  380. },
  381. {
  382. name = S("CC Classic Double Stripe"),
  383. notes = "",
  384. livery_design = {
  385. livery_template_name = S("CC Edged Stripe"),
  386. overlays = {
  387. [1] = {id = 1, color = "#FAF0E6"}, -- "Side Walls",
  388. [2] = {id = 2, color = "#FAF0E6"}, -- "Stripe",
  389. [3] = {id = 3, color = "#800000"}, -- "Stripe Edges",
  390. -- [4] = {id = 4, color = "#000000"}, -- "Logo",
  391. -- [5] = {id = 5, color = "#000000"}, -- "End Doors",
  392. },
  393. },
  394. },
  395. {
  396. name = S("CC Intercity Urban"),
  397. notes = "",
  398. livery_design = {
  399. livery_template_name = S("CC Intercity Stripe"),
  400. overlays = {
  401. [1] = {id = 1, color = "#808080"}, -- "Exterior Walls",
  402. [2] = {id = 2, color = "#006400"}, -- "Stripe",
  403. -- [3] = {id = 3, color = "#000000"}, -- "Service Stripe",
  404. [4] = {id = 4, color = "#808080"}, -- "Side Doors",
  405. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  406. },
  407. },
  408. },
  409. {
  410. name = S("CC Intercity Dark Olive"),
  411. notes = "",
  412. livery_design = {
  413. livery_template_name = S("CC Intercity Stripe"),
  414. overlays = {
  415. [1] = {id = 1, color = "#516200"}, -- "Exterior Walls",
  416. -- [2] = {id = 2, color = "#000000"}, -- "Stripe",
  417. -- [3] = {id = 3, color = "#000000"}, -- "Service Stripe",
  418. -- [4] = {id = 4, color = "#000000"}, -- "Side Doors",
  419. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  420. },
  421. },
  422. },
  423. {
  424. name = S("CC Legacy Solid Red"),
  425. notes = "",
  426. livery_design = {
  427. livery_template_name = S("CC Solid Color"),
  428. overlays = {
  429. [1] = {id = 1, color = "#800000"}, -- "Side Walls",
  430. [2] = {id = 2, color = "#2E8B57"}, -- "Seats",
  431. [3] = {id = 3, color = "#DAA520"}, -- "Service Stripe",
  432. [4] = {id = 4, color = "#FAF0E6"}, -- "Logo",
  433. -- [5] = {id = 5, color = "#FAF0E6"}, -- "Class Number",
  434. },
  435. },
  436. },
  437. {
  438. name = S("CC Modern Brown Stripe"),
  439. notes = "",
  440. livery_design = {
  441. livery_template_name = S("CC Stripe"),
  442. overlays = {
  443. -- [1] = {id = 1, color = "#000000"}, -- "Side Walls",
  444. [2] = {id = 2, color = "#8B4513"}, -- "Stripe",
  445. [3] = {id = 3, color = "#DAA520"}, -- "Stripe Divider",
  446. -- [4] = {id = 4, color = "#000000"}, -- "Side Doors",
  447. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  448. },
  449. },
  450. },
  451. {
  452. name = S("CC Slate Roof"),
  453. notes = "",
  454. livery_design = {
  455. livery_template_name = S("CC Colored Roof"),
  456. overlays = {
  457. [1] = {id = 1, color = "#708090"}, -- "Side Walls",
  458. [2] = {id = 2, color = "#2F4F4F"}, -- "Roof",
  459. [3] = {id = 3, color = "#2F4F4F"}, -- "Trim",
  460. [4] = {id = 4, color = "#2F4F4F"}, -- "Logo",
  461. [5] = {id = 5, color = "#708090"}, -- "End Doors",
  462. },
  463. },
  464. },
  465. {
  466. name = S("CC Legacy Express"),
  467. notes = "",
  468. livery_design = {
  469. livery_template_name = S("CC Express"),
  470. overlays = {
  471. [1] = {id = 1, color = "#400000"}, -- "Exterior Walls",
  472. [2] = {id = 2, color = "#000030"}, -- "Seats",
  473. -- [3] = {id = 3, color = "#000000"}, -- "Decoration",
  474. -- [4] = {id = 4, color = "#000000"}, -- "Label",
  475. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  476. -- [6] = {id = 6, color = "#000000"}, -- "Logo",
  477. },
  478. },
  479. },
  480. {
  481. name = S("No Logo Solid Green"),
  482. notes = "",
  483. livery_design = {
  484. livery_template_name = S("CC Solid Color"),
  485. overlays = {
  486. [1] = {id = 1, color = "#004000"}, -- "Side Walls",
  487. -- [2] = {id = 2, color = "#000000"}, -- "Seats",
  488. -- [3] = {id = 3, color = "#000000"}, -- "Service Stripe",
  489. [4] = {id = 4, color = "#004000"}, -- "Logo",
  490. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  491. },
  492. },
  493. },
  494. {
  495. name = S("No Logo Retro Mojo"),
  496. notes = "",
  497. livery_design = {
  498. livery_template_name = S("CC Window Band"),
  499. overlays = {
  500. [1] = {id = 1, color = "#008080"}, -- "Side Walls",
  501. [2] = {id = 2, color = "#FAF0E6"}, -- "Window Band",
  502. [3] = {id = 3, color = "#FAF0E6"}, -- "Decoration",
  503. [4] = {id = 4, color = "#008080"}, -- "Logo",
  504. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  505. },
  506. },
  507. },
  508. {
  509. name = S("No Logo Classic Express"),
  510. notes = "",
  511. livery_design = {
  512. livery_template_name = S("CC Express"),
  513. overlays = {
  514. -- [1] = {id = 1, color = "#000000"}, -- "Exterior Walls",
  515. -- [2] = {id = 2, color = "#000000"}, -- "Seats",
  516. -- [3] = {id = 3, color = "#000000"}, -- "Decoration",
  517. -- [4] = {id = 4, color = "#000000"}, -- "Label",
  518. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  519. [6] = {id = 6, color = "#000030"}, -- "Logo",
  520. },
  521. },
  522. },
  523. {
  524. name = S("No Logo Evergreen Express"),
  525. notes = "",
  526. livery_design = {
  527. livery_template_name = S("CC Express"),
  528. overlays = {
  529. [1] = {id = 1, color = "#003B00"}, -- "Exterior Walls",
  530. [2] = {id = 2, color = "#2E8B57"}, -- "Seats",
  531. [3] = {id = 3, color = "#008000"}, -- "Decoration",
  532. -- [4] = {id = 4, color = "#000000"}, -- "Label",
  533. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  534. [6] = {id = 6, color = "#003B00"}, -- "Logo",
  535. },
  536. },
  537. },
  538. {
  539. name = S("No Logo Expresso Express"),
  540. notes = "",
  541. livery_design = {
  542. livery_template_name = S("CC Express"),
  543. overlays = {
  544. [1] = {id = 1, color = "#703000"}, -- "Exterior Walls",
  545. [2] = {id = 2, color = "#D2B48C"}, -- "Seats",
  546. [3] = {id = 3, color = "#FFA500"}, -- "Decoration",
  547. [4] = {id = 4, color = "#FF8C00"}, -- "Label",
  548. -- [5] = {id = 5, color = "#000000"}, -- "Class Number",
  549. [6] = {id = 6, color = "#703000"}, -- "Logo",
  550. },
  551. },
  552. },
  553. }
  554. -- ===============================================================================================================================================
  555. if use_advtrains_livery_designer then
  556. -- Notify player if a newer version of AdvTrains Livery Tools is available or needed.
  557. if not advtrains_livery_designer.is_compatible_mod_version or
  558. not advtrains_livery_designer.is_compatible_mod_version({major = 0, minor = 8, patch = 3}) then
  559. minetest.log("info", "["..mod_name.."] An old version of AdvTrains Livery Tools was detected. Consider updating to the latest version.")
  560. -- Version 0.8.3 is not currently required so just log an informational message.
  561. end
  562. -- This function is called by the advtrains_livery_designer tool whenever the player
  563. -- activates the "Apply" button. The texture and/or the mesh could optionally be
  564. -- modified here, if needed.
  565. local function apply_wagon_livery_textures(player, wagon, textures)
  566. if wagon and textures and textures[1] then
  567. local data = advtrains.wagons[wagon.id]
  568. data.livery = textures[1]
  569. wagon:set_textures(data)
  570. end
  571. end
  572. -- Register this mod and its livery functions with the advtrains_livery_designer tool.
  573. advtrains_livery_designer.register_mod(mod_name, apply_wagon_livery_textures)
  574. -- Register this mod's wagons.
  575. for _, wagon in ipairs(wagons) do
  576. advtrains_livery_database.register_wagon(wagon.wagon_type)
  577. end
  578. -- Register this mod's livery templates with the advtrains_livery_designer tool.
  579. for wagon_type, wagon_livery_templates in pairs(livery_templates) do
  580. for livery_template_id, livery_template in pairs(wagon_livery_templates) do
  581. local livery_template_name = livery_template_names[livery_template_id].name
  582. if livery_template_name then
  583. advtrains_livery_database.add_livery_template(
  584. wagon_type,
  585. livery_template_name,
  586. {livery_template.base_texture},
  587. mod_name,
  588. (livery_template.overlays and #livery_template.overlays) or 0,
  589. "Marnack", -- Template designer
  590. "CC-BY-SA-3.0", -- Texture license
  591. "Marnack", -- Texture creator(s)
  592. livery_template_names[livery_template_id].notes
  593. )
  594. if livery_template.overlays then
  595. for overlay_id, overlay in ipairs(livery_template.overlays) do
  596. advtrains_livery_database.add_livery_template_overlay(
  597. wagon_type,
  598. livery_template_name,
  599. overlay_id,
  600. overlay.name,
  601. 1,
  602. overlay.texture,
  603. overlay.alpha
  604. )
  605. end
  606. end
  607. end
  608. end
  609. end
  610. -- Register this mod's predefined wagon liveries with the advtrains_livery_designer tool.
  611. for _, predefined_livery in pairs(predefined_liveries) do
  612. -- Each predefined livery will be defined for each wagon type. This may not be true in the future.
  613. for _, wagon in pairs(wagons) do
  614. local livery_design = predefined_livery.livery_design
  615. livery_design.wagon_type = wagon.wagon_type
  616. advtrains_livery_database.add_predefined_livery(predefined_livery.name, livery_design, mod_name, predefined_livery.notes)
  617. end
  618. end
  619. end
  620. -- ===============================================================================================================================================
  621. -- This function is used when updating the wagon's livery with the bike painter tool.
  622. -- Although the bike painter can currently only paint the first overlay, this implementation
  623. -- will handle multiple overlays if that restriction changes.
  624. local function get_wagon_texture(wagon_type, livery_template_id, overlays)
  625. -- Get and then verify that the base texture is valid
  626. local wagon_texture = livery_templates[wagon_type][livery_template_id].base_texture
  627. if not wagon_texture then
  628. return nil
  629. end
  630. -- Append overlay clause(s) to the wagon texture based on the given overlays.
  631. -- Note that any of the given overlays that are not valid for the specified
  632. -- wagon type will be ignored.
  633. if overlays and livery_templates[wagon_type][livery_template_id].overlays then
  634. for _, overlay in ipairs(overlays) do
  635. if overlay.id and overlay.color and
  636. livery_templates[wagon_type][livery_template_id].overlays[overlay.id] and
  637. livery_templates[wagon_type][livery_template_id].overlays[overlay.id].texture then
  638. local alpha = livery_templates[wagon_type][livery_template_id].overlays[overlay.id].alpha or 255
  639. if alpha < 0 then alpha = 0 end
  640. if alpha > 255 then alpha = 255 end
  641. local overlay_texture = "^("..
  642. livery_templates[wagon_type][livery_template_id].overlays[overlay.id].texture..
  643. "^[colorize:"..overlay.color..":"..alpha..
  644. ")"
  645. wagon_texture = wagon_texture..overlay_texture
  646. end
  647. end
  648. end
  649. return wagon_texture
  650. end
  651. -- The following enables the bike painter to colorize the first overlay.
  652. local function set_livery(wagon, puncher, itemstack, data)
  653. local meta = itemstack:get_meta()
  654. local color = meta:get_string("paint_color")
  655. if not color or not color:find("^#%x%x%x%x%x%x$") then
  656. return
  657. end
  658. local alpha = tonumber(meta:get_string("alpha"))
  659. if not alpha then
  660. return
  661. end
  662. -- The alpha value is used to select the livery template. Note that the alpha
  663. -- values can range from 0 to 255. Livery template ids start with 1. Livery
  664. -- template ids greater than the number of defined livery tempaltes will cause
  665. -- the painter to have no effect.
  666. local livery_template_id = alpha + 1
  667. if not livery_template_names[livery_template_id] then
  668. return
  669. end
  670. -- It is possible that a given livery template may not be defined for all
  671. -- wagon types.
  672. local wagon_type = data.type
  673. if not livery_templates[wagon_type] or
  674. not livery_templates[wagon_type][livery_template_id] or
  675. not livery_templates[wagon_type][livery_template_id].base_texture then
  676. return
  677. end
  678. -- Using the bike painter only allows for the first overlay to be
  679. -- colorized. Also, the color "#000000" is reserved and used to
  680. -- force the livery tempalte to be displayed without any color overrides.
  681. -- This is only true when using the painter.
  682. local overlays = {}
  683. if color ~= "#000000" and livery_templates[wagon_type][livery_template_id].overlays then
  684. overlays = {[1] = {id = 1, color = color}}
  685. end
  686. local wagon_texture = get_wagon_texture(wagon_type, livery_template_id, overlays)
  687. if not wagon_texture then
  688. return
  689. end
  690. data.livery = wagon_texture
  691. wagon:set_textures(data)
  692. end
  693. local function set_textures(wagon, data)
  694. if data.livery then
  695. wagon.object:set_properties({textures={data.livery}})
  696. end
  697. end
  698. local function update_livery(wagon, puncher)
  699. local itemstack = puncher:get_wielded_item()
  700. local item_name = itemstack:get_name()
  701. if use_advtrains_livery_designer and item_name == advtrains_livery_designer.tool_name then
  702. advtrains_livery_designer.activate_tool(puncher, wagon, mod_name)
  703. return true
  704. end
  705. return false
  706. end
  707. ----------------------------------------------------------------------------------------
  708. for _, wagon in pairs(wagons) do
  709. advtrains.register_wagon(wagon.wagon_type, {
  710. mesh = wagon.mesh,
  711. textures = wagon.textures,
  712. set_textures = set_textures,
  713. set_livery = set_livery,
  714. custom_may_destroy = function(wgn, puncher, time_from_last_punch, tool_capabilities, direction)
  715. return not update_livery(wgn, puncher)
  716. end,
  717. drives_on={default=true},
  718. max_speed=20,
  719. seats = {
  720. {
  721. name="1",
  722. attach_offset={x=0, y=-2, z=17},
  723. view_offset={x=0, y=-1.7, z=0},
  724. group="pass",
  725. },
  726. {
  727. name="2",
  728. attach_offset={x=0, y=-2, z=6},
  729. view_offset={x=0, y=-1.7, z=0},
  730. group="pass",
  731. },
  732. {
  733. name="3",
  734. attach_offset={x=0, y=-2, z=-6},
  735. view_offset={x=0, y=-1.7, z=0},
  736. group="pass",
  737. },
  738. {
  739. name="4",
  740. attach_offset={x=0, y=-2, z=-17},
  741. view_offset={x=0, y=-1.7, z=0},
  742. group="pass",
  743. },
  744. },
  745. seat_groups = {
  746. pass={
  747. name = "Passenger area",
  748. access_to = {},
  749. require_doors_open=true,
  750. },
  751. },
  752. doors={
  753. open={
  754. [-1]={frames={x=21, y=30}, time=1},
  755. [1]={frames={x=1, y=10}, time=1}
  756. },
  757. close={
  758. [-1]={frames={x=30, y=41}, time=1},
  759. [1]={frames={x=10, y=20}, time=1}
  760. }
  761. },
  762. door_entry={-2, 2},
  763. assign_to_seat_group = {"pass"},
  764. visual_size = {x=1, y=1},
  765. wagon_span=3,
  766. wheel_positions = {1.9, -1.9},
  767. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  768. coupler_types_front = {chain=true},
  769. coupler_types_back = {chain=true},
  770. drops={"default:steelblock"},
  771. }, wagon.name, wagon.inventory_image)
  772. minetest.register_craft({
  773. output = wagon.wagon_type,
  774. recipe = wagon.recipe,
  775. })
  776. end