From: Zefram Date: Sat, 26 Apr 2014 22:26:07 +0000 (+0100) Subject: Fix flashlight's light generation X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=db796755707809e79eee85b2c4c599359c400008;p=zefram%2Fminetest%2Ftechnic.git Fix flashlight's light generation The flashlight was lighting the wrong node, 1 m east of the player's lower half, thus getting no light if the player is adjacent to an eastern wall. Restore the old 1 m above, that coincides with the player's hands. There was a problem with light from the flashlight getting stuck in the map. This arises because the flashlight's light value was 15, the reserved value that the engine uses for sunlight. Moving the flashlight upwards, by jumping while it is equipped, would cause the node below it to acquire a bogus sunlit state. Fix this by reducing the flashlight's light value to 14 (LIGHT_MAX), which is the maximum permitted for non-sunlight. The light_off node type is not required. With the light value limited to 14, mere removal of the light node suffices to correctly recalculate lighting. --- diff --git a/technic/tools/flashlight.lua b/technic/tools/flashlight.lua index 1a3c1cf..02f3299 100644 --- a/technic/tools/flashlight.lua +++ b/technic/tools/flashlight.lua @@ -56,7 +56,7 @@ minetest.register_on_joinplayer(function(player) local player_name = player:get_player_name() local pos = player:getpos() local rounded_pos = vector.round(pos) - rounded_pos.x = rounded_pos.x + 1 + rounded_pos.y = rounded_pos.y + 1 player_positions[player_name] = rounded_pos was_wielding[player_name] = true end) @@ -66,7 +66,7 @@ minetest.register_on_leaveplayer(function(player) local player_name = player:get_player_name() local pos = player_positions[player_name] local nodename = minetest.get_node(pos).name - if nodename == "technic:light_off" or nodename == "technic:light" then + if nodename == "technic:light" then minetest.remove_node(pos) end player_positions[player_name] = nil @@ -103,7 +103,7 @@ minetest.register_globalstep(function(dtime) local flashlight_weared = check_for_flashlight(player) local pos = player:getpos() local rounded_pos = vector.round(pos) - rounded_pos.x = rounded_pos.x + 1 + rounded_pos.y = rounded_pos.y + 1 local old_pos = player_positions[player_name] local player_moved = not vector.equals(old_pos, rounded_pos) @@ -112,7 +112,6 @@ minetest.register_globalstep(function(dtime) was_wielding[player_name] = false local node = minetest.get_node_or_nil(old_pos) if node and node.name == "technic:light" then - minetest.set_node(old_pos, {name="technic:light_off"}) minetest.remove_node(old_pos) end elseif (player_moved or not was_wielding[player_name]) and flashlight_weared then @@ -122,7 +121,6 @@ minetest.register_globalstep(function(dtime) end local node = minetest.get_node_or_nil(old_pos) if node and node.name == "technic:light" then - minetest.set_node(old_pos, {name="technic:light_off"}) minetest.remove_node(old_pos) end player_positions[player_name] = rounded_pos @@ -140,22 +138,6 @@ minetest.register_node("technic:light", { walkable = false, buildable_to = true, sunlight_propagates = true, - light_source = 15, + light_source = LIGHT_MAX, pointable = false, }) - -minetest.register_node("technic:light_off", { - drawtype = "glasslike", - tile_images = {"technic_light.png"}, - paramtype = "light", - groups = {not_in_creative_inventory=1}, - drop = "", - walkable = false, - buildable_to = true, - sunlight_propagates = true, - selection_box = { - type = "fixed", - fixed = {0, 0, 0, 0, 0, 0}, - }, -}) -