2015-09-01 17:15:24 +02:00
|
|
|
-- Compass handling
|
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
local wield_image_0 = "nav_compass_inventory_0.png"
|
|
|
|
local wield_image_1 = "nav_compass_inventory_1.png"
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_0",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(E)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_0.png^[transformR90",
|
|
|
|
wield_image = wield_image_0 .. "^[transformR90",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_1",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(NE)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_1.png^[transformR90",
|
|
|
|
wield_image = wield_image_1 .. "^[transformR90",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_2",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(N)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_0.png",
|
|
|
|
wield_image = wield_image_0,
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_3",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(NW)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_1.png",
|
|
|
|
wield_image = wield_image_1,
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_4",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(W)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_0.png^[transformR270",
|
|
|
|
wield_image = wield_image_0 .. "^[transformR270",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_5",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(SW)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_1.png^[transformR270",
|
|
|
|
wield_image = wield_image_1 .. "^[transformR270",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_6",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(S)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_0.png^[transformR180",
|
|
|
|
wield_image = wield_image_0 .. "^[transformR180",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craftitem(
|
2015-09-01 17:15:24 +02:00
|
|
|
"nav:compass_7",
|
|
|
|
{
|
2015-10-20 21:00:54 +02:00
|
|
|
description = "Compass(SE)",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-20 21:00:54 +02:00
|
|
|
inventory_image = "nav_compass_inventory_1.png^[transformR180",
|
|
|
|
wield_image = wield_image_1 .. "^[transformR180",
|
2015-09-01 17:15:24 +02:00
|
|
|
|
|
|
|
groups = {nav_compass = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
})
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_alias("nav:compass", "nav:compass_2")
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_craft(
|
2015-09-01 17:15:24 +02:00
|
|
|
{
|
|
|
|
output = "nav:compass_2",
|
|
|
|
recipe = {
|
|
|
|
{"", "default:ingot_carbonsteel", ""},
|
|
|
|
{"default:ingot_steel", "default:stick", "default:ingot_steel"},
|
|
|
|
{"", "default:ingot_steel", ""},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function step(dtime)
|
2017-05-12 04:29:55 +02:00
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
2015-09-01 17:15:24 +02:00
|
|
|
local inv = player:get_inventory()
|
|
|
|
|
|
|
|
local yaw = player:get_look_yaw()
|
|
|
|
local dir = math.floor(((yaw / math.pi) * 4) + 0.5)
|
|
|
|
|
|
|
|
if dir < 0 then
|
|
|
|
dir = dir + 8
|
|
|
|
end
|
|
|
|
|
|
|
|
if dir >= 8 then
|
|
|
|
dir = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = 1, 8 do
|
|
|
|
local itemstack = inv:get_stack("main", i)
|
2017-05-12 04:29:55 +02:00
|
|
|
local item = minetest.registered_items[itemstack:get_name()]
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2015-10-13 00:24:37 +02:00
|
|
|
if item ~= nil then
|
|
|
|
if item.groups.nav_compass then
|
|
|
|
inv:set_stack("main", i, ItemStack("nav:compass_"..dir))
|
|
|
|
end
|
2015-09-01 17:15:24 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_globalstep(step)
|
2015-10-25 22:18:54 +01:00
|
|
|
|
|
|
|
-- Achievements
|
|
|
|
|
|
|
|
achievements.register_achievement(
|
|
|
|
"true_navigator",
|
|
|
|
{
|
|
|
|
title = "True Navigator",
|
|
|
|
description = "Craft a compass",
|
|
|
|
times = 1,
|
2015-11-09 20:16:25 +01:00
|
|
|
craftitem = "nav:compass_2",
|
2015-10-25 22:18:54 +01:00
|
|
|
})
|