Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ light_tool.light_beam = function(pos, dir, range)
local lightable = light_tool.check(light_tool.lightable_nodes, node.name)
local lightable_index = light_tool.check_index(light_tool.lightable_nodes, node.name)
local lit = light_tool.check(light_tool.lit_nodes, node.name)
if node.name == "air" or node.name == "light_tool:light" then
minetest.set_node(new_pos, {name = "light_tool:light"})

if node.name == "air" then
-- Place temporary light nodes in air:
minetest.set_node(new_pos, {name = "light_tool:light"})
minetest.get_node_timer(new_pos):start(0.2)
elseif node.name == "light_tool:light" then
-- Reset destruction timer for this light node:
minetest.get_node_timer(new_pos):start(0.2)
elseif lightable or node.name == lit then

local index = light_tool.check_index(light_tool.lightable_nodes, node.name)
Expand Down
9 changes: 5 additions & 4 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ minetest.register_tool("light_tool:light_tool", {
})
light_tool.add_tool("light_tool:light_tool", 20)

-- This is a temporary light source which forms the light beam of a flashlight.
-- When you constructed it, call minetest.get_node_timer(pos):start(lifetime) to make it delete itself.
-- Call start() again to extend the lifetime.
minetest.register_node("light_tool:light", {
drawtype = "airlike",
tiles = {"blank.png"},
Expand All @@ -18,10 +21,8 @@ minetest.register_node("light_tool:light", {
light_source = 8,
pointable = false,
buildable_to = true,
on_construct = function(pos)
minetest.after(0.1, function()
minetest.set_node(pos, {name = "air"})
end)
on_timer = function(pos)
minetest.set_node(pos, {name = "air"})
end,
})

Expand Down