containers.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. local oil_drum_max_load = 55
  2. -- oil drum
  3. -- gas can
  4. -- lpg bottle (steel bottle + regulator)
  5. -- large storage containers
  6. -- very large storage container, possibly arbitrarily constructable like nuke reactor
  7. --[[ NEED:
  8. textures:
  9. steel drum
  10. medium lpg bottle
  11. pipes
  12. inv textures:
  13. plastic gas can
  14. small lpg bottle
  15. lpg regulator
  16. pipes
  17. sounds:
  18. metal sounds
  19. filling sounds
  20. craft items:
  21. ^ lpg regulator
  22. small lpg bottle
  23. gas can
  24. pipes
  25. register tool:
  26. gas can
  27. small lpg bottle
  28. register node:
  29. oil drum
  30. medium lpg bottle
  31. large lpg bottle sections
  32. pipes
  33. box models:
  34. medium lpg bottle
  35. large lpg bottle sections
  36. oil drum
  37. pipes
  38. ]]
  39. bitumen.containers = {}
  40. bitumen.containers.max_fill = {
  41. {oil_drum = 200},
  42. {gas_can = 20},
  43. }
  44. -- gas can is a tool
  45. minetest.register_tool("bitumen:gas_can", {
  46. description = "Gas Can",
  47. inventory_image = "bitumen_gas_can.png",
  48. stack_max = 1,
  49. -- liquids_pointable = true,
  50. on_use = function(itemstack, user, pointed_thing)
  51. if pointed_thing.type ~= "node" then
  52. return end
  53. n = minetest.env:get_node(pointed_thing)
  54. -- only operate on oil givers
  55. if n.group.oilpipe_give ~= 1 then
  56. return end
  57. item=itemstack:to_table()
  58. local fill=nil
  59. if item["metadata"]=="" then fill=0
  60. else fill=tonumber(item["metadata"])
  61. end
  62. -- can is empty
  63. if fill <= 0 then return end
  64. -- if n.name == "default:water_source" then
  65. -- if load+1<17 then
  66. -- minetest.env:add_node(pointed_thing.under, {name="air"})
  67. -- load=load+1;
  68. -- item["metadata"]=tostring(load)
  69. -- technic.set_RE_wear(item,load,water_can_max_load)
  70. -- itemstack:replace(item)
  71. -- end
  72. -- return itemstack
  73. -- end
  74. item=itemstack:to_table()
  75. if load==0 then return end
  76. if n.name == "default:water_flowing" then
  77. minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
  78. load=load-1;
  79. item["metadata"]=tostring(load)
  80. technic.set_RE_wear(item,load,water_can_max_load)
  81. itemstack:replace(item)
  82. return itemstack
  83. end
  84. n = minetest.env:get_node(pointed_thing.above)
  85. if n.name == "air" then
  86. minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
  87. load=load-1;
  88. item["metadata"]=tostring(load)
  89. technic.set_RE_wear(item,load,water_can_max_load)
  90. itemstack:replace(item)
  91. return itemstack
  92. end
  93. end,
  94. })
  95. minetest.register_node(":bitumen:oil_drum", {
  96. description = "Oil Drum",
  97. tiles = {"bitumen_drum_top.png", "bitumen_drum_bottom.png", "bitumen_drum_side.png",
  98. "bitumen_drum_side.png", "bitumen_drum_side.png", "bitumen_drum_side.png"},
  99. paramtype2 = "facedir",
  100. -- inventory_image = "bitumen_oil_drum.png",
  101. groups = {
  102. cracky=2,
  103. oddly_breakable_by_hand=2,
  104. oilpipe=1,
  105. oilpipe_receive=1,
  106. oil_container = 1
  107. },
  108. paramtype = "light",
  109. drawtype = "nodebox",
  110. node_box = {
  111. type = "fixed",
  112. fixed = {
  113. --11.25
  114. {-0.49, -0.5, -0.10, 0.49, 0.5, 0.10},
  115. {-0.10, -0.5, -0.49, 0.10, 0.5, 0.49},
  116. --22.5
  117. {-0.46, -0.5, -0.19, 0.46, 0.5, 0.19},
  118. {-0.19, -0.5, -0.46, 0.19, 0.5, 0.46},
  119. -- 33.75
  120. {-0.416, -0.5, -0.28, 0.416, 0.5, 0.28},
  121. {-0.28, -0.5, -0.416, 0.28, 0.5, 0.416},
  122. --45
  123. {-0.35, -0.5, -0.35, 0.35, 0.5, 0.35},
  124. },
  125. },
  126. selection_box = {
  127. type = "fixed",
  128. fixed = {
  129. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  130. },
  131. },
  132. -- stack_max = 99,
  133. -- tube = tubes_properties,legacy_facedir_simple = true,
  134. sounds = default.node_sound_wood_defaults(),
  135. on_construct = function(pos)
  136. local meta = minetest.env:get_meta(pos)
  137. meta:set_string("infotext", "Oil Drum (Empty)")
  138. meta:set_string("oiltype", "Empty")
  139. meta:set_int("filllevel", "0")
  140. -- meta:set_string("fillmax", "200") -- 55 US Gal, 44 Imp. Gal, 200 L
  141. local inv = meta:get_inventory()
  142. inv:set_size("main", 10*4)
  143. end,
  144. can_dig = function(pos, player)
  145. local meta = minetest.env:get_meta(pos)
  146. if meta:get_int('filllevel') > 0 then
  147. return false
  148. end
  149. return true
  150. end,
  151. })
  152. -- minetest.register_tool("bitumen:oil_drum", {
  153. -- description = "55 Gallon Oil Drum",
  154. -- inventory_image = "technic_battery.png",
  155. -- tool_capabilities = {
  156. -- charge = 0,
  157. -- max_drop_level = 0,
  158. -- groupcaps = {
  159. -- fleshy = {times={}, uses=10000, maxlevel=0}
  160. -- }
  161. -- }
  162. -- })