init.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. wine = {}
  2. -- Intllib
  3. local S
  4. if minetest.get_modpath("intllib") then
  5. S = intllib.Getter()
  6. else
  7. S = function(s, a, ...)
  8. if a == nil then
  9. return s
  10. end
  11. a = {a, ...}
  12. return s:gsub("(@?)@(%(?)(%d+)(%)?)",
  13. function(e, o, n, c)
  14. if e == ""then
  15. return a[tonumber(n)] .. (o == "" and c or "")
  16. else
  17. return "@" .. o .. n .. c
  18. end
  19. end)
  20. end
  21. end
  22. local ferment=""
  23. if minetest.get_modpath("mcl_core") then
  24. ferment = {
  25. {"farming:grapes", "wine:glass_wine"},
  26. {"farming:barley", "wine:glass_beer"},
  27. {"mobs:honey", "wine:glass_mead"},
  28. {"mcl_core:apple", "wine:glass_cider"},
  29. {"mcl_core:paper", "wine:glass_rum"},
  30. {"wine:blue_agave", "wine:glass_tequila"},
  31. {"farming:wheat", "wine:glass_wheat_beer"},
  32. {"farming:rice", "wine:glass_sake"},
  33. {"farming:corn", "wine:glass_bourbon"},
  34. {"farming:baked_potato", "wine:glass_vodka"}
  35. }
  36. else
  37. ferment = {
  38. {"farming:grapes", "wine:glass_wine"},
  39. {"farming:barley", "wine:glass_beer"},
  40. {"mobs:honey", "wine:glass_mead"},
  41. {"default:apple", "wine:glass_cider"},
  42. {"default:papyrus", "wine:glass_rum"},
  43. {"wine:blue_agave", "wine:glass_tequila"},
  44. {"farming:wheat", "wine:glass_wheat_beer"},
  45. {"farming:rice", "wine:glass_sake"},
  46. {"farming:corn", "wine:glass_bourbon"},
  47. {"farming:baked_potato", "wine:glass_vodka"}
  48. }
  49. end
  50. function wine:add_item(list)
  51. for n = 1, #list do
  52. table.insert(ferment, list[n])
  53. end
  54. end
  55. local efectsound=""
  56. local efectsound2=""
  57. if minetest.get_modpath("mcl_core") then
  58. efectsound=mcl_sounds.node_sound_glass_defaults()
  59. efectsound2=mcl_sounds.node_sound_defaults()
  60. else
  61. efectsound=default.node_sound_glass_defaults()
  62. efectsound2=default.node_sound_defaults()
  63. end
  64. -- glass of wine
  65. minetest.register_node("wine:glass_wine", {
  66. description = S("Glass of Wine"),
  67. drawtype = "plantlike",
  68. visual_scale = 0.8,
  69. tiles = {"wine_glass.png"},
  70. inventory_image = "wine_glass.png",
  71. wield_image = "wine_glass.png",
  72. paramtype = "light",
  73. is_ground_content = false,
  74. sunlight_propagates = true,
  75. walkable = false,
  76. selection_box = {
  77. type = "fixed",
  78. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  79. },
  80. groups = {
  81. food_wine = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  82. alcohol = 1
  83. },
  84. sounds = efectsound,
  85. on_use = minetest.item_eat(2),
  86. })
  87. -- bottle of wine
  88. minetest.register_node("wine:bottle_wine", {
  89. description = S("Bottle of Wine"),
  90. drawtype = "plantlike",
  91. tiles = {"wine_bottle.png"},
  92. inventory_image = "wine_bottle.png",
  93. paramtype = "light",
  94. sunlight_propagates = true,
  95. walkable = false,
  96. selection_box = {
  97. type = "fixed",
  98. fixed = { -0.15, -0.5, -0.15, 0.15, 0.25, 0.15 }
  99. },
  100. groups = {dig_immediate = 3, attached_node = 1, vessel = 1},
  101. sounds = efectsound2,
  102. })
  103. minetest.register_craft({
  104. output = "wine:bottle_wine",
  105. recipe = {
  106. {"wine:glass_wine", "wine:glass_wine", "wine:glass_wine"},
  107. {"wine:glass_wine", "wine:glass_wine", "wine:glass_wine"},
  108. {"wine:glass_wine", "wine:glass_wine", "wine:glass_wine"},
  109. },
  110. })
  111. minetest.register_craft({
  112. type = "shapeless",
  113. output = "wine:glass_wine 9",
  114. recipe = {"wine:bottle_wine"},
  115. })
  116. -- glass of rum
  117. minetest.register_node("wine:glass_rum", {
  118. description = "Rum",
  119. drawtype = "plantlike",
  120. visual_scale = 0.8,
  121. tiles = {"wine_rum_glass.png"},
  122. inventory_image = "wine_rum_glass.png",
  123. wield_image = "wine_rum_glass.png",
  124. paramtype = "light",
  125. is_ground_content = false,
  126. sunlight_propagates = true,
  127. walkable = false,
  128. selection_box = {
  129. type = "fixed",
  130. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  131. },
  132. groups = {
  133. food_rum = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  134. alcohol = 1
  135. },
  136. sounds = efectsound,
  137. on_use = minetest.item_eat(2),
  138. })
  139. -- bottle of rum
  140. minetest.register_node("wine:bottle_rum", {
  141. description = "Bottle of Rum",
  142. drawtype = "plantlike",
  143. tiles = {"wine_rum_bottle.png"},
  144. inventory_image = "wine_rum_bottle.png",
  145. paramtype = "light",
  146. sunlight_propagates = true,
  147. walkable = false,
  148. selection_box = {
  149. type = "fixed",
  150. fixed = { -0.15, -0.5, -0.15, 0.15, 0.25, 0.15 }
  151. },
  152. groups = {dig_immediate = 3, attached_node = 1, vessel = 1},
  153. sounds = efectsound2,
  154. })
  155. minetest.register_craft({
  156. output = "wine:bottle_rum",
  157. recipe = {
  158. {"wine:glass_rum", "wine:glass_rum", "wine:glass_rum"},
  159. {"wine:glass_rum", "wine:glass_rum", "wine:glass_rum"},
  160. {"wine:glass_rum", "wine:glass_rum", "wine:glass_rum"},
  161. },
  162. })
  163. minetest.register_craft({
  164. type = "shapeless",
  165. output = "wine:glass_rum 9",
  166. recipe = {"wine:bottle_rum"},
  167. })
  168. -- glass of weizen, or wheat beer
  169. -- The image is a lighter version of the one from RiverKpocc @ deviantart.com
  170. minetest.register_node("wine:glass_wheat_beer", {
  171. description = S("Wheat Beer"),
  172. drawtype = "torchlike", --"plantlike",
  173. visual_scale = 0.8,
  174. tiles = {"wine_wheat_beer_glass.png"},
  175. inventory_image = "wine_wheat_beer_glass.png",
  176. wield_image = "wine_wheat_beer_glass.png",
  177. paramtype = "light",
  178. is_ground_content = false,
  179. sunlight_propagates = true,
  180. walkable = false,
  181. selection_box = {
  182. type = "fixed",
  183. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  184. },
  185. groups = {
  186. food_beer = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  187. alcohol = 1
  188. },
  189. sounds = efectsound,
  190. on_use = minetest.item_eat(2),
  191. })
  192. -- glass of beer (thanks to RiverKpocc @ deviantart.com for image)
  193. minetest.register_node("wine:glass_beer", {
  194. description = S("Beer"),
  195. drawtype = "torchlike", --"plantlike",
  196. visual_scale = 0.8,
  197. tiles = {"wine_beer_glass.png"},
  198. inventory_image = "wine_beer_glass.png",
  199. wield_image = "wine_beer_glass.png",
  200. paramtype = "light",
  201. is_ground_content = false,
  202. sunlight_propagates = true,
  203. walkable = false,
  204. selection_box = {
  205. type = "fixed",
  206. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  207. },
  208. groups = {
  209. food_beer = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  210. alcohol = 1
  211. },
  212. sounds = efectsound,
  213. on_use = minetest.item_eat(2),
  214. })
  215. -- glass of honey mead
  216. minetest.register_node("wine:glass_mead", {
  217. description = S("Honey-Mead"),
  218. drawtype = "plantlike",
  219. visual_scale = 0.8,
  220. tiles = {"wine_mead_glass.png"},
  221. inventory_image = "wine_mead_glass.png",
  222. wield_image = "wine_mead_glass.png",
  223. paramtype = "light",
  224. is_ground_content = false,
  225. sunlight_propagates = true,
  226. walkable = false,
  227. selection_box = {
  228. type = "fixed",
  229. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  230. },
  231. groups = {
  232. food_mead = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  233. alcohol = 1
  234. },
  235. sounds = efectsound,
  236. on_use = minetest.item_eat(4),
  237. })
  238. -- glass of apple cider
  239. minetest.register_node("wine:glass_cider", {
  240. description = S("Apple Cider"),
  241. drawtype = "plantlike",
  242. visual_scale = 0.8,
  243. tiles = {"wine_cider_glass.png"},
  244. inventory_image = "wine_cider_glass.png",
  245. wield_image = "wine_cider_glass.png",
  246. paramtype = "light",
  247. is_ground_content = false,
  248. sunlight_propagates = true,
  249. walkable = false,
  250. selection_box = {
  251. type = "fixed",
  252. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  253. },
  254. groups = {
  255. food_cider = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  256. alcohol = 1
  257. },
  258. sounds = efectsound,
  259. on_use = minetest.item_eat(2),
  260. })
  261. -- glass of tequila
  262. minetest.register_node("wine:glass_tequila", {
  263. description = "Tequila",
  264. drawtype = "plantlike",
  265. visual_scale = 0.8,
  266. tiles = {"wine_tequila.png"},
  267. inventory_image = "wine_tequila.png",
  268. wield_image = "wine_tequila.png",
  269. paramtype = "light",
  270. is_ground_content = false,
  271. sunlight_propagates = true,
  272. walkable = false,
  273. selection_box = {
  274. type = "fixed",
  275. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  276. },
  277. groups = {
  278. food_tequila = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  279. alcohol = 1
  280. },
  281. sounds = efectsound,
  282. on_use = minetest.item_eat(2),
  283. })
  284. -- bottle of tequila
  285. minetest.register_node("wine:bottle_tequila", {
  286. description = "Bottle of Tequila",
  287. drawtype = "plantlike",
  288. tiles = {"wine_tequila_bottle.png"},
  289. inventory_image = "wine_tequila_bottle.png",
  290. paramtype = "light",
  291. sunlight_propagates = true,
  292. walkable = false,
  293. selection_box = {
  294. type = "fixed",
  295. fixed = { -0.15, -0.5, -0.15, 0.15, 0.25, 0.15 }
  296. },
  297. groups = {dig_immediate = 3, attached_node = 1, vessel = 1},
  298. sounds = efectsound2,
  299. })
  300. minetest.register_craft({
  301. output = "wine:bottle_tequila",
  302. recipe = {
  303. {"wine:glass_tequila", "wine:glass_tequila", "wine:glass_tequila"},
  304. {"wine:glass_tequila", "wine:glass_tequila", "wine:glass_tequila"},
  305. {"wine:glass_tequila", "wine:glass_tequila", "wine:glass_tequila"},
  306. },
  307. })
  308. minetest.register_craft({
  309. type = "shapeless",
  310. output = "wine:glass_tequila 9",
  311. recipe = {"wine:bottle_tequila"},
  312. })
  313. -- glass of sake
  314. minetest.register_node("wine:glass_sake", {
  315. description = "Sake",
  316. drawtype = "plantlike",
  317. visual_scale = 0.8,
  318. tiles = {"wine_sake.png"},
  319. inventory_image = "wine_sake.png",
  320. wield_image = "wine_sake.png",
  321. paramtype = "light",
  322. is_ground_content = false,
  323. sunlight_propagates = true,
  324. walkable = false,
  325. selection_box = {
  326. type = "fixed",
  327. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  328. },
  329. groups = {
  330. food_sake = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  331. alcohol = 1
  332. },
  333. sounds = efectsound,
  334. on_use = minetest.item_eat(2),
  335. })
  336. -- glass of bourbon
  337. minetest.register_node("wine:glass_bourbon", {
  338. description = S("Glass of Bourbon"),
  339. drawtype = "plantlike",
  340. visual_scale = 0.8,
  341. tiles = {"wine_bourbon_glass.png"},
  342. inventory_image = "wine_bourbon_glass.png",
  343. wield_image = "wine_bourbon_glass.png",
  344. paramtype = "light",
  345. is_ground_content = false,
  346. sunlight_propagates = true,
  347. walkable = false,
  348. selection_box = {
  349. type = "fixed",
  350. fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
  351. },
  352. groups = {
  353. food_wine = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  354. alcohol = 1
  355. },
  356. sounds = efectsound,
  357. on_use = minetest.item_eat(2),
  358. })
  359. -- bottle of bourbon
  360. minetest.register_node("wine:bottle_bourbon", {
  361. description = S("Bottle of Bourbon"),
  362. drawtype = "plantlike",
  363. tiles = {"wine_bourbon_bottle.png"},
  364. inventory_image = "wine_bourbon_bottle.png",
  365. paramtype = "light",
  366. sunlight_propagates = true,
  367. walkable = false,
  368. selection_box = {
  369. type = "fixed",
  370. fixed = { -0.15, -0.5, -0.15, 0.15, 0.25, 0.15 }
  371. },
  372. groups = {dig_immediate = 3, attached_node = 1, vessel = 1},
  373. sounds = efectsound2,
  374. })
  375. minetest.register_craft({
  376. output = "wine:bottle_bourbon",
  377. recipe = {
  378. {"wine:glass_bourbon", "wine:glass_bourbon", "wine:glass_bourbon"},
  379. {"wine:glass_bourbon", "wine:glass_bourbon", "wine:glass_bourbon"},
  380. {"wine:glass_bourbon", "wine:glass_bourbon", "wine:glass_bourbon"},
  381. },
  382. })
  383. minetest.register_craft({
  384. type = "shapeless",
  385. output = "wine:glass_bourbon 9",
  386. recipe = {"wine:bottle_bourbon"},
  387. })
  388. -- glass of vodka
  389. minetest.register_node("wine:glass_vodka", {
  390. description = S("Glass of Vodka"),
  391. drawtype = "plantlike",
  392. visual_scale = 0.8,
  393. tiles = {"wine_vodka_glass.png"},
  394. inventory_image = "wine_vodka_glass.png",
  395. wield_image = "wine_vodka_glass.png",
  396. paramtype = "light",
  397. is_ground_content = false,
  398. sunlight_propagates = true,
  399. walkable = false,
  400. selection_box = {
  401. type = "fixed",
  402. fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
  403. },
  404. groups = {
  405. food_wine = 1, vessel = 1, dig_immediate = 3, attached_node = 1,
  406. alcohol = 1
  407. },
  408. sounds = efectsound,
  409. on_use = minetest.item_eat(2),
  410. })
  411. -- bottle of vodka
  412. minetest.register_node("wine:bottle_vodka", {
  413. description = S("Bottle of Vodka"),
  414. drawtype = "plantlike",
  415. tiles = {"wine_vodka_bottle.png"},
  416. inventory_image = "wine_vodka_bottle.png",
  417. paramtype = "light",
  418. sunlight_propagates = true,
  419. walkable = false,
  420. selection_box = {
  421. type = "fixed",
  422. fixed = { -0.15, -0.5, -0.15, 0.15, 0.25, 0.15 }
  423. },
  424. groups = {dig_immediate = 3, attached_node = 1, vessel = 1},
  425. sounds = efectsound2,
  426. })
  427. minetest.register_craft({
  428. output = "wine:bottle_vodka",
  429. recipe = {
  430. {"wine:glass_vodka", "wine:glass_vodka", "wine:glass_vodka"},
  431. {"wine:glass_vodka", "wine:glass_vodka", "wine:glass_vodka"},
  432. {"wine:glass_vodka", "wine:glass_vodka", "wine:glass_vodka"},
  433. },
  434. })
  435. minetest.register_craft({
  436. type = "shapeless",
  437. output = "wine:glass_vodka 9",
  438. recipe = {"wine:bottle_vodka"},
  439. })
  440. -- blue agave
  441. minetest.register_node("wine:blue_agave", {
  442. description = "Blue Agave",
  443. drawtype = "plantlike",
  444. visual_scale = 0.8,
  445. tiles = {"wine_blue_agave.png"},
  446. inventory_image = "wine_blue_agave.png",
  447. wield_image = "wine_blue_agave.png",
  448. paramtype = "light",
  449. is_ground_content = false,
  450. sunlight_propagates = true,
  451. walkable = false,
  452. selection_box = {
  453. type = "fixed",
  454. fixed = {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}
  455. },
  456. groups = {snappy = 3, attached_node = 1, plant = 1},
  457. --sounds = default.node_sound_leaves_defaults(),
  458. on_construct = function(pos)
  459. local timer = minetest.get_node_timer(pos)
  460. timer:start(17)
  461. end,
  462. on_timer = function(pos)
  463. local light = minetest.get_node_light(pos)
  464. if not light or light < 13 or math.random() > 1/76 then
  465. return true -- go to next iteration
  466. end
  467. local n = minetest.find_nodes_in_area_under_air(
  468. {x = pos.x + 2, y = pos.y + 1, z = pos.z + 2},
  469. {x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
  470. {"wine:blue_agave"})
  471. -- too crowded, we'll wait for another iteration
  472. if #n > 2 then
  473. return true
  474. end
  475. -- find desert sand with air above (grow across and down only)
  476. n = minetest.find_nodes_in_area_under_air(
  477. {x = pos.x + 1, y = pos.y - 1, z = pos.z + 1},
  478. {x = pos.x - 1, y = pos.y - 2, z = pos.z - 1},
  479. {"default:desert_sand"})
  480. -- place blue agave
  481. if n and #n > 0 then
  482. local new_pos = n[math.random(#n)]
  483. new_pos.y = new_pos.y + 1
  484. minetest.set_node(new_pos, {name = "wine:blue_agave"})
  485. end
  486. return true
  487. end
  488. })
  489. minetest.register_craft( {
  490. type = "shapeless",
  491. output = "dye:cyan 4",
  492. recipe = {"wine:blue_agave"}
  493. })
  494. minetest.register_decoration({
  495. deco_type = "simple",
  496. place_on = {"default:desert_sand"},
  497. sidelen = 16,
  498. fill_ratio = 0.001,
  499. biomes = {"desert"},
  500. decoration = {"wine:blue_agave"},
  501. y_min = 15,
  502. y_max = 50,
  503. spawn_by = "default:desert_sand",
  504. num_spawn_by = 6,
  505. })
  506. if minetest.get_modpath("bonemeal") then
  507. bonemeal:add_deco({
  508. {"default:desert_sand", {}, {"default:dry_shrub", "wine:blue_agave", "", ""} }
  509. })
  510. end
  511. -- Wine barrel
  512. winebarrel_formspec = "size[8,9]"
  513. --.. default.gui_bg..default.gui_bg_img..default.gui_slots
  514. .. "list[current_name;src;2,1;1,1;]"
  515. .. "list[current_name;dst;5,1;1,1;]"
  516. .. "list[current_player;main;0,5;8,4;]"
  517. .. "listring[current_name;dst]"
  518. .. "listring[current_player;main]"
  519. .. "listring[current_name;src]"
  520. .. "listring[current_player;main]"
  521. .. "image[3.5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"
  522. minetest.register_node("wine:wine_barrel", {
  523. description = S("Fermenting Barrel"),
  524. tiles = {"wine_barrel.png" },
  525. drawtype = "mesh",
  526. mesh = "wine_barrel.obj",
  527. paramtype = "light",
  528. paramtype2 = "facedir",
  529. groups = {
  530. choppy = 2, oddly_breakable_by_hand = 1, flammable = 2,
  531. tubedevice = 1, tubedevice_receiver = 1
  532. },
  533. legacy_facedir_simple = true,
  534. on_place = minetest.rotate_node,
  535. on_construct = function(pos)
  536. local meta = minetest.get_meta(pos)
  537. meta:set_string("formspec", winebarrel_formspec)
  538. meta:set_string("infotext", S("Fermenting Barrel"))
  539. meta:set_float("status", 0.0)
  540. local inv = meta:get_inventory()
  541. inv:set_size("src", 1)
  542. inv:set_size("dst", 1)
  543. end,
  544. can_dig = function(pos,player)
  545. local meta = minetest.get_meta(pos)
  546. local inv = meta:get_inventory()
  547. if not inv:is_empty("dst")
  548. or not inv:is_empty("src") then
  549. return false
  550. end
  551. return true
  552. end,
  553. allow_metadata_inventory_take = function(pos, listname, index, stack, player)
  554. if minetest.is_protected(pos, player:get_player_name()) then
  555. return 0
  556. end
  557. return stack:get_count()
  558. end,
  559. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  560. if minetest.is_protected(pos, player:get_player_name()) then
  561. return 0
  562. end
  563. local meta = minetest.get_meta(pos)
  564. local inv = meta:get_inventory()
  565. if listname == "src" then
  566. return stack:get_count()
  567. elseif listname == "dst" then
  568. return 0
  569. end
  570. end,
  571. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  572. if minetest.is_protected(pos, player:get_player_name()) then
  573. return 0
  574. end
  575. local meta = minetest.get_meta(pos)
  576. local inv = meta:get_inventory()
  577. local stack = inv:get_stack(from_list, from_index)
  578. if to_list == "src" then
  579. return count
  580. elseif to_list == "dst" then
  581. return 0
  582. end
  583. end,
  584. on_metadata_inventory_put = function(pos)
  585. local timer = minetest.get_node_timer(pos)
  586. timer:start(5)
  587. end,
  588. tube = (function() if minetest.get_modpath("pipeworks") then return {
  589. -- using a different stack from defaut when inserting
  590. insert_object = function(pos, node, stack, direction)
  591. local meta = minetest.get_meta(pos)
  592. local inv = meta:get_inventory()
  593. local timer = minetest.get_node_timer(pos)
  594. if not timer:is_started() then
  595. timer:start(5)
  596. end
  597. return inv:add_item("src", stack)
  598. end,
  599. can_insert = function(pos,node,stack,direction)
  600. local meta = minetest.get_meta(pos)
  601. local inv = meta:get_inventory()
  602. return inv:room_for_item("src", stack)
  603. end,
  604. -- the default stack, from which objects will be taken
  605. input_inventory = "dst",
  606. connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
  607. } end end)(),
  608. on_timer = function(pos)
  609. local meta = minetest.get_meta(pos) ; if not meta then return end
  610. local inv = meta:get_inventory()
  611. -- is barrel empty?
  612. if not inv or inv:is_empty("src") then
  613. meta:set_float("status", 0.0)
  614. meta:set_string("infotext", S("Fermenting Barrel"))
  615. return false
  616. end
  617. -- does it contain any of the source items on the list?
  618. local has_item
  619. for n = 1, #ferment do
  620. if inv:contains_item("src", ItemStack(ferment[n][1])) then
  621. has_item = n
  622. break
  623. end
  624. end
  625. if not has_item then
  626. return false
  627. end
  628. -- is there room for additional fermentation?
  629. if not inv:room_for_item("dst", ferment[has_item][2]) then
  630. meta:set_string("infotext", S("Fermenting Barrel (FULL)"))
  631. return true
  632. end
  633. local status = meta:get_float("status")
  634. -- fermenting (change status)
  635. if status < 100 then
  636. meta:set_string("infotext", S("Fermenting Barrel (@1% Done)", status))
  637. meta:set_float("status", status + 5)
  638. else
  639. inv:remove_item("src", ferment[has_item][1])
  640. inv:add_item("dst", ferment[has_item][2])
  641. meta:set_float("status", 0,0)
  642. end
  643. if inv:is_empty("src") then
  644. meta:set_float("status", 0.0)
  645. meta:set_string("infotext", S("Fermenting Barrel"))
  646. end
  647. return true
  648. end,
  649. })
  650. if minetest.get_modpath("mcl_core") then
  651. minetest.register_craft({
  652. output = "wine:wine_barrel",
  653. recipe = {
  654. {"group:wood", "group:wood", "group:wood"},
  655. {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
  656. {"group:wood", "group:wood", "group:wood"},
  657. },
  658. })
  659. else
  660. minetest.register_craft({
  661. output = "wine:wine_barrel",
  662. recipe = {
  663. {"group:wood", "group:wood", "group:wood"},
  664. {"default:steel_ingot", "", "default:steel_ingot"},
  665. {"group:wood", "group:wood", "group:wood"},
  666. },
  667. })
  668. end
  669. -- LBMs to start timers on existing, ABM-driven nodes
  670. minetest.register_lbm({
  671. name = "wine:barrel_timer_init",
  672. nodenames = {"wine:wine_barrel"},
  673. run_at_every_load = false,
  674. action = function(pos)
  675. local t = minetest.get_node_timer(pos)
  676. t:start(5)
  677. end,
  678. })
  679. minetest.register_lbm({
  680. name = "wine:agave_timer_init",
  681. nodenames = {"wine:blue_agave"},
  682. run_at_every_load = false,
  683. action = function(pos)
  684. local t = minetest.get_node_timer(pos)
  685. t:start(17)
  686. end,
  687. })
  688. -- add lucky blocks
  689. if minetest.get_modpath("lucky_block") then
  690. lucky_block:add_blocks({
  691. {"dro", {"wine:glass_wine"}, 5},
  692. {"dro", {"wine:glass_beer"}, 5},
  693. {"dro", {"wine:glass_wheat_beer"}, 5},
  694. {"dro", {"wine:glass_mead"}, 5},
  695. {"dro", {"wine:glass_cider"}, 5},
  696. {"dro", {"wine:glass_rum"}, 5},
  697. {"dro", {"wine:glass_tequila"}, 5},
  698. {"dro", {"wine:glass_bourbon"}, 5},
  699. {"dro", {"wine:glass_vodka"}, 5},
  700. {"dro", {"wine:wine_barrel"}, 1},
  701. {"tel", 5, 1},
  702. {"nod", "default:chest", 0, {
  703. {name = "wine:bottle_wine", max = 1},
  704. {name = "wine:bottle_tequila", max = 1},
  705. {name = "wine:bottle_rum", max = 1},
  706. {name = "wine:bottle_bourbon", max = 1},
  707. {name = "wine:bottle_vodka", max = 1},
  708. {name = "wine:wine_barrel", max = 1},
  709. {name = "wine:blue_agave", max = 4}}},
  710. })
  711. end
  712. print (S("[MOD] Wine loaded"))