functions.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. function default.get_hotbar_bg(x,y)
  2. local out = ''
  3. for i=0,7,1 do
  4. out = out ..'image['..x+i..','..y..';1,1;gui_hb_bg.png]'
  5. end
  6. return out
  7. end
  8. function campfire.fire_formspec(item_percent)
  9. local formspec =
  10. 'size[8,6.75]'..
  11. default.gui_slots..
  12. 'listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]'..
  13. 'background[8,6.75;0,0;campfire_campfire_bg.png;true]'..
  14. -- 'label[2,.75;< Add More Wood]'..
  15. -- 'label[1.25,2; Cook Something >]'..
  16. 'list[current_name;fuel;1,.5;4,2;]'..
  17. -- 'list[current_name;src;4,1.75;1,1;]'..
  18. -- 'image[5,1.75;1,1;gui_furnace_arrow_bg.png^[lowpart:'..
  19. -- (item_percent)..':gui_furnace_arrow_fg.png^[transformR270]'..
  20. -- 'list[current_name;dst;6,1.75;2,1;]'..
  21. 'list[current_player;main;0,2.75;8,1;]'..
  22. 'list[current_player;main;0,4;8,3;8]'..
  23. default.get_hotbar_bg(0,2.75)
  24. return formspec
  25. end
  26. campfire.embers_formspec =
  27. 'size[8,6.75]'..
  28. default.gui_slots..
  29. 'listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]'..
  30. 'background[8,6.75;0,0;campfire_campfire_bg.png;true]'..
  31. -- 'label[2,.75;< Add More Wood]'..
  32. -- 'label[1.25,2; Cook Something >]'..
  33. 'list[current_name;fuel;1,.5;4,2;]'..
  34. -- 'list[current_name;src;4,1.75;1,1;]'..
  35. -- 'image[5,1.75;1,1;gui_furnace_arrow_bg.png^[transformR270]'..
  36. -- 'list[current_name;dst;6,1.75;2,1;]'..
  37. 'list[current_player;main;0,2.75;8,1;]'..
  38. 'list[current_player;main;0,4;8,3;8]'..
  39. default.get_hotbar_bg(0,2.75)
  40. function burn(pointed_thing) --kindling doesn't always start from the first spark
  41. local ignite_chance = math.random(5)
  42. if ignite_chance == 1
  43. and string.find(minetest.get_node(pointed_thing.under).name, 'campfire:kindling_contained')
  44. then
  45. minetest.set_node(pointed_thing.under, {name = 'campfire:embers_contained'})
  46. elseif ignite_chance == 1
  47. and string.find(minetest.get_node(pointed_thing.under).name, 'campfire:kindling')
  48. then
  49. minetest.set_node(pointed_thing.under, {name = 'campfire:embers'})
  50. else --Do nothing
  51. end
  52. end
  53. function smoke_particles(pos)
  54. minetest.add_particlespawner({
  55. amount = 1, -- how many particles do you want
  56. time = 2, -- spawner stops after this time (use 0 for infinite)
  57. minpos = {x=pos.x, y=pos.y, z=pos.z}, -- minimum offset
  58. maxpos = {x=pos.x, y=pos.y, z=pos.z}, -- maximum offset
  59. minvel = {x=-.1, y=0, z=-.1}, -- minimum velocity
  60. maxvel = {x=.1, y=.4, z=.1}, -- maximum velocity
  61. minacc = {x=-.05, y=.02, z=-.05}, -- minimum acceleration
  62. maxacc = {x=.1, y=.1, z=.1}, -- maximim acceleration
  63. minexptime = 3, -- minimum expiration time
  64. maxexptime = 6, -- maximum expiration time
  65. minsize = 3, -- minimum size (0.5 = half size)
  66. maxsize = 8, -- maximum size (1=full resolution)
  67. collisiondetection = false, -- do particles stop when they hit solid node
  68. texture = 'campfire_smoke.png', -- image to use (e.g. 'bubble.png' )
  69. vertical = false, -- upright/vertical image for rain
  70. -- playername = 'singleplayer', -- particles only appear for this player
  71. })
  72. end
  73. function ember_particles(pos)
  74. minetest.add_particlespawner({
  75. amount = 1,
  76. time = 2,
  77. minpos = {x=pos.x, y=pos.y, z=pos.z},
  78. maxpos = {x=pos.x, y=pos.y, z=pos.z},
  79. minvel = {x=-.15, y=.3, z=-.15},
  80. maxvel = {x=.1, y=.6, z=.1},
  81. minacc = {x=-.05, y=.02, z=-.05},
  82. maxacc = {x=.1, y=.3, z=.1},
  83. minexptime = 1,
  84. maxexptime = 3,
  85. minsize = 1,
  86. maxsize = 2,
  87. collisiondetection = false,
  88. texture = 'campfire_embers.png',
  89. vertical = false,
  90. -- playername = 'singleplayer',
  91. })
  92. end
  93. function lava_particles(pos)
  94. minetest.add_particlespawner({
  95. amount = 2,
  96. time = 1,
  97. minpos = {x=pos.x, y=pos.y-.5, z=pos.z},
  98. maxpos = {x=pos.x, y=pos.y, z=pos.z},
  99. minvel = {x=-.4, y=1, z=-.4},
  100. maxvel = {x=.4, y=1.5, z=.4},
  101. minacc = {x=-.4, y=1, z=-.4},
  102. maxacc = {x=.4, y=1.5, z=.4},
  103. minexptime = 1,
  104. maxexptime = 1.5,
  105. minsize = .6,
  106. maxsize = 2,
  107. collisiondetection = false,
  108. texture = 'campfire_lava_blob.png',
  109. vertical = false,
  110. -- playername = 'singleplayer',
  111. })
  112. end