mirror of
https://github.com/minetest-mods/technic.git
synced 2025-06-30 23:30:38 +02:00
More global localiztions
This commit is contained in:
@ -27,10 +27,34 @@ local players = {}
|
||||
local player_positions = {}
|
||||
local last_wielded = {}
|
||||
|
||||
function round(num)
|
||||
local function round(num)
|
||||
return math.floor(num + 0.5)
|
||||
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_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
table.insert(players, player_name)
|
||||
@ -143,27 +167,3 @@ minetest.register_node("technic:light_off", {
|
||||
},
|
||||
})
|
||||
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user