init.lua 4.1 KB

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