diff options
author | Zefram <zefram@fysh.org> | 2014-04-27 18:40:21 +0100 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-04-27 14:43:31 -0400 |
commit | 5c59d970703c11174352aa0b34edd62da90e8e96 (patch) | |
tree | 0a23d3c61e735a7a78ae1b1c4494d95c31cbc358 | |
parent | db796755707809e79eee85b2c4c599359c400008 (diff) |
Fix discharge of flashlight and sonic screwdriver
These two tools wouldn't discharge all the way to zero through use,
unlike most chargeable items.
Incidentally remove a duplicate of the check_for_flashlight() function.
-rw-r--r-- | technic/tools/flashlight.lua | 27 | ||||
-rw-r--r-- | technic/tools/sonic_screwdriver.lua | 2 |
2 files changed, 2 insertions, 27 deletions
diff --git a/technic/tools/flashlight.lua b/technic/tools/flashlight.lua index 02f3299..1be550e 100644 --- a/technic/tools/flashlight.lua +++ b/technic/tools/flashlight.lua @@ -40,7 +40,7 @@ local function check_for_flashlight(player) if not meta or not meta.charge then return false end - if meta.charge - 2 > 0 then + if meta.charge >= 2 then meta.charge = meta.charge - 2; technic.set_RE_wear(hotbar[i], meta.charge, flashlight_max_charge) hotbar[i]:set_metadata(minetest.serialize(meta)) @@ -72,31 +72,6 @@ minetest.register_on_leaveplayer(function(player) player_positions[player_name] = nil end) - -local function check_for_flashlight(player) - if player == nil then - return false - end - local inv = player:get_inventory() - local hotbar = inv:get_list("main") - for i = 1, 8 do - if hotbar[i]:get_name() == "technic:flashlight" then - local meta = minetest.deserialize(hotbar[i]:get_metadata()) - if not meta or not meta.charge then - return false - end - if meta.charge - 2 > 0 then - meta.charge = meta.charge - 2; - technic.set_RE_wear(hotbar[i], meta.charge, flashlight_max_charge) - hotbar[i]:set_metadata(minetest.serialize(meta)) - inv:set_stack("main", i, hotbar[i]) - return true - end - end - end - return false -end - minetest.register_globalstep(function(dtime) for i, player in pairs(minetest.get_connected_players()) do local player_name = player:get_player_name() diff --git a/technic/tools/sonic_screwdriver.lua b/technic/tools/sonic_screwdriver.lua index 3951b8b..a9a52d8 100644 --- a/technic/tools/sonic_screwdriver.lua +++ b/technic/tools/sonic_screwdriver.lua @@ -30,7 +30,7 @@ minetest.register_tool("technic:sonic_screwdriver", { if not meta1 or not meta1.charge then return end - if meta1.charge - 100 > 0 then + if meta1.charge >= 100 then minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 0.3, max_hear_distance = 10}) local p = node.param2 |