Advertisement
Guest User

Untitled

a guest
Nov 1st, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. local nv_time = 3
  2.  
  3. for nv = 1,2,1 do
  4.  
  5. if nv == 1 then
  6. nv_time = 5 -- time for 1st node
  7. else
  8. nv_time = 20 -- time for 2nd node
  9. end
  10.  
  11. minetest.register_node("lottpotion:night_vis_"..nv, {
  12. description = "Potion of Night Vision ("..nv_time.." sec.)",
  13. drawtype = "plantlike",
  14. tiles = {"lottpotion_night_vis.png^vessels_glass_bottle.png"},
  15. is_ground_content = false,
  16. walkable = false,
  17. paramtype = "light",
  18. selection_box = {
  19. type = "fixed",
  20. fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
  21. },
  22. groups = {vessel=1,dig_immediate=3,attached_node=1, potion=1},
  23. sounds = default.node_sound_glass_defaults(),
  24. stack_max = 1,
  25. wield_image = "lottpotion_night_vis.png^vessels_glass_bottle.png",
  26. inventory_image = "lottpotion_night_vis.png^vessels_glass_bottle.png",
  27. on_use = function(item, user, pointed_thing)
  28. local player = user:get_player_name()
  29. lightchange(user, nv_time) -- here time is 20 for both nodes
  30. --effect
  31. local playerpos = user:getpos();
  32. minetest.add_particlespawner(
  33. 7, --amount
  34. 0.1, --time
  35. {x=playerpos.x-1, y=playerpos.y+1, z=playerpos.z-1}, --minpos
  36. {x=playerpos.x+1, y=playerpos.y+1, z=playerpos.z+1}, --maxpos
  37. {x=-0, y=3, z=-0}, --minvel
  38. {x=0, y=4, z=0}, --maxvel
  39. {x=-0.5,y=0,z=-0.5}, --minacc
  40. {x=0.5,y=1,z=0.5}, --maxacc
  41. 0.1, --minexptime
  42. 0.2, --maxexptime
  43. 1, --minsize
  44. 2, --maxsize
  45. false, --collisiondetection
  46. "bubble.png" --texture
  47. )
  48. item:replace("vessels:glass_bottle")
  49. return item
  50. end
  51. })
  52.  
  53. end
  54.  
  55. function lightchange(person, duration)
  56. local mtime = minetest.get_timeofday()
  57. if mtime <= 0.25 or mtime >= 0.75 then
  58. person:override_day_night_ratio(mtime+0.5)
  59. minetest.after(duration, function()
  60. person:override_day_night_ratio(nil)
  61. end)
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement