spaces -> tabs

This commit is contained in:
cora 2022-06-13 12:24:27 +02:00
parent e58387d123
commit 7dd6d5f886
1 changed files with 47 additions and 47 deletions

View File

@ -1,81 +1,81 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
minetest.register_tool("mcl_spyglass:spyglass",{ minetest.register_tool("mcl_spyglass:spyglass",{
description = S("Spyglass"), description = S("Spyglass"),
_doc_items_longdesc = S("A spyglass is an item that can be used for zooming in on specific locations."), _doc_items_longdesc = S("A spyglass is an item that can be used for zooming in on specific locations."),
inventory_image = "mcl_spyglass.png", inventory_image = "mcl_spyglass.png",
stack_max = 1, stack_max = 1,
_mcl_toollike_wield = true, _mcl_toollike_wield = true,
}) })
local function craft_spyglass(ingot) local function craft_spyglass(ingot)
minetest.register_craft({ minetest.register_craft({
output = "mcl_spyglass:spyglass", output = "mcl_spyglass:spyglass",
recipe = { recipe = {
{"xpanes:pane_natural_flat"}, {"xpanes:pane_natural_flat"},
{ingot}, {ingot},
{ingot}, {ingot},
} }
}) })
end end
if minetest.get_modpath("mcl_copper") then if minetest.get_modpath("mcl_copper") then
craft_spyglass("mcl_copper:copper_ingot") craft_spyglass("mcl_copper:copper_ingot")
else else
craft_spyglass("mcl_core:iron_ingot") craft_spyglass("mcl_core:iron_ingot")
end end
local spyglass_scope = {} local spyglass_scope = {}
local function add_scope(player) local function add_scope(player)
local wielditem = player:get_wielded_item() local wielditem = player:get_wielded_item()
if wielditem:get_name() == "mcl_spyglass:spyglass" then if wielditem:get_name() == "mcl_spyglass:spyglass" then
spyglass_scope[player] = player:hud_add({ spyglass_scope[player] = player:hud_add({
hud_elem_type = "image", hud_elem_type = "image",
position = {x = 0.5, y = 0.5}, position = {x = 0.5, y = 0.5},
scale = {x = -100, y = -100}, scale = {x = -100, y = -100},
text = "mcl_spyglass_scope.png", text = "mcl_spyglass_scope.png",
}) })
player:hud_set_flags({wielditem = false}) player:hud_set_flags({wielditem = false})
end end
end end
local function remove_scope(player) local function remove_scope(player)
if spyglass_scope[player] then if spyglass_scope[player] then
player:hud_remove(spyglass_scope[player]) player:hud_remove(spyglass_scope[player])
spyglass_scope[player] = nil spyglass_scope[player] = nil
player:hud_set_flags({wielditem = true}) player:hud_set_flags({wielditem = true})
player:set_fov(86.1) player:set_fov(86.1)
end end
end end
controls.register_on_press(function(player, key) controls.register_on_press(function(player, key)
if key ~= "RMB" then return end if key ~= "RMB" then return end
add_scope(player) add_scope(player)
end) end)
controls.register_on_release(function(player, key, time) controls.register_on_release(function(player, key, time)
if key ~= "RMB" then return end if key ~= "RMB" then return end
remove_scope(player) remove_scope(player)
end) end)
controls.register_on_hold(function(player, key, time) controls.register_on_hold(function(player, key, time)
if key ~= "RMB" then return end if key ~= "RMB" then return end
local wielditem = player:get_wielded_item() local wielditem = player:get_wielded_item()
if wielditem:get_name() == "mcl_spyglass:spyglass" then if wielditem:get_name() == "mcl_spyglass:spyglass" then
player:set_fov(8, false, 0.1) player:set_fov(8, false, 0.1)
if spyglass_scope[player] == nil then if spyglass_scope[player] == nil then
add_scope(player) add_scope(player)
end end
else else
remove_scope(player) remove_scope(player)
end end
end) end)
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)
remove_scope(player) remove_scope(player)
end) end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
spyglass_scope[player] = nil spyglass_scope[player] = nil
end) end)