init.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. advtrains.register_wagon("under_s7dm", {
  26. mesh="advtrains_london_s7dm.b3d",
  27. textures = {"advtrains_london_s7dm.png"},
  28. base_texture = "advtrains_london_s7dm.png",
  29. base_livery = "advtrains_london_s7dm_livery.png",
  30. set_textures = set_textures,
  31. set_livery = set_livery,
  32. drives_on={default=true},
  33. max_speed=20,
  34. seats = {
  35. {
  36. name=S("Driver stand"),
  37. attach_offset={x=0, y=8, z=19},
  38. view_offset={x=0, y=-1, z=18},
  39. driving_ctrl_access=true,
  40. group="dstand",
  41. },
  42. {
  43. name="1",
  44. attach_offset={x=-4, y=8, z=0},
  45. view_offset={x=0, y=0, z=0},
  46. group="pass",
  47. },
  48. {
  49. name="2",
  50. attach_offset={x=4, y=8, z=0},
  51. view_offset={x=0, y=0, z=0},
  52. group="pass",
  53. },
  54. {
  55. name="3",
  56. attach_offset={x=-4, y=8, z=-8},
  57. view_offset={x=0, y=0, z=0},
  58. group="pass",
  59. },
  60. {
  61. name="4",
  62. attach_offset={x=4, y=8, z=-8},
  63. view_offset={x=0, y=0, z=0},
  64. group="pass",
  65. },
  66. },
  67. seat_groups = {
  68. dstand={
  69. name = "Driver Stand",
  70. access_to = {"pass"},
  71. require_doors_open=true,
  72. driving_ctrl_access=true,
  73. },
  74. pass={
  75. name = "Passenger area",
  76. access_to = {"dstand"},
  77. require_doors_open=true,
  78. },
  79. },
  80. assign_to_seat_group = {"dstand", "pass"},
  81. doors={
  82. open={
  83. [-1]={frames={x=0, y=20}, time=1},
  84. [1]={frames={x=40, y=60}, time=1}
  85. },
  86. close={
  87. [-1]={frames={x=20, y=40}, time=1},
  88. [1]={frames={x=60, y=80}, time=1}
  89. }
  90. },
  91. door_entry={-1},
  92. assign_to_seat_group = {"dstand", "pass"},
  93. visual_size = {x=1, y=1},
  94. wagon_span=2.5,
  95. is_locomotive=true,
  96. collisionbox = {-1.0,-0.5,-2.0, 1.0,2.5,2.0},
  97. drops={"default:steelblock 4"},
  98. }, S("underground_s7dm"), "advtrains_london_s7dm_inv.png")
  99. advtrains.register_wagon("under_s7ndm", {
  100. mesh="advtrains_london_s7ndm.b3d",
  101. textures = {"advtrains_london_s7ndm.png"},
  102. base_texture = "advtrains_london_s7ndm.png",
  103. base_livery = "advtrains_london_s7ndm_livery.png",
  104. set_textures = set_textures,
  105. set_livery = set_livery,
  106. drives_on={default=true},
  107. max_speed=20,
  108. seats = {
  109. {
  110. name="1",
  111. attach_offset={x=-4, y=8, z=8},
  112. view_offset={x=0, y=0, z=0},
  113. group="pass",
  114. },
  115. {
  116. name="2",
  117. attach_offset={x=4, y=8, z=8},
  118. view_offset={x=0, y=0, z=0},
  119. group="pass",
  120. },
  121. {
  122. name="1a",
  123. attach_offset={x=-4, y=8, z=0},
  124. view_offset={x=0, y=0, z=0},
  125. group="pass",
  126. },
  127. {
  128. name="2a",
  129. attach_offset={x=4, y=8, z=0},
  130. view_offset={x=0, y=0, z=0},
  131. group="pass",
  132. },
  133. {
  134. name="3",
  135. attach_offset={x=-4, y=8, z=-8},
  136. view_offset={x=0, y=0, z=0},
  137. group="pass",
  138. },
  139. {
  140. name="4",
  141. attach_offset={x=4, y=8, z=-8},
  142. view_offset={x=0, y=0, z=0},
  143. group="pass",
  144. },
  145. },
  146. seat_groups = {
  147. pass={
  148. name = "Passenger area",
  149. access_to = {},
  150. require_doors_open=true,
  151. },
  152. },
  153. assign_to_seat_group = {"pass"},
  154. doors={
  155. open={
  156. [-1]={frames={x=0, y=20}, time=1},
  157. [1]={frames={x=40, y=60}, time=1}
  158. },
  159. close={
  160. [-1]={frames={x=20, y=40}, time=1},
  161. [1]={frames={x=60, y=80}, time=1}
  162. }
  163. },
  164. door_entry={-1, 1},
  165. visual_size = {x=1, y=1},
  166. wagon_span=2.3,
  167. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  168. drops={"default:steelblock 4"},
  169. }, S("underground_s7ndm"), "advtrains_london_s7ndm_inv.png")