mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-08-19 05:24:11 +02:00
Add new compass API.
* Add API.md * Update mcl_itemframes to use the new API. * Revert old exported function back to original API.
This commit is contained in:
parent
a8c231da34
commit
8a4b8707fa
20
mods/ITEMS/mcl_compass/API.md
Normal file
20
mods/ITEMS/mcl_compass/API.md
Normal file
@ -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
|
||||
|
||||
-- Export stereotype item for other mods to use
|
||||
mcl_compass.stereotype = "mcl_compass:" .. stereotype_frame
|
||||
|
||||
--- Get partial compass itemname.
|
||||
-- Returns partial itemname of a compass with needle direction matching compass position.
|
||||
-- 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 " ..
|
||||
"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)
|
||||
if itemstack:get_meta():get_string("pointsto") ~= "" then
|
||||
return frame .. "_lodestone"
|
||||
else
|
||||
return frame
|
||||
end
|
||||
end
|
||||
|
||||
--- Get compass itemname.
|
||||
@ -248,9 +246,6 @@ minetest.register_craft({
|
||||
|
||||
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",{
|
||||
description=S("Lodestone"),
|
||||
|
@ -222,7 +222,7 @@ minetest.register_node("mcl_itemframes:item_frame",{
|
||||
put_itemstack:set_count(1)
|
||||
local itemname = put_itemstack:get_name()
|
||||
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
|
||||
if minetest.get_item_group(itemname, "clock") > 0 then
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
|
Loading…
Reference in New Issue
Block a user