Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local nv_time = 3
- for nv = 1,2,1 do
- if nv == 1 then
- nv_time = 5 -- time for 1st node
- else
- nv_time = 20 -- time for 2nd node
- end
- minetest.register_node("lottpotion:night_vis_"..nv, {
- description = "Potion of Night Vision ("..nv_time.." sec.)",
- drawtype = "plantlike",
- tiles = {"lottpotion_night_vis.png^vessels_glass_bottle.png"},
- is_ground_content = false,
- walkable = false,
- paramtype = "light",
- selection_box = {
- type = "fixed",
- fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
- },
- groups = {vessel=1,dig_immediate=3,attached_node=1, potion=1},
- sounds = default.node_sound_glass_defaults(),
- stack_max = 1,
- wield_image = "lottpotion_night_vis.png^vessels_glass_bottle.png",
- inventory_image = "lottpotion_night_vis.png^vessels_glass_bottle.png",
- on_use = function(item, user, pointed_thing)
- local player = user:get_player_name()
- lightchange(user, nv_time) -- here time is 20 for both nodes
- --effect
- local playerpos = user:getpos();
- minetest.add_particlespawner(
- 7, --amount
- 0.1, --time
- {x=playerpos.x-1, y=playerpos.y+1, z=playerpos.z-1}, --minpos
- {x=playerpos.x+1, y=playerpos.y+1, z=playerpos.z+1}, --maxpos
- {x=-0, y=3, z=-0}, --minvel
- {x=0, y=4, z=0}, --maxvel
- {x=-0.5,y=0,z=-0.5}, --minacc
- {x=0.5,y=1,z=0.5}, --maxacc
- 0.1, --minexptime
- 0.2, --maxexptime
- 1, --minsize
- 2, --maxsize
- false, --collisiondetection
- "bubble.png" --texture
- )
- item:replace("vessels:glass_bottle")
- return item
- end
- })
- end
- function lightchange(person, duration)
- local mtime = minetest.get_timeofday()
- if mtime <= 0.25 or mtime >= 0.75 then
- person:override_day_night_ratio(mtime+0.5)
- minetest.after(duration, function()
- person:override_day_night_ratio(nil)
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement