init.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. advtrains.register_wagon("NY_lokomotive", {
  8. mesh="advtrains_engine_ny.b3d",
  9. textures = {"advtrains_engine_ny.png"},
  10. is_locomotive=true,
  11. drives_on={default=true},
  12. max_speed=15,
  13. seats = {
  14. {
  15. name=S("Driver Stand (left)"),
  16. attach_offset={x=-2.8, y=-1, z=18},
  17. view_offset={x=0, y=-3, z=10},
  18. driving_ctrl_access=true,
  19. group = "dstand",
  20. },
  21. {
  22. name="1",
  23. attach_offset={x=-4, y=-3, z=8},
  24. view_offset={x=0, y=-4, z=0},
  25. group="pass",
  26. },
  27. {
  28. name="2",
  29. attach_offset={x=4, y=-3, z=8},
  30. view_offset={x=0, y=-4, z=0},
  31. group="pass",
  32. },
  33. {
  34. name="3",
  35. attach_offset={x=-4, y=-3, z=-8},
  36. view_offset={x=0, y=-4, z=0},
  37. group="pass",
  38. },
  39. {
  40. name="4",
  41. attach_offset={x=4, y=-3, z=-8},
  42. view_offset={x=0, y=-4, z=0},
  43. group="pass",
  44. },
  45. },
  46. seat_groups = {
  47. dstand={
  48. name = "Driver Stand",
  49. access_to = {"pass"},
  50. driving_ctrl_access=true,
  51. require_doors_open=true,
  52. },
  53. pass={
  54. name = "Passenger area",
  55. access_to = {"dstand"},
  56. require_doors_open=true,
  57. },
  58. },
  59. assign_to_seat_group = {"dstand", "pass"},
  60. doors={
  61. open={
  62. [-1]={frames={x=0, y=20}, time=1},
  63. [1]={frames={x=40, y=60}, time=1}
  64. },
  65. close={
  66. [-1]={frames={x=20, y=40}, time=1},
  67. [1]={frames={x=60, y=80}, time=1}
  68. }
  69. },
  70. visual_size = {x=1, y=1},
  71. wagon_span=2.3,
  72. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  73. update_animation=function(self, velocity)
  74. if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then
  75. self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true)
  76. self.old_anim_velocity=advtrains.abs_ceil(velocity)
  77. end
  78. end,
  79. drops={"advtrains:NY_lokomotive"},
  80. custom_on_velocity_change = function(self, velocity, old_velocity, dtime)
  81. if not velocity or not old_velocity then return end
  82. if old_velocity == 0 and velocity > 0 then
  83. minetest.sound_play("ny_subway_throttle", {object = self.object})
  84. end
  85. end
  86. }, S("NY subway Engine"), "advtrains_engine_ny_inv.png")
  87. advtrains.register_wagon("ny_wagon", {
  88. mesh="advtrains_wagon_ny.b3d",
  89. textures = {"advtrains_engine_ny.png"},
  90. drives_on={default=true},
  91. max_speed=15,
  92. seats = {
  93. {
  94. name="1",
  95. attach_offset={x=-4, y=-3, z=8},
  96. view_offset={x=0, y=-4, z=0},
  97. group="pass",
  98. },
  99. {
  100. name="2",
  101. attach_offset={x=4, y=-3, z=8},
  102. view_offset={x=0, y=-4, z=0},
  103. group="pass",
  104. },
  105. {
  106. name="1a",
  107. attach_offset={x=-4, y=-3, z=0},
  108. view_offset={x=0, y=-4, z=0},
  109. group="pass",
  110. },
  111. {
  112. name="2a",
  113. attach_offset={x=4, y=-3, z=0},
  114. view_offset={x=0, y=-4, z=0},
  115. group="pass",
  116. },
  117. {
  118. name="3",
  119. attach_offset={x=-4, y=-3, z=-8},
  120. view_offset={x=0, y=-4, z=0},
  121. group="pass",
  122. },
  123. {
  124. name="4",
  125. attach_offset={x=4, y=-3, z=-8},
  126. view_offset={x=0, y=-4, z=0},
  127. group="pass",
  128. },
  129. },
  130. seat_groups = {
  131. pass={
  132. name = "Passenger area",
  133. access_to = {},
  134. require_doors_open=true,
  135. },
  136. },
  137. assign_to_seat_group = {"pass"},
  138. doors={
  139. open={
  140. [-1]={frames={x=0, y=20}, time=1},
  141. [1]={frames={x=40, y=60}, time=1}
  142. },
  143. close={
  144. [-1]={frames={x=20, y=40}, time=1},
  145. [1]={frames={x=60, y=80}, time=1}
  146. }
  147. },
  148. door_entry={-1, 1},
  149. visual_size = {x=1, y=1},
  150. wagon_span=2.3,
  151. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  152. drops={"advtrains:ny_wagon"},
  153. }, S("NY subway wagon"), "advtrains_wagon_ny_inv.png")