-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
80 lines (54 loc) · 1.56 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- map/init.lua
-- Mod global namespace
map = {}
-- Load support for MT game translation.
local S = minetest.get_translator("map")
-- Update HUD flags
-- Global to allow overriding
function map.update_hud_flags(player)
local creative_enabled = minetest.is_creative_enabled(player:get_player_name())
local minimap_enabled = creative_enabled or
player:get_inventory():contains_item("main", "map:mapping_kit")
local radar_enabled = creative_enabled
player:hud_set_flags({
minimap = minimap_enabled,
minimap_radar = radar_enabled
})
end
-- Set HUD flags 'on joinplayer'
minetest.register_on_joinplayer(function(player)
map.update_hud_flags(player)
end)
-- Cyclic update of HUD flags
local function cyclic_update()
for _, player in ipairs(minetest.get_connected_players()) do
map.update_hud_flags(player)
end
minetest.after(5.3, cyclic_update)
end
minetest.after(5.3, cyclic_update)
-- Mapping kit item
minetest.register_craftitem("map:mapping_kit", {
description = S("Mapping Kit") .. "\n" .. S("Use with 'Minimap' key"),
inventory_image = "map_mapping_kit.png",
stack_max = 1,
groups = {flammable = 3, tool = 1},
on_use = function(itemstack, user, pointed_thing)
map.update_hud_flags(user)
end,
})
-- Crafting
minetest.register_craft({
output = "map:mapping_kit",
recipe = {
{"default:glass", "default:paper", "group:stick"},
{"default:steel_ingot", "default:paper", "default:steel_ingot"},
{"group:wood", "default:paper", "dye:black"},
}
})
-- Fuel
minetest.register_craft({
type = "fuel",
recipe = "map:mapping_kit",
burntime = 5,
})