diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index a7c949b8c5..e0c41c1f44 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -12,13 +12,13 @@ mcl_itemframes.create_base_definitions() -- necessary to maintain compatibility amongst older versions. mcl_itemframes.backwards_compatibility() --- test for the create custom frame +-- Define the standard frames. mcl_itemframes.create_custom_frame("false", "item_frame", false, "mcl_itemframes_item_frame.png", mcl_colors.WHITE, "Item Frame", - "Can hold an item.") + "Can hold an item.","") mcl_itemframes.create_custom_frame("false", "glow_item_frame", true, "mcl_itemframes_glow_item_frame.png", mcl_colors.WHITE, "Glowing Item Frame", - "Can hold an item and glows.") + "Can hold an item and glows.","") -- Register the base frame's recipes. -- was going to make it a specialized function, but minetest refuses to play nice. diff --git a/mods/ITEMS/mcl_itemframes/item_frames_API.lua b/mods/ITEMS/mcl_itemframes/item_frames_API.lua index 9173192bb5..bd78f33e1c 100644 --- a/mods/ITEMS/mcl_itemframes/item_frames_API.lua +++ b/mods/ITEMS/mcl_itemframes/item_frames_API.lua @@ -445,8 +445,8 @@ function mcl_itemframes.create_custom_items(name, has_glow) minetest.log("action", "[mcl_itemframes] create_custom_item_entity: name: " .. name .. "_map\n") end end - minetest.register_entity(name .. "_item", custom_frame_item) - minetest.register_entity(name .. "_map", custom_frame_map_item) + minetest.register_entity(":" .. name .. "_item", custom_frame_item) + minetest.register_entity(":" .. name .. "_map", custom_frame_map_item) end function mcl_itemframes.update_frame_registry(modname, name, has_glow) @@ -470,8 +470,8 @@ function mcl_itemframes.update_frame_registry(modname, name, has_glow) end --- name: The name used to distinguish the item frame. Prepends "mcl_itemframes:" to the name. Example usage: ---- "glow_item_frame" creates a node named "mcl_itemframes:glow_item_frame". -function mcl_itemframes.create_custom_frame(modname, name, has_glow, tiles, color, ttframe, description) +--- "glow_item_frame" creates a node named ":mcl_itemframes:glow_item_frame". +function mcl_itemframes.create_custom_frame(modname, name, has_glow, tiles, color, ttframe, description, inv_wield_image) local mod_name_pass = false if modname ~= "" and modname ~= "false" then if minetest.get_modpath(modname) then @@ -517,11 +517,16 @@ function mcl_itemframes.create_custom_frame(modname, name, has_glow, tiles, colo custom_itemframe_definition = table.copy(mcl_itemframes.glow_frame_base) end + if inv_wield_image ~= nil and inv_wield_image ~= "" then + custom_itemframe_definition.glow_frame_base.inventory_image = { "(" .. inv_wield_image .. "^[multiply:" .. color .. ")" } + custom_itemframe_definition.glow_frame_base.wield_image = { "(" .. inv_wield_image .. "^[multiply:" .. color .. ")" } + end + custom_itemframe_definition.tiles = { "(" .. tiles .. "^[multiply:" .. color .. ")" } custom_itemframe_definition._tt_help = ttframe custom_itemframe_definition.description = description - minetest.register_node(working_name, custom_itemframe_definition) + minetest.register_node(":" .. working_name, custom_itemframe_definition) mcl_itemframes.update_frame_registry(modname, working_name, has_glow) mcl_itemframes.custom_register_lbm(working_name) @@ -802,7 +807,7 @@ function mcl_itemframes.backwards_compatibility () }) minetest.register_alias("itemframes:frame", "mcl_itemframes:item_frame") - -- To be installed when complete; adds backwards compatibility + -- adds backwards compatibility minetest.register_alias("mcl_itemframes:item", "mcl_itemframes:item_frame_item") minetest.register_alias("mcl_itemframes:map", "mcl_itemframes:item_frame_map") minetest.register_alias("mcl_itemframes:glow_item", "mcl_itemframes:glow_item_frame_item") diff --git a/mods/ITEMS/mcl_itemframes/item_frames_api_doc.txt b/mods/ITEMS/mcl_itemframes/item_frames_api_doc.txt new file mode 100644 index 0000000000..7510b15b53 --- /dev/null +++ b/mods/ITEMS/mcl_itemframes/item_frames_api_doc.txt @@ -0,0 +1,36 @@ +The item frames use case is a very specific one, but... in the event that there is need for a new item frame then that +is where this api will shine. + +As long as the api has been initialized (which it does in its own init.lua) then you really only need to call one +function. That function being mcl_itemframes.create_custom_frame(modname, name, has_glow, tiles, color, ttframe, +description, inv_wield_image). Note: unlike the Signs API, this API does not automatically create the recipe for you. + +Here's an explanation of create_custom_frame and an example of using it. + +This function is responsible for creating each frame, and handling the creation of its underlying entities. + +Parameters: +* modname: Used to make sure that a specific module is installed before running the code contained within. Set to "" or + false, if there's not a mod to check for. +* name: The name used to distinguish the item frame. Prepends "mcl_itemframes:" to the name. Example usage: + "glow_item_frame" creates a node named "mcl_itemframes:glow_item_frame". +* has_glow: Does the frame cause the item within to glow? true / false. +* tiles: The image files used for the item frame's object texturing. +* color: Colorizes the frame / wield / inventory image to a specific color. Use White (#FFFFFF) to ignore. +* ttframe: The tooltip to show for the frame. +* description: The frame's description. +* inv_wield_image: Optionally the image to use as the inventory and the wield image. Colorized. set to "" or nil to use + the default frame / glow frame images. Note: must be set if you want the inventory / wield image to be colored. + +example: +-- Register the Glow Frame +mcl_itemframes.create_custom_frame("false", "glow_item_frame", true, + "mcl_itemframes_glow_item_frame.png", mcl_colors.WHITE, "Glowing Item Frame", + "Can hold an item and glows.","") + +-- Register the Glow Frame's recipe +minetest.register_craft({ + type = "shapeless", + output = 'mcl_itemframes:glow_item_frame', + recipe = { 'mcl_mobitems:glow_ink_sac', 'mcl_itemframes:item_frame' }, +})