drinks2.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. -- This code is for if Thirst isn't enabled.
  2. --Parse Table
  3. for i in ipairs (drinks.drink_table) do
  4. local desc = drinks.drink_table[i][1]
  5. local craft = drinks.drink_table[i][2]
  6. local color = drinks.drink_table[i][3]
  7. local health = drinks.drink_table[i][4]
  8. health = health or 1
  9. --Actual Node registration
  10. minetest.register_node('drinks:jbu_'..desc..'', {
  11. description = 'Bucket of '..craft..' Juice',
  12. drawtype = "plantlike",
  13. tiles = {'bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)'},
  14. inventory_image = 'bucket.png^(drinks_bucket_contents.png^[colorize:'..color..':200)',
  15. wield_image = '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. juice_type = craft,
  30. inventory_image = 'drinks_glass_contents.png^[colorize:'..color..':200^drinks_drinking_glass.png',
  31. on_use = function(itemstack, user, pointed_thing)
  32. local eat_func = minetest.item_eat(health, 'vessels:drinking_glass')
  33. return eat_func(itemstack, user, pointed_thing)
  34. end,
  35. })
  36. drinks.register_item( 'drinks:jbo_'..desc, 'vessels:glass_bottle', {
  37. description = 'Bottle of '..craft..' Juice',
  38. groups = {drink=1},
  39. juice_type = craft,
  40. inventory_image = 'drinks_bottle_contents.png^[colorize:'..color..':200^drinks_glass_bottle.png',
  41. on_use = function(itemstack, user, pointed_thing)
  42. local eat_func = minetest.item_eat((health*2), 'vessels:glass_bottle')
  43. return eat_func(itemstack, user, pointed_thing)
  44. end,
  45. })
  46. drinks.register_item( 'drinks:jsb_'..desc, 'vessels:steel_bottle', {
  47. description = 'Heavy Steel Bottle ('..craft..' Juice)',
  48. groups = {drink=1},
  49. juice_type = craft,
  50. inventory_image = 'vessels_steel_bottle.png',
  51. on_use = function(itemstack, user, pointed_thing)
  52. local eat_func = minetest.item_eat((health*2), 'vessels:steel_bottle')
  53. return eat_func(itemstack, user, pointed_thing)
  54. end,
  55. })
  56. end