init.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. -- mod support (moreblocks/technic_worldgen)
  2. local slab_str = "stairs:slab_wood"
  3. function applyModSupport()
  4. local moreblocks_found = false
  5. local technic_worldgen = false
  6. local modnames = minetest.get_modnames()
  7. for i, name in ipairs(modnames) do
  8. -- minetest.log("[Mod] " .. name)
  9. if name == "moreblocks" then
  10. moreblocks_found = true
  11. end
  12. if name == "technic_worldgen" then
  13. technic_worldgen = true
  14. end
  15. end
  16. if moreblocks_found == true and technic_worldgen == true then
  17. minetest.log("applying patch to mod " .. minetest.get_current_modname())
  18. minetest.log("converting '" .. slab_str .. "' to 'moreblocks:slab_wood'")
  19. slab_str = "moreblocks:slab_wood"
  20. end
  21. end
  22. --applyModSupport()
  23. --Craft Recipes
  24. -- added mod-support
  25. minetest.register_craft({
  26. output = 'drinks:juice_press',
  27. recipe = {
  28. {'default:stick', 'default:steel_ingot', 'default:stick'},
  29. {'default:stick', 'bucket:bucket_empty', 'default:stick'},
  30. {slab_str, slab_str, 'vessels:drinking_glass'},
  31. }
  32. })
  33. -- added mod-support
  34. minetest.register_craft({
  35. output = 'drinks:liquid_barrel',
  36. recipe = {
  37. {'group:wood', 'group:wood', 'group:wood'},
  38. {'group:wood', 'group:wood', 'group:wood'},
  39. {slab_str, '', slab_str},
  40. }
  41. })
  42. drinks = {
  43. drink_table = {},
  44. juiceable = {},
  45. shortname = {
  46. ['jcu'] = {size = 2, name = 'vessels:drinking_glass'},
  47. ['jbo'] = {size = 4, name = 'vessels:glass_bottle'},
  48. ['jsb'] = {size = 4, name = 'vessels:steel_bottle'},
  49. ['jbu'] = {size = 16, name = 'bucket:bucket_empty'}
  50. },
  51. longname = {
  52. ['vessels:drinking_glass'] = {size = 2, name = 'jcu'},
  53. ['vessels:glass_bottle'] = {size = 4, name = 'jbo'},
  54. ['vessels:steel_bottle'] = {size = 4, name = 'jsb'},
  55. ['bucket:bucket_empty'] = {size = 16, name = 'jbu'},
  56. ['thirsty:steel_canteen'] = {size = 20, name = 'thirsty:steel_canteen'},
  57. ['thirsty:bronze_canteen'] = {size = 30, name = 'thirsty:bronze_canteen'},
  58. },
  59. }
  60. -- Honestly not needed for default, but used as an example to add support to other mods.
  61. -- Basically to use this all you need to do is add the name of the fruit to make juiceable (see line 14 for example)
  62. -- Add the new fruit to a table like I've done in line 16.
  63. -- The table should follow this scheme: internal name, Displayed name, colorize code.
  64. -- Check out the drinks.lua file for more info how how the colorize code is used.
  65. if minetest.get_modpath('default') then
  66. drinks.juiceable['apple'] = true -- Name of fruit to make juiceable.
  67. drinks.juiceable['cactus'] = true
  68. drinks.juiceable['blueberries'] = true
  69. table.insert(drinks.drink_table, {'apple', 'Apple', '#ecff56'})
  70. table.insert(drinks.drink_table, {'cactus', 'Cactus', '#96F97B'})
  71. table.insert(drinks.drink_table, {'blueberries', 'Blueberry', '#521dcb'})
  72. end
  73. if minetest.get_modpath('bushes_classic') then
  74. drinks.juiceable['blackberry'] = true
  75. drinks.juiceable['blueberry'] = true
  76. drinks.juiceable['gooseberry'] = true
  77. drinks.juiceable['raspberry'] = true
  78. drinks.juiceable['strawberry'] = true
  79. table.insert(drinks.drink_table, {'blackberry', 'Blackberry', '#581845'})
  80. table.insert(drinks.drink_table, {'blueberry', 'Blueberry', '#521dcb'})
  81. table.insert(drinks.drink_table, {'gooseberry', 'Gooseberry', '#9cf57c'})
  82. table.insert(drinks.drink_table, {'raspberry', 'Raspberry', '#C70039'})
  83. table.insert(drinks.drink_table, {'strawberry', 'Strawberry', '#ff3636'})
  84. end
  85. if minetest.get_modpath('farming_plus') then
  86. drinks.juiceable['banana'] = true
  87. drinks.juiceable['melon'] = true
  88. drinks.juiceable['lemon_item'] = true
  89. drinks.juiceable['orange_item'] = true
  90. drinks.juiceable['peach_item'] = true
  91. drinks.juiceable['rhubarb_item'] = true
  92. drinks.juiceable['tomato_item'] = true
  93. drinks.juiceable['strawberry_item'] = true
  94. drinks.juiceable['raspberry_item'] = true
  95. table.insert(drinks.drink_table, {'banana', 'Banana', '#eced9f'})
  96. table.insert(drinks.drink_table, {'lemon', 'Lemon', '#feffaa'})
  97. table.insert(drinks.drink_table, {'melon', 'Melon', '#ef4646'})
  98. table.insert(drinks.drink_table, {'orange', 'Orange', '#ffc417'})
  99. table.insert(drinks.drink_table, {'peach', 'Peach', '#f2bc1e'})
  100. table.insert(drinks.drink_table, {'rhubarb', 'Rhubarb', '#fb8461'})
  101. table.insert(drinks.drink_table, {'tomato', 'Tomato', '#d03a0e'})
  102. table.insert(drinks.drink_table, {'strawberry', 'Strawberry', '#ff3636'})
  103. table.insert(drinks.drink_table, {'raspberry', 'Raspberry', '#C70039'})
  104. end
  105. if minetest.get_modpath('crops') then
  106. drinks.juiceable['melon'] = true
  107. drinks.juiceable['melon_slice'] = true
  108. drinks.juiceable['tomato'] = true
  109. drinks.juiceable['pumpkin'] = true
  110. table.insert(drinks.drink_table, {'melon', 'Melon', '#ef4646'})
  111. table.insert(drinks.drink_table, {'tomato', 'Tomato', '#d03a0e'})
  112. table.insert(drinks.drink_table, {'pumpkin', 'Pumpkin', '#ffc04c'})
  113. end
  114. if minetest.get_modpath('farming') then
  115. drinks.juiceable['melon_8'] = true
  116. drinks.juiceable['melon_slice'] = true
  117. drinks.juiceable['tomato'] = true
  118. drinks.juiceable['carrot'] = true
  119. drinks.juiceable['cucumber'] = true
  120. drinks.juiceable['grapes'] = true
  121. drinks.juiceable['pumpkin'] = true
  122. drinks.juiceable['raspberries'] = true
  123. drinks.juiceable['rhubarb'] = true
  124. drinks.juiceable['pineapple'] = true
  125. drinks.juiceable['pineapple_ring'] = true
  126. table.insert(drinks.drink_table, {'melon', 'Melon', '#ef4646'})
  127. table.insert(drinks.drink_table, {'tomato', 'Tomato', '#990000'})
  128. table.insert(drinks.drink_table, {'carrot', 'Carrot', '#ed9121'})
  129. table.insert(drinks.drink_table, {'cucumber', 'Cucumber', '#73af59'})
  130. table.insert(drinks.drink_table, {'grapes', 'Grape', '#b20056'})
  131. table.insert(drinks.drink_table, {'pumpkin', 'Pumpkin', '#ffc04c'})
  132. table.insert(drinks.drink_table, {'raspberries', 'Raspberry', '#C70039'})
  133. table.insert(drinks.drink_table, {'rhubarb', 'Rhubarb', '#fb8461'})
  134. table.insert(drinks.drink_table, {'pineapple', 'Pineapple', '#dcd611'})
  135. end
  136. if minetest.get_modpath('fruit') then
  137. drinks.juiceable['pear'] = true
  138. drinks.juiceable['plum'] = true
  139. drinks.juiceable['peach'] = true
  140. drinks.juiceable['orange'] = true
  141. table.insert(drinks.drink_table, {'pear', 'Pear', '#ecff56'})
  142. table.insert(drinks.drink_table, {'plum', 'Plum', '#8e4585'})
  143. table.insert(drinks.drink_table, {'peach', 'Peach', '#f2bc1e'})
  144. table.insert(drinks.drink_table, {'orange', 'Orange', '#ffc417'})
  145. end
  146. if minetest.get_modpath('ethereal') then
  147. drinks.juiceable['banana'] = true
  148. drinks.juiceable['coconut'] = true
  149. drinks.juiceable['orange'] = true
  150. drinks.juiceable['strawberry'] = true
  151. table.insert(drinks.drink_table, {'banana', 'Banana', '#eced9f'})
  152. table.insert(drinks.drink_table, {'coconut', 'Coconut', '#ffffff'})
  153. table.insert(drinks.drink_table, {'orange', 'Orange', '#ffc417'})
  154. table.insert(drinks.drink_table, {'strawberry', 'Strawberry', '#ff3636'})
  155. end
  156. if minetest.get_modpath('desert_life') then
  157. drinks.juiceable['prickly_pear'] = true
  158. drinks.juiceable['barrel_cacti_1'] = true
  159. table.insert(drinks.drink_table, {'prickly', 'Cactus', '#96F97B'})
  160. table.insert(drinks.drink_table, {'barrel', 'Cactus', '#96F97B'})
  161. end
  162. -- replace craftitem to node definition
  163. -- use existing node as template (e.g. 'vessel:glass_bottle')
  164. drinks.register_item = function( name, template, def )
  165. local template_def = minetest.registered_nodes[template]
  166. if template_def then
  167. local drinks_def = table.copy(template_def)
  168. -- replace/add values
  169. for k,v in pairs(def) do
  170. if k == "groups" then
  171. -- special handling for groups: merge instead replace
  172. for g,n in pairs(v) do
  173. drinks_def[k][g] = n
  174. end
  175. else
  176. drinks_def[k]=v
  177. end
  178. end
  179. if def.inventory_image then
  180. drinks_def.wield_image = drinks_def.inventory_image
  181. drinks_def.tiles = { drinks_def.inventory_image }
  182. end
  183. minetest.register_node( name, drinks_def )
  184. end
  185. end
  186. if minetest.get_modpath('thirsty') then
  187. dofile(minetest.get_modpath('drinks')..'/drinks.lua')
  188. else
  189. dofile(minetest.get_modpath('drinks')..'/drinks2.lua')
  190. end
  191. dofile(minetest.get_modpath('drinks')..'/drink_machines.lua')
  192. dofile(minetest.get_modpath('drinks')..'/formspecs.lua')