init.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. --function copied from jre231 mod
  8. local function jr_set_livery(self, puncher, itemstack,data)
  9. -- Get color data
  10. local meta = itemstack:get_meta()
  11. local color = meta:get_string("paint_color")
  12. local alpha = tonumber(meta:get_string("alpha"))
  13. if color and color:find("^#%x%x%x%x%x%x$") then
  14. data.livery = self.base_texture.."^("..self.base_livery.."^[colorize:"..color..":"..alpha..")"
  15. self:set_textures(data)
  16. end
  17. end
  18. local function jr_set_textures(self, data)
  19. if data.livery then
  20. self.object:set_properties({
  21. textures={data.livery}
  22. })
  23. end
  24. end
  25. advtrains.register_wagon("moretrains_wagon_gondola", {
  26. mesh="moretrains_gondola.b3d",
  27. textures = {"moretrains_wagon_gondola.png"},
  28. seats = {},
  29. drives_on={default=true},
  30. max_speed=20,
  31. visual_size = {x=1, y=1},
  32. wagon_span=2.784,
  33. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  34. drops={"default:steelblock"},
  35. has_inventory = true,
  36. get_inventory_formspec = advtrains.standard_inventory_formspec,
  37. inventory_list_sizes = {
  38. box=8*3,
  39. },
  40. }, S("Gondola wagon (empty)"), "moretrains_wagon_gondola_inv.png")
  41. advtrains.register_wagon("moretrains_wagon_gondola_mese", {
  42. mesh="moretrains_gondola_mese.b3d",
  43. textures = {"moretrains_wagon_gondola.png"},
  44. seats = {},
  45. drives_on={default=true},
  46. max_speed=20,
  47. visual_size = {x=1, y=1},
  48. wagon_span=2.784,
  49. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  50. drops={"default:steelblock"},
  51. has_inventory = true,
  52. get_inventory_formspec = advtrains.standard_inventory_formspec,
  53. inventory_list_sizes = {
  54. box=8*3,
  55. },
  56. }, S("Gondola wagon with mese"), "moretrains_wagon_gondola_mese_inv.png")
  57. advtrains.register_wagon("moretrains_wagon_gondola_cobble", {
  58. mesh="moretrains_gondola_mese.b3d",
  59. textures = {"moretrains_wagon_gondola_cobble.png"},
  60. seats = {},
  61. drives_on={default=true},
  62. max_speed=20,
  63. visual_size = {x=1, y=1},
  64. wagon_span=2.784,
  65. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  66. drops={"default:steelblock"},
  67. has_inventory = true,
  68. get_inventory_formspec = advtrains.standard_inventory_formspec,
  69. inventory_list_sizes = {
  70. box=8*3,
  71. },
  72. }, S("Gondola wagon with cobble stone"), "moretrains_wagon_gondola_cobble_inv.png")
  73. advtrains.register_wagon("moretrains_wagon_gondola_toiletpaper", {
  74. mesh="moretrains_gondola_toiletpaper.b3d",
  75. textures = {"moretrains_wagon_gondola.png"},
  76. seats = {},
  77. drives_on={default=true},
  78. max_speed=20,
  79. visual_size = {x=1, y=1},
  80. wagon_span=2.784,
  81. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  82. drops={"default:steelblock"},
  83. has_inventory = true,
  84. get_inventory_formspec = advtrains.standard_inventory_formspec,
  85. inventory_list_sizes = {
  86. box=8*3,
  87. },
  88. base_texture = "moretrains_wagon_gondola.png",
  89. base_livery = "moretrains_wagon_gondola_livery.png",
  90. set_textures = jr_set_textures,
  91. set_livery = jr_set_livery,
  92. }, S("Gondola wagon with toilet paper"), "moretrains_wagon_gondola_toiletpaper_inv.png")
  93. advtrains.register_wagon("moretrains_wagon_gondola_rails", {
  94. mesh="moretrains_gondola_rails.b3d",
  95. textures = {"moretrains_wagon_gondola.png"},
  96. seats = {},
  97. drives_on={default=true},
  98. max_speed=20,
  99. visual_size = {x=1, y=1},
  100. wagon_span=2.784,
  101. collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
  102. drops={"default:steelblock"},
  103. has_inventory = true,
  104. get_inventory_formspec = advtrains.standard_inventory_formspec,
  105. inventory_list_sizes = {
  106. box=8*3,
  107. },
  108. }, S("Gondola wagon with rails"), "moretrains_wagon_gondola_rails_inv.png")
  109. minetest.register_craft({
  110. output = 'advtrains:moretrains_wagon_gondola',
  111. recipe = {
  112. {'group:wood', 'default:chest', 'group:wood'},
  113. {'advtrains:wheel', '', 'advtrains:wheel'},
  114. },
  115. })
  116. minetest.register_craft({
  117. output = "advtrains:moretrains_wagon_gondola_mese",
  118. type = "shapeless",
  119. recipe = {"advtrains:moretrains_wagon_gondola", "default:mese", "default:mese"},
  120. })
  121. minetest.register_craft({
  122. output = 'advtrains:moretrains_wagon_gondola_toiletpaper',
  123. recipe = {
  124. {'default:paper', 'default:paper', 'default:paper'},
  125. {'default:paper', 'advtrains:moretrains_wagon_gondola', 'default:paper'},
  126. {'default:paper', 'default:paper', 'default:paper'},
  127. },
  128. })
  129. minetest.register_craft({
  130. output = "advtrains:moretrains_wagon_gondola_cobble",
  131. type = "shapeless",
  132. recipe = {"advtrains:moretrains_wagon_gondola", "default:cobble", "default:cobble"},
  133. })
  134. minetest.register_craft({
  135. output = "advtrains:moretrains_wagon_gondola_rails",
  136. type = "shapeless",
  137. recipe = {"advtrains:moretrains_wagon_gondola", "advtrains:dtrack_placer", "advtrains:dtrack_placer"},
  138. })