components.lua 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. --[[
  2. Default components for Thirsty.
  3. These are nodes and items that "implement" the functionality
  4. from functions.lua
  5. See init.lua for license.
  6. ]]
  7. --[[
  8. Drinking containers (Tier 1)
  9. Defines a simple wooden bowl which can be used on water to fill
  10. your hydration.
  11. Optionally also augments the nodes from vessels to enable drinking
  12. on use.
  13. ]]
  14. if minetest.get_modpath("vessels") and thirsty.config.register_vessels then
  15. -- add "drinking" to vessels
  16. thirsty.augment_item_for_drinking('vessels:drinking_glass', 22)
  17. thirsty.augment_item_for_drinking('vessels:glass_bottle', 24)
  18. thirsty.augment_item_for_drinking('vessels:steel_bottle', 26)
  19. end
  20. if minetest.get_modpath("default") and thirsty.config.register_bowl then
  21. -- our own simple wooden bowl
  22. minetest.register_craftitem('thirsty:wooden_bowl', {
  23. description = "Wooden bowl",
  24. inventory_image = "thirsty_bowl_16.png",
  25. liquids_pointable = true,
  26. on_use = thirsty.on_use(nil),
  27. })
  28. minetest.register_craft({
  29. output = "thirsty:wooden_bowl",
  30. recipe = {
  31. {"group:wood", "", "group:wood"},
  32. {"", "group:wood", ""}
  33. }
  34. })
  35. end
  36. --[[
  37. Hydro containers (Tier 2)
  38. Defines canteens (currently two types, with different capacities),
  39. tools which store hydro. They use wear to show their content
  40. level in their durability bar; they do not disappear when used up.
  41. Wear corresponds to hydro level as follows:
  42. - a wear of 0 shows no durability bar -> empty (initial state)
  43. - a wear of 1 shows a full durability bar -> full
  44. - a wear of 65535 shows an empty durability bar -> empty
  45. ]]
  46. if minetest.get_modpath("default") and thirsty.config.register_canteens then
  47. minetest.register_tool('thirsty:steel_canteen', {
  48. description = 'Steel canteen',
  49. inventory_image = "thirsty_steel_canteen_16.png",
  50. liquids_pointable = true,
  51. stack_max = 1,
  52. on_use = thirsty.on_use(nil),
  53. })
  54. minetest.register_tool('thirsty:bronze_canteen', {
  55. description = 'Bronze canteen',
  56. inventory_image = "thirsty_bronze_canteen_16.png",
  57. liquids_pointable = true,
  58. stack_max = 1,
  59. on_use = thirsty.on_use(nil),
  60. })
  61. minetest.register_craft({
  62. output = "thirsty:steel_canteen",
  63. recipe = {
  64. { "group:wood", ""},
  65. { "default:steel_ingot", "default:steel_ingot"},
  66. { "default:steel_ingot", "default:steel_ingot"}
  67. }
  68. })
  69. minetest.register_craft({
  70. output = "thirsty:bronze_canteen",
  71. recipe = {
  72. { "group:wood", ""},
  73. { "default:bronze_ingot", "default:bronze_ingot"},
  74. { "default:bronze_ingot", "default:bronze_ingot"}
  75. }
  76. })
  77. end
  78. --[[
  79. Tier 3
  80. ]]
  81. if minetest.get_modpath("default") and minetest.get_modpath("bucket") and thirsty.config.register_drinking_fountain then
  82. minetest.register_node('thirsty:drinking_fountain', {
  83. description = 'Drinking fountain',
  84. drawtype = 'nodebox',
  85. tiles = {
  86. -- top, bottom, right, left, front, back
  87. 'thirsty_drinkfount_top.png',
  88. 'thirsty_drinkfount_bottom.png',
  89. 'thirsty_drinkfount_side.png',
  90. 'thirsty_drinkfount_side.png',
  91. 'thirsty_drinkfount_side.png',
  92. 'thirsty_drinkfount_side.png',
  93. },
  94. paramtype = 'light',
  95. groups = { cracky = 2 },
  96. node_box = {
  97. type = "fixed",
  98. fixed = {
  99. { -3/16, -8/16, -3/16, 3/16, 3/16, 3/16 },
  100. { -8/16, 3/16, -8/16, 8/16, 6/16, 8/16 },
  101. { -8/16, 6/16, -8/16, 8/16, 8/16, -6/16 },
  102. { -8/16, 6/16, 6/16, 8/16, 8/16, 8/16 },
  103. { -8/16, 6/16, -6/16, -6/16, 8/16, 6/16 },
  104. { 6/16, 6/16, -6/16, 8/16, 8/16, 6/16 },
  105. },
  106. },
  107. selection_box = {
  108. type = "regular",
  109. },
  110. collision_box = {
  111. type = "regular",
  112. },
  113. on_rightclick = thirsty.on_rightclick(nil),
  114. })
  115. minetest.register_craft({
  116. output = "thirsty:drinking_fountain",
  117. recipe = {
  118. { "default:stone", "bucket:bucket_water", "default:stone"},
  119. { "", "default:stone", ""},
  120. { "", "default:stone", ""}
  121. }
  122. })
  123. end
  124. --[[
  125. Tier 4+: the water fountains, plus extenders
  126. ]]
  127. if minetest.get_modpath("default") and minetest.get_modpath("bucket") and thirsty.config.register_fountains then
  128. minetest.register_node('thirsty:water_fountain', {
  129. description = 'Water fountain',
  130. tiles = {
  131. -- top, bottom, right, left, front, back
  132. 'thirsty_waterfountain_top.png',
  133. 'thirsty_waterfountain_top.png',
  134. 'thirsty_waterfountain_side.png',
  135. 'thirsty_waterfountain_side.png',
  136. 'thirsty_waterfountain_side.png',
  137. 'thirsty_waterfountain_side.png',
  138. },
  139. paramtype = 'light',
  140. groups = { cracky = 2 },
  141. })
  142. minetest.register_node('thirsty:water_extender', {
  143. description = 'Water fountain extender',
  144. tiles = {
  145. 'thirsty_waterextender_top.png',
  146. 'thirsty_waterextender_top.png',
  147. 'thirsty_waterextender_side.png',
  148. 'thirsty_waterextender_side.png',
  149. 'thirsty_waterextender_side.png',
  150. 'thirsty_waterextender_side.png',
  151. },
  152. paramtype = 'light',
  153. groups = { cracky = 2 },
  154. })
  155. minetest.register_craft({
  156. output = "thirsty:water_fountain",
  157. recipe = {
  158. { "default:copper_ingot", "bucket:bucket_water", "default:copper_ingot"},
  159. { "", "default:copper_ingot", ""},
  160. { "default:copper_ingot", "default:mese_crystal", "default:copper_ingot"}
  161. }
  162. })
  163. minetest.register_craft({
  164. output = "thirsty:water_extender",
  165. recipe = {
  166. { "", "bucket:bucket_water", ""},
  167. { "", "default:copper_ingot", ""},
  168. { "default:copper_ingot", "default:mese_crystal", "default:copper_ingot"}
  169. }
  170. })
  171. minetest.register_abm({
  172. nodenames = {'thirsty:water_fountain'},
  173. interval = 2,
  174. chance = 5,
  175. action = thirsty.fountain_abm,
  176. })
  177. end
  178. --[[
  179. Tier 5
  180. These amulets don't do much; the actual code is above, where
  181. they are searched for in player's inventories
  182. ]]
  183. if minetest.get_modpath("default") and minetest.get_modpath("bucket") and thirsty.config.register_amulets then
  184. minetest.register_craftitem('thirsty:injector', {
  185. description = 'Water injector',
  186. inventory_image = 'thirsty_injector.png',
  187. })
  188. minetest.register_craft({
  189. output = "thirsty:injector",
  190. recipe = {
  191. { "default:diamond", "default:mese_crystal", "default:diamond"},
  192. { "default:mese_crystal", "bucket:bucket_water", "default:mese_crystal"},
  193. { "default:diamond", "default:mese_crystal", "default:diamond"}
  194. }
  195. })
  196. minetest.register_craftitem('thirsty:extractor', {
  197. description = 'Water extractor',
  198. inventory_image = 'thirsty_extractor.png',
  199. })
  200. minetest.register_craft({
  201. output = "thirsty:extractor",
  202. recipe = {
  203. { "default:mese_crystal", "default:diamond", "default:mese_crystal"},
  204. { "default:diamond", "bucket:bucket_water", "default:diamond"},
  205. { "default:mese_crystal", "default:diamond", "default:mese_crystal"}
  206. }
  207. })
  208. end