drinks.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. --Parse Table
  2. for i in ipairs (drinks.drink_table) do
  3. local desc = drinks.drink_table[i][1]
  4. local craft = drinks.drink_table[i][2]
  5. local color = drinks.drink_table[i][3]
  6. local health = drinks.drink_table[i][4]
  7. health = health or 1
  8. --Actual Node registration
  9. minetest.register_node('drinks:jbu_'..desc..'', {
  10. description = 'Bucket of '..craft..' Juice',
  11. drawtype = "plantlike",
  12. tiles = {'bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)'},
  13. inventory_image = 'bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)',
  14. wield_image = 'bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)',
  15. paramtype = "light",
  16. juice_type = craft,
  17. is_ground_content = false,
  18. walkable = false,
  19. selection_box = {
  20. type = "fixed",
  21. fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
  22. },
  23. groups = {vessel=1,dig_immediate=3,attached_node=1, drink = 1},
  24. sounds = default.node_sound_defaults(),
  25. })
  26. drinks.register_item( 'drinks:jcu_'..desc, 'vessels:drinking_glass', {
  27. description = 'Cup of '..craft..' Juice',
  28. juice_type = craft,
  29. inventory_image = 'drinks_glass_contents.png^[colorize:'..color..':200^drinks_drinking_glass.png',
  30. on_use = function(itemstack, user, pointed_thing)
  31. local eat_func = minetest.item_eat(health, 'vessels:drinking_glass')
  32. return eat_func(itemstack, user, pointed_thing)
  33. end,
  34. })
  35. drinks.register_item( 'drinks:jbo_'..desc, 'vessels:glass_bottle', {
  36. description = 'Bottle of '..craft..' Juice',
  37. groups = {drink=1},
  38. juice_type = craft,
  39. inventory_image = 'drinks_bottle_contents.png^[colorize:'..color..':200^drinks_glass_bottle.png',
  40. on_use = function(itemstack, user, pointed_thing)
  41. local eat_func = minetest.item_eat((health*2), 'vessels:glass_bottle')
  42. return eat_func(itemstack, user, pointed_thing)
  43. end,
  44. })
  45. drinks.register_item( 'drinks:jsb_'..desc, 'vessels:steel_bottle', {
  46. description = 'Heavy Steel Bottle ('..craft..' Juice)',
  47. groups = {drink=1},
  48. juice_type = craft,
  49. inventory_image = 'vessels_steel_bottle.png',
  50. on_use = function(itemstack, user, pointed_thing)
  51. local eat_func = minetest.item_eat((health*2), 'vessels:steel_bottle')
  52. return eat_func(itemstack, user, pointed_thing)
  53. end,
  54. })
  55. end