diff --git a/mods/ITEMS/mcl_spyglass/init.lua b/mods/ITEMS/mcl_spyglass/init.lua new file mode 100644 index 0000000000..fa1a823399 --- /dev/null +++ b/mods/ITEMS/mcl_spyglass/init.lua @@ -0,0 +1,73 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +minetest.register_tool("mcl_spyglass:spyglass",{ + description = S("Spyglass"), + _doc_items_longdesc = S("A spyglass is an item that can be used for zooming in on specific locations."), + inventory_image = "mcl_spyglass.png", + stack_max = 1, + _mcl_toollike_wield = true, +}) + +minetest.register_craft({ + output = "mcl_spyglass:spyglass", + recipe = { + {"mcl_amethyst:amethyst_shard"}, + {"mcl_copper:copper_ingot"}, + {"mcl_copper:copper_ingot"}, + } +}) + +local spyglass_scope = {} + +local function add_scope(player) + local wielditem = player:get_wielded_item() + if wielditem:get_name() == "mcl_spyglass:spyglass" then + spyglass_scope[player] = player:hud_add({ + hud_elem_type = "image", + position = {x = 0.5, y = 0.5}, + scale = {x = -100, y = -100}, + text = "mcl_spyglass_scope.png", + }) + player:hud_set_flags({wielditem = false}) + end +end + +local function remove_scope(player) + if spyglass_scope[player] then + player:hud_remove(spyglass_scope[player]) + spyglass_scope[player] = nil + player:hud_set_flags({wielditem = true}) + player:set_fov(86.1) + end +end + +controls.register_on_press(function(player, key) + if key ~= "RMB" then return end + add_scope(player) +end) + +controls.register_on_release(function(player, key, time) + if key ~= "RMB" then return end + remove_scope(player) +end) + +controls.register_on_hold(function(player, key, time) + if key ~= "RMB" then return end + local wielditem = player:get_wielded_item() + if wielditem:get_name() == "mcl_spyglass:spyglass" then + player:set_fov(8, false, 0.1) + if spyglass_scope[player] == nil then + add_scope(player) + end + else + remove_scope(player) + end +end) + +minetest.register_on_dieplayer(function(player) + remove_scope(player) +end) + +minetest.register_on_leaveplayer(function(player) + spyglass_scope[player] = nil +end) diff --git a/mods/ITEMS/mcl_spyglass/locale/mcl_spyglass.ru.tr b/mods/ITEMS/mcl_spyglass/locale/mcl_spyglass.ru.tr new file mode 100644 index 0000000000..32b7fa96aa --- /dev/null +++ b/mods/ITEMS/mcl_spyglass/locale/mcl_spyglass.ru.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_spyglass +Spyglass=Подзорная труба +A spyglass is an item that can be used for zooming in on specific locations.=Подзорная труба это предмет который позволяет смотреть вдаль. \ No newline at end of file diff --git a/mods/ITEMS/mcl_spyglass/locale/template.txt b/mods/ITEMS/mcl_spyglass/locale/template.txt new file mode 100644 index 0000000000..606b46455e --- /dev/null +++ b/mods/ITEMS/mcl_spyglass/locale/template.txt @@ -0,0 +1,3 @@ +# textdomain: mcl_spyglass +Spyglass= +A spyglass is an item that can be used for zooming in on specific locations.= diff --git a/mods/ITEMS/mcl_spyglass/mod.conf b/mods/ITEMS/mcl_spyglass/mod.conf new file mode 100644 index 0000000000..c13b281e14 --- /dev/null +++ b/mods/ITEMS/mcl_spyglass/mod.conf @@ -0,0 +1,4 @@ +name = mcl_spyglass +author = NO11 +description = This mod adds a spyglass, which is an item that can be used for zooming in on specific locations. +depends = mcl_core, controls diff --git a/mods/ITEMS/mcl_spyglass/textures/mcl_spyglass.png b/mods/ITEMS/mcl_spyglass/textures/mcl_spyglass.png new file mode 100644 index 0000000000..cc5eb4d962 Binary files /dev/null and b/mods/ITEMS/mcl_spyglass/textures/mcl_spyglass.png differ diff --git a/mods/ITEMS/mcl_spyglass/textures/mcl_spyglass_scope.png b/mods/ITEMS/mcl_spyglass/textures/mcl_spyglass_scope.png new file mode 100644 index 0000000000..041a88febf Binary files /dev/null and b/mods/ITEMS/mcl_spyglass/textures/mcl_spyglass_scope.png differ