drinks.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. -- The color of the drink is all done in code, so we don't need to have multiple images.
  9. --Actual Node registration
  10. minetest.register_node('drinks:jbu_'..desc..'', {
  11. description = 'Bucket of '..craft..' Juice',
  12. drawtype = "plantlike",
  13. tiles = {'mesecraft_bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)'},
  14. inventory_image = 'mesecraft_bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)',
  15. wield_image = 'mesecraft_bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)',
  16. paramtype = "light",
  17. juice_type = craft,
  18. is_ground_content = false,
  19. walkable = false,
  20. selection_box = {
  21. type = "fixed",
  22. fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
  23. },
  24. groups = {vessel=1,dig_immediate=3,attached_node=1, drink = 1},
  25. sounds = default.node_sound_defaults(),
  26. })
  27. drinks.register_item('drinks:jcu_'..desc, 'vessels:drinking_glass', {
  28. description = 'Cup of '..craft..' Juice',
  29. groups = {drink=1},
  30. juice_type = craft,
  31. inventory_image = 'drinks_glass_contents.png^[colorize:'..color..':200^drinks_drinking_glass.png',
  32. on_use = function(itemstack, user, pointed_thing)
  33. thirsty.drink(user, 4, 20)
  34. local eat_func = minetest.item_eat(health, 'vessels:drinking_glass')
  35. return eat_func(itemstack, user, pointed_thing)
  36. end,
  37. })
  38. drinks.register_item('drinks:jbo_'..desc, 'vessels:glass_bottle',{
  39. description = 'Bottle of '..craft..' Juice',
  40. groups = {drink = 1},
  41. juice_type = craft,
  42. inventory_image = 'drinks_bottle_contents.png^[colorize:'..color..':200^drinks_glass_bottle.png',
  43. on_use = function(itemstack, user, pointed_thing)
  44. thirsty.drink(user, 8, 20)
  45. local eat_func = minetest.item_eat((health*2), 'vessels:glass_bottle')
  46. return eat_func(itemstack, user, pointed_thing)
  47. end,
  48. })
  49. drinks.register_item('drinks:jsb_'..desc, 'vessels:steel_bottle',{
  50. description = 'Heavy Steel Bottle ('..craft..' Juice)',
  51. groups = {drink = 1},
  52. juice_type = craft,
  53. inventory_image = 'vessels_steel_bottle.png',
  54. on_use = function(itemstack, user, pointed_thing)
  55. thirsty.drink(user, 8, 20)
  56. local eat_func = minetest.item_eat((health*2), 'vessels:steel_bottle')
  57. return eat_func(itemstack, user, pointed_thing)
  58. end,
  59. })
  60. end