From 22c5f0f41eab57db93d7762e8c19840c05f59363 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 20 Feb 2017 00:51:28 +0100 Subject: [PATCH] Add a map imitation The map item just enables the minimap. It's pretty overpowered at the moment. --- mods/ITEMS/mcl_maps/init.lua | 81 ++++++++++++++++++ mods/ITEMS/mcl_maps/mod.conf | 1 + .../mcl_maps/textures/mcl_maps_map_empty.png | Bin 0 -> 274 bytes .../mcl_maps/textures/mcl_maps_map_filled.png | Bin 0 -> 274 bytes .../textures/mcl_maps_map_filled_markings.png | Bin 0 -> 15348 bytes mods/PLAYER/mcl_player/init.lua | 3 +- 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 mods/ITEMS/mcl_maps/init.lua create mode 100644 mods/ITEMS/mcl_maps/mod.conf create mode 100644 mods/ITEMS/mcl_maps/textures/mcl_maps_map_empty.png create mode 100644 mods/ITEMS/mcl_maps/textures/mcl_maps_map_filled.png create mode 100644 mods/ITEMS/mcl_maps/textures/mcl_maps_map_filled_markings.png diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua new file mode 100644 index 00000000..e36a5abc --- /dev/null +++ b/mods/ITEMS/mcl_maps/init.lua @@ -0,0 +1,81 @@ +-- Turn empty map into filled map by rightclick +local make_filled_map = function(itemstack, placer, pointed_thing) + local new_map = ItemStack("mcl_maps:filled_map") + itemstack:take_item() + if itemstack:is_empty() then + return new_map + else + local inv = placer:get_inventory() + if inv:room_for_item("main", new_map) then + inv:add_item("main", new_map) + else + minetest.add_item(placer:getpos(), new_map) + end + return itemstack + end +end + +minetest.register_craftitem("mcl_maps:empty_map", { + description = "Empty Map", + inventory_image = "mcl_maps_map_empty.png", + groups = { not_in_creative_inventory = 1 }, + on_place = make_filled_map, + on_secondary_use = make_filled_map, + stack_max = 64, +}) + +-- Enables minimap if carried in hotbar. +-- If this item is NOT in the hotbar, the minimap is unavailable +-- Note: This is not at all like Minecraft right now. Minetest's minimap is pretty overpowered, it +-- has a very greatly zoomed-out version and even a radar mode +minetest.register_craftitem("mcl_maps:filled_map", { + description = "Map", + inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)", + stack_max = 1, +}) + +minetest.register_craft({ + output = "mcl_maps:filled_map", + recipe = { + { "mcl_core:paper", "mcl_core:paper", "mcl_core:paper" }, + { "mcl_core:paper", "group:compass", "mcl_core:paper" }, + { "mcl_core:paper", "mcl_core:paper", "mcl_core:paper" }, + } +}) + +local function has_item_in_hotbar(player, item) + -- Requirement: player carries the tool in the hotbar + local inv = player:get_inventory() + local hotbar = player:hud_get_hotbar_itemcount() + for i=1, hotbar do + if inv:get_stack("main", i):get_name() == item then + return true + end + end + return false +end + +-- Checks if player is still allowed to display the minimap +local function update_minimap(player) + if has_item_in_hotbar(player, "mcl_maps:filled_map") then + player:hud_set_flags({minimap = true}) + else + player:hud_set_flags({minimap = false}) + end +end + +minetest.register_on_joinplayer(function(player) + update_minimap(player) +end) + +local updatetimer = 0 +minetest.register_globalstep(function(dtime) + updatetimer = updatetimer + dtime + if updatetimer > 0.1 then + local players = minetest.get_connected_players() + for i=1, #players do + update_minimap(players[i]) + end + updatetimer = updatetimer - dtime + end +end) diff --git a/mods/ITEMS/mcl_maps/mod.conf b/mods/ITEMS/mcl_maps/mod.conf new file mode 100644 index 00000000..44c4becf --- /dev/null +++ b/mods/ITEMS/mcl_maps/mod.conf @@ -0,0 +1 @@ +name = mcl_maps diff --git a/mods/ITEMS/mcl_maps/textures/mcl_maps_map_empty.png b/mods/ITEMS/mcl_maps/textures/mcl_maps_map_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..9b5aa7d6786c4d438b26fc52c4330300000ab766 GIT binary patch literal 274 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}H$7b(Ln>~)ogU3~M1jZk zZj$+R-Lrf#F6N1a2M%^s-pO8I@MGe9vx>gnz}a4!FVA{JKgefU_c}OhkJ5z)JuVh9 zQ#qQS*VHjjI(ivY1&V}Ja{SPpt5J{yNBz{zIZH{J%L61_66;SCoevD z<(A@E!J@Ncr?8h$7-w2{uO0U>v8xX_B&>R7v0RFKXuc@YGVH*W+6A624KJkwMJoPF d<~E9%m(_b+ZpePJoPmLX!PC{xWt~$(695bcaR&eZ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_maps/textures/mcl_maps_map_filled.png b/mods/ITEMS/mcl_maps/textures/mcl_maps_map_filled.png new file mode 100644 index 0000000000000000000000000000000000000000..9b5aa7d6786c4d438b26fc52c4330300000ab766 GIT binary patch literal 274 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}H$7b(Ln>~)ogU3~M1jZk zZj$+R-Lrf#F6N1a2M%^s-pO8I@MGe9vx>gnz}a4!FVA{JKgefU_c}OhkJ5z)JuVh9 zQ#qQS*VHjjI(ivY1&V}Ja{SPpt5J{yNBz{zIZH{J%L61_66;SCoevD z<(A@E!J@Ncr?8h$7-w2{uO0U>v8xX_B&>R7v0RFKXuc@YGVH*W+6A624KJkwMJoPF d<~E9%m(_b+ZpePJoPmLX!PC{xWt~$(695bcaR&eZ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_maps/textures/mcl_maps_map_filled_markings.png b/mods/ITEMS/mcl_maps/textures/mcl_maps_map_filled_markings.png new file mode 100644 index 0000000000000000000000000000000000000000..4f7e08cc18b32c907a4f5632d9db555da58f5472 GIT binary patch literal 15348 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}oCO|{#S9GG!XV7ZFl&wk z1B2Dc%#etZ2wxwokg&dz0$52&wylyQ$U=n(-v9;Y{GwC^Q#~`?WJ6;k1#?S1LsLs53lkj$BLhP- zeFGDHLrYylV=F^rD-#0+C{VKFQczH^DN0GR3UYCST33{kW~-D@Qc_^0uU}qXu2*iX zmtT~wZ)j<0sc&GUZ)Bufl#-@fT$xvrSfQI&tPC*(W{yj0adJ^+K}lwQo&w0+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PyF+4K7GH5J`>(7m)!4Q8pS}kZ>T991Sia0}7&S zG`Jw)KqNUDTto&GMA>L?LBfGZax}Pz3@C`Q(cprF1Ciuta1j|$5M`sm1qlZt$EYF>)1Qn`}7U6FoMA86ZavPY0F z14ET614BbI1H;e%3=9n~85l|p7#Ln9FfdrnU|pA>)8je&t-si%u$NX4x;*SxtJ z40u>B-1%>1>+5&1H0<#*-Gxz7+4c&NEG!2rj|HkQloXv{q4vYuS}vT`jI@0qx86boFyt=akR{05|iZ#Q*>R literal 0 HcmV?d00001 diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index da083bcd..bef53c08 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -148,9 +148,8 @@ minetest.register_on_joinplayer(function(player) -- Minecraft has no sneak glitch -- sneak is also disabled because it is buggy in Minetest (can be used to negate fall damage) player:set_physics_override({sneak_glitch=false}) - -- Minecraft also offers no minimap for free - player:hud_set_flags({minimap=false}) player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) + -- Note: Minimap is now handled in mcl_maps end) minetest.register_on_leaveplayer(function(player)