init.lua 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. local S
  2. if minetest.get_modpath("intllib") then
  3. S = intllib.Getter()
  4. else
  5. S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
  6. end
  7. local function set_livery(self, puncher, itemstack, data)
  8. local meta = itemstack:get_meta()
  9. local color = meta:get_string("paint_color")
  10. if color and color:find("^#%x%x%x%x%x%x$") then
  11. local alpha = tonumber(meta:get_string("alpha"))
  12. if alpha == 0 then
  13. data.livery = self.base_texture
  14. else
  15. data.livery = self.base_texture.."^("..self.base_livery.."^[colorize:"..color..":255)"
  16. end
  17. self:set_textures(data)
  18. end
  19. end
  20. local function set_textures(self, data)
  21. if data.livery then
  22. self.object:set_properties({textures={data.livery}})
  23. end
  24. end
  25. local bed = 'wool:white'
  26. if minetest.get_modpath("beds") then
  27. bed = 'beds:bed'
  28. end
  29. local door = 'default:steel_ingot'
  30. if minetest.get_modpath("doors") then
  31. door = 'doors:door_steel'
  32. end
  33. advtrains.register_wagon("moretrains_intercity:corridor_coach_class2", {
  34. mesh="moretrains_intercity_corridor_coach_class2.b3d",
  35. textures = {"moretrains_intercity_corridor_coach_class2.png"},
  36. base_texture = "moretrains_intercity_corridor_coach_class2.png",
  37. base_livery = "moretrains_intercity_livery.png",
  38. set_textures = set_textures,
  39. set_livery = set_livery,
  40. drives_on={default=true},
  41. max_speed=20,
  42. seats = {
  43. {
  44. name="1",
  45. attach_offset={x=0, y=-2, z=17},
  46. view_offset={x=0, y=-1.7, z=0},
  47. group="pass",
  48. },
  49. {
  50. name="2",
  51. attach_offset={x=0, y=-2, z=6},
  52. view_offset={x=0, y=-1.7, z=0},
  53. group="pass",
  54. },
  55. {
  56. name="3",
  57. attach_offset={x=0, y=-2, z=-6},
  58. view_offset={x=0, y=-1.7, z=0},
  59. group="pass",
  60. },
  61. {
  62. name="4",
  63. attach_offset={x=0, y=-2, z=-17},
  64. view_offset={x=0, y=-1.7, z=0},
  65. group="pass",
  66. },
  67. },
  68. seat_groups = {
  69. pass={
  70. name = "Passenger area",
  71. access_to = {},
  72. require_doors_open=true,
  73. },
  74. },
  75. doors={
  76. open={
  77. [-1]={frames={x=21, y=30}, time=1},
  78. [1]={frames={x=1, y=10}, time=1}
  79. },
  80. close={
  81. [-1]={frames={x=30, y=41}, time=1},
  82. [1]={frames={x=10, y=20}, time=1}
  83. }
  84. },
  85. door_entry={-2, 2},
  86. assign_to_seat_group = {"pass"},
  87. visual_size = {x=1, y=1},
  88. wagon_span=3,
  89. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  90. drops={"default:steelblock"},
  91. }, S("Intercity Corridor Coach Class 2"), "moretrains_intercity_corridor_coach_class2_inv.png")
  92. minetest.register_craft({
  93. output = 'moretrains_intercity:corridor_coach_class2',
  94. recipe = {
  95. {'default:steelblock', 'dye:white', 'default:steelblock'},
  96. {'default:glass', 'wool:blue', door},
  97. {'advtrains:wheel', 'default:steelblock', 'advtrains:wheel'},
  98. },
  99. })
  100. advtrains.register_wagon("moretrains_intercity:corridor_coach_class1", {
  101. mesh="moretrains_intercity_corridor_coach_class1.b3d",
  102. textures = {"moretrains_intercity_corridor_coach_class1.png"},
  103. base_texture = "moretrains_intercity_corridor_coach_class1.png",
  104. base_livery = "moretrains_intercity_livery.png",
  105. set_textures = set_textures,
  106. set_livery = set_livery,
  107. drives_on={default=true},
  108. max_speed=20,
  109. seats = {
  110. {
  111. name="1",
  112. attach_offset={x=0, y=-2, z=17},
  113. view_offset={x=0, y=-1.7, z=0},
  114. group="pass",
  115. },
  116. {
  117. name="2",
  118. attach_offset={x=0, y=-2, z=6},
  119. view_offset={x=0, y=-1.7, z=0},
  120. group="pass",
  121. },
  122. {
  123. name="3",
  124. attach_offset={x=0, y=-2, z=-6},
  125. view_offset={x=0, y=-1.7, z=0},
  126. group="pass",
  127. },
  128. {
  129. name="4",
  130. attach_offset={x=0, y=-2, z=-17},
  131. view_offset={x=0, y=-1.7, z=0},
  132. group="pass",
  133. },
  134. },
  135. seat_groups = {
  136. pass={
  137. name = "Passenger area",
  138. access_to = {},
  139. require_doors_open=true,
  140. },
  141. },
  142. doors={
  143. open={
  144. [-1]={frames={x=21, y=30}, time=1},
  145. [1]={frames={x=1, y=10}, time=1}
  146. },
  147. close={
  148. [-1]={frames={x=30, y=41}, time=1},
  149. [1]={frames={x=10, y=20}, time=1}
  150. }
  151. },
  152. door_entry={-2, 2},
  153. assign_to_seat_group = {"pass"},
  154. visual_size = {x=1, y=1},
  155. wagon_span=3,
  156. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  157. drops={"default:steelblock"},
  158. }, S("Intercity Corridor Coach Class 1"), "moretrains_intercity_corridor_coach_class1_inv.png")
  159. minetest.register_craft({
  160. output = 'moretrains_intercity:corridor_coach_class1',
  161. recipe = {
  162. {'default:gold_ingot'},
  163. {'moretrains_intercity:corridor_coach_class2'},
  164. },
  165. })
  166. advtrains.register_wagon("moretrains_intercity:open_coach_class2", {
  167. mesh="moretrains_intercity_open_coach_class2.b3d",
  168. textures = {"moretrains_intercity_open_coach_class2.png"},
  169. base_texture = "moretrains_intercity_open_coach_class2.png",
  170. base_livery = "moretrains_intercity_livery.png",
  171. set_textures = set_textures,
  172. set_livery = set_livery,
  173. drives_on={default=true},
  174. max_speed=20,
  175. seats = {
  176. {
  177. name="1",
  178. attach_offset={x=-3.6, y=-2, z=19},
  179. view_offset={x=0, y=-2, z=0},
  180. group="pass",
  181. },
  182. {
  183. name="2",
  184. attach_offset={x=3.6, y=-2, z=8},
  185. view_offset={x=0, y=-2, z=0},
  186. group="pass",
  187. },
  188. {
  189. name="3",
  190. attach_offset={x=-3.6, y=-2, z=-9},
  191. view_offset={x=0, y=-2, z=0},
  192. group="pass",
  193. },
  194. {
  195. name="4",
  196. attach_offset={x=3.6, y=-2, z=-14.5},
  197. view_offset={x=0, y=-2, z=0},
  198. group="pass",
  199. },
  200. {
  201. name="5",
  202. attach_offset={x=-3.6, y=-2, z=-20},
  203. view_offset={x=0, y=-2, z=0},
  204. group="pass",
  205. },
  206. },
  207. seat_groups = {
  208. pass={
  209. name = "Passenger area",
  210. access_to = {},
  211. require_doors_open=true,
  212. },
  213. },
  214. doors={
  215. open={
  216. [-1]={frames={x=21, y=30}, time=1},
  217. [1]={frames={x=1, y=10}, time=1}
  218. },
  219. close={
  220. [-1]={frames={x=30, y=41}, time=1},
  221. [1]={frames={x=10, y=20}, time=1}
  222. }
  223. },
  224. door_entry={-2, 2},
  225. assign_to_seat_group = {"pass"},
  226. visual_size = {x=1, y=1},
  227. wagon_span=3,
  228. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  229. drops={"default:steelblock"},
  230. }, S("Intercity Open Coach Class 2"), "moretrains_intercity_open_coach_class2_inv.png")
  231. minetest.register_craft({
  232. output = 'moretrains_intercity:open_coach_class2',
  233. recipe = {
  234. {'default:steelblock', 'dye:white', 'default:steelblock'},
  235. {'default:glass', 'wool:cyan', door},
  236. {'advtrains:wheel', 'default:steelblock', 'advtrains:wheel'},
  237. },
  238. })
  239. advtrains.register_wagon("moretrains_intercity:open_coach_class1", {
  240. mesh="moretrains_intercity_open_coach_class1.b3d",
  241. textures = {"moretrains_intercity_open_coach_class1.png"},
  242. base_texture = "moretrains_intercity_open_coach_class1.png",
  243. base_livery = "moretrains_intercity_livery.png",
  244. set_textures = set_textures,
  245. set_livery = set_livery,
  246. drives_on={default=true},
  247. max_speed=20,
  248. seats = {
  249. {
  250. name="1",
  251. attach_offset={x=-3.6, y=-2, z=10},
  252. view_offset={x=0, y=-1.7, z=0},
  253. group="pass",
  254. },
  255. {
  256. name="2",
  257. attach_offset={x=-3.6, y=-2, z=-10},
  258. view_offset={x=0, y=-1.7, z=0},
  259. group="pass",
  260. },
  261. {
  262. name="3",
  263. attach_offset={x=-3.6, y=-2, z=-18},
  264. view_offset={x=0, y=-1.7, z=0},
  265. group="pass",
  266. },
  267. },
  268. seat_groups = {
  269. pass={
  270. name = "Passenger area",
  271. access_to = {},
  272. require_doors_open=true,
  273. },
  274. },
  275. doors={
  276. open={
  277. [-1]={frames={x=21, y=30}, time=1},
  278. [1]={frames={x=1, y=10}, time=1}
  279. },
  280. close={
  281. [-1]={frames={x=30, y=41}, time=1},
  282. [1]={frames={x=10, y=20}, time=1}
  283. }
  284. },
  285. door_entry={-2, 2},
  286. assign_to_seat_group = {"pass"},
  287. visual_size = {x=1, y=1},
  288. wagon_span=3,
  289. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  290. drops={"default:steelblock"},
  291. }, S("Intercity Open Coach Class 1"), "moretrains_intercity_open_coach_class1_inv.png")
  292. minetest.register_craft({
  293. output = 'moretrains_intercity:open_coach_class1',
  294. recipe = {
  295. {'default:gold_ingot'},
  296. {'moretrains_intercity:open_coach_class2'},
  297. },
  298. })