forked from VoxeLibre/VoxeLibre
update fork #6
|
@ -0,0 +1,20 @@
|
||||||
|
# mcl_compass
|
||||||
|
|
||||||
|
# Compass API
|
||||||
|
|
||||||
|
##mcl_compass.stereotype = "mcl_compass:" .. stereotype_frame
|
||||||
|
Default compass craftitem. This is also the image that is shown in the inventory.
|
||||||
|
|
||||||
|
##mcl_compass/init.lua:function mcl_compass.get_compass_itemname(pos, dir, itemstack)
|
||||||
|
Returns the itemname of a compass with needle direction matching the
|
||||||
|
current compass position.
|
||||||
|
|
||||||
|
pos: position of the compass;
|
||||||
|
dir: rotational orientation of the compass;
|
||||||
|
itemstack: the compass including its optional lodestone metadata.
|
||||||
|
|
||||||
|
##mcl_compass/init.lua:function mcl_compass.get_compass_image(pos, dir)
|
||||||
|
-- Returns partial itemname of a compass with needle direction matching compass position.
|
||||||
|
-- Legacy compatibility function for mods using older api.
|
||||||
|
|
||||||
|
|
|
@ -118,20 +118,18 @@ local function get_compass_frame(pos, dir, itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Export stereotype item for other mods to use
|
||||||
|
mcl_compass.stereotype = "mcl_compass:" .. stereotype_frame
|
||||||
|
|
||||||
--- Get partial compass itemname.
|
--- Get partial compass itemname.
|
||||||
-- Returns partial itemname of a compass with needle direction matching compass position.
|
-- Returns partial itemname of a compass with needle direction matching compass position.
|
||||||
-- Legacy compatibility function for mods using older api.
|
-- Legacy compatibility function for mods using older api.
|
||||||
--
|
--
|
||||||
function mcl_compass.get_compass_image(pos, dir, itemstack)
|
function mcl_compass.get_compass_image(pos, dir)
|
||||||
minetest.log("warning", "mcl_compass: deprecated function " ..
|
minetest.log("warning", "mcl_compass: deprecated function " ..
|
||||||
"get_compass_image() called, use get_compass_itemname().")
|
"get_compass_image() called, use get_compass_itemname().")
|
||||||
local itemstack = ItemStack("mcl_compass:" .. stereotype_frame)
|
local itemstack = ItemStack(mcl_compass.stereotype)
|
||||||
local frame = get_compass_frame(pos, dir, itemstack)
|
local frame = get_compass_frame(pos, dir, itemstack)
|
||||||
if itemstack:get_meta():get_string("pointsto") ~= "" then
|
|
||||||
return frame .. "_lodestone"
|
|
||||||
else
|
|
||||||
return frame
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get compass itemname.
|
--- Get compass itemname.
|
||||||
|
@ -248,9 +246,6 @@ minetest.register_craft({
|
||||||
|
|
||||||
minetest.register_alias("mcl_compass:compass", "mcl_compass:" .. stereotype_frame)
|
minetest.register_alias("mcl_compass:compass", "mcl_compass:" .. stereotype_frame)
|
||||||
|
|
||||||
-- Export stereotype item for other mods to use
|
|
||||||
mcl_compass.stereotype = "mcl_compass:" .. stereotype_frame
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("mcl_compass:lodestone",{
|
minetest.register_node("mcl_compass:lodestone",{
|
||||||
description=S("Lodestone"),
|
description=S("Lodestone"),
|
||||||
|
|
|
@ -222,7 +222,7 @@ minetest.register_node("mcl_itemframes:item_frame",{
|
||||||
put_itemstack:set_count(1)
|
put_itemstack:set_count(1)
|
||||||
local itemname = put_itemstack:get_name()
|
local itemname = put_itemstack:get_name()
|
||||||
if minetest.get_item_group(itemname, "compass") > 0 then
|
if minetest.get_item_group(itemname, "compass") > 0 then
|
||||||
put_itemstack:set_name("mcl_compass:" .. mcl_compass.get_compass_image(pos, minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2)), put_itemstack))
|
put_itemstack:set_name(mcl_compass.get_compass_itemname(pos, minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2)), put_itemstack))
|
||||||
end
|
end
|
||||||
if minetest.get_item_group(itemname, "clock") > 0 then
|
if minetest.get_item_group(itemname, "clock") > 0 then
|
||||||
minetest.get_node_timer(pos):start(1.0)
|
minetest.get_node_timer(pos):start(1.0)
|
||||||
|
|
Loading…
Reference in New Issue