diff --git a/mods/anvil/init.lua b/mods/anvil/init.lua index 7aaf04f..ee65ecd 100644 --- a/mods/anvil/init.lua +++ b/mods/anvil/init.lua @@ -1,6 +1,8 @@ anvil = {} realtest.registered_anvil_recipes = {} +local F = minetest.formspec_escape + function realtest.register_anvil_recipe(RecipeDef) local recipe = { type = RecipeDef.type or "forge", @@ -390,7 +392,12 @@ realtest.show_craft_guide_anvil = function( player, formname, fields) if( plan.type and plan.type=="weld" ) then how_to = "Weld"; end - + + local f_output = "" + if plan.output and minetest.registered_items[plan.output] then + f_output = "item_image[3.5,2.0;1,1;"..plan.output.."]".. + "tooltip[3.5,2;0.8,0.9;"..F(minetest.registered_items[plan.output].description).."]" + end local formspec = "size[12,8]".. "label[1.5,-0.2;"..how_to.." "..tostring(stack:get_count()).."x "..name.." this way (click on "..how_to.."):]".. @@ -413,7 +420,7 @@ realtest.show_craft_guide_anvil = function( player, formname, fields) "box[2.9,0.75;0.8,0.9;#BBBBBB]".. "box[4.1,0.75;0.8,0.9;#BBBBBB]".. "box[3.5,1.99;0.8,0.9;#BBBBBB]".. - "item_image[3.5,2.0;1,1;"..plan.output.."]".. + f_output.. -- the 4 simulated slots for the instruments "box[1.0,1.99;0.8,0.9;#BBBBBB]".. "box[6.0,1.99;0.8,0.9;#BBBBBB]".. @@ -425,7 +432,8 @@ realtest.show_craft_guide_anvil = function( player, formname, fields) -- show the indigrents if( plan.item1 and plan.item1 ~= "" and minetest.registered_items[ plan.item1 ]) then - local button = "item_image[2.9,0.75;1,1;"..plan.item1.."]"; + local button = "item_image[2.9,0.75;1,1;"..plan.item1.."]".. + "tooltip[2.9,0.75;0.8,0.9;"..F(minetest.registered_items[plan.item1].description).."]" for _, v in ipairs(realtest.registered_anvil_recipes) do if( v.output == plan.item1 ) then button = "item_image_button[2.9,0.75;1,1;"..v.output..";"..v.output..";]"; @@ -435,7 +443,8 @@ realtest.show_craft_guide_anvil = function( player, formname, fields) end -- the second slot usually takes a plan if( plan.item2 and plan.item2 ~= "" and minetest.registered_items[ plan.item2 ]) then - local button = "item_image[4.1,0.75;1,1;"..plan.item2.."]"; + local button = "item_image[4.1,0.75;1,1;"..plan.item2.."]".. + "tooltip[4.1,0.75;0.8,0.9;"..F(minetest.registered_items[plan.item2].description).."]" for _, v in ipairs(realtest.registered_anvil_recipes) do if( v.output == plan.item2 ) then button = "item_image_button[4.1,0.75;1,1;"..v.output..";"..v.output..";]"; @@ -469,7 +478,8 @@ realtest.show_craft_guide_anvil = function( player, formname, fields) end -- welding requires flux if( plan.type and plan.type=="weld") then - formspec = formspec.."item_image[6.0,2.0;1,1;minerals:flux]"; + formspec = formspec.."item_image[6.0,2.0;1,1;minerals:flux]".. + "tooltip[6,2;0.8,0.9;"..minetest.registered_items["minerals:flux"].description.."]" end diff --git a/mods/joiner_table/init.lua b/mods/joiner_table/init.lua index db414f4..6e91d05 100644 --- a/mods/joiner_table/init.lua +++ b/mods/joiner_table/init.lua @@ -1,6 +1,8 @@ joiner_table = {} realtest.registered_joiner_table_recipes = {} +local F = minetest.formspec_escape + function realtest.register_joiner_table_recipe(RecipeDef) local recipe = { item1 = RecipeDef.item1 or "", @@ -175,6 +177,9 @@ realtest.show_craft_guide_joiner_table = function( player, formname, fields) name = plan.output; end + local item_output = ItemStack(plan.output):get_name() + local f_output = "item_image[4.5,2;1,1;"..plan.output.."]".. + "tooltip[4.5,2;0.8,0.9;"..F(minetest.registered_items[item_output].description).."]" local formspec = "size[8,9]".. @@ -194,27 +199,28 @@ realtest.show_craft_guide_joiner_table = function( player, formname, fields) "box[3.9,0.75;0.8,0.9;#BBBBBB]".. "box[5.1,0.75;0.8,0.9;#BBBBBB]".. "box[4.5,1.98;0.8,0.9;#BBBBBB]".. - "item_image[4.5,2;1,1;"..plan.output.."]".. + f_output.. -- the 4 simulated slots for the instruments "box[0.5,1.5;0.8,0.9;#BBBBBB]".. "box[0.5,2.5;0.8,0.9;#BBBBBB]".. "box[1.5,1.5;0.8,0.9;#BBBBBB]".. "box[1.5,2.5;0.8,0.9;#BBBBBB]".. - -- some receipes output more of the same item than just one - "label[4.0,2.5;"..tostring(stack:get_count()).."x]".. "label[0,3.5;Select receipe to show:]"; -- show the indigrents if( plan.item1 and plan.item1 ~= "" and minetest.registered_items[ plan.item1 ]) then - formspec = formspec.."item_image[3.9,0.75;1,1;"..plan.item1.."]"; + formspec = formspec.."item_image[3.9,0.75;1,1;"..plan.item1.."]".. + "tooltip[3.9,0.75;0.8,0.9;"..F(minetest.registered_items[plan.item1].description).."]" end -- the second slot usually takes a plan if( plan.item2 and plan.item2 ~= "" and minetest.registered_items[ plan.item2 ]) then - formspec = formspec.."item_image[5.1,0.75;1,1;"..plan.item2.."]"; + formspec = formspec.."item_image[5.1,0.75;1,1;"..plan.item2.."]".. + "tooltip[5.1,0.75;0.8,0.9;"..F(minetest.registered_items[plan.item2].description).."]" end -- show the instrument needed if( plan.instrument and plan.instrument ~= "" and minetest.registered_items[ "instruments:"..plan.instrument.."_copper" ]) then - formspec = formspec.."item_image[1.5,1.5;1,1;instruments:"..plan.instrument.."_copper]"; + formspec = formspec.."item_image[1.5,1.5;1,1;instruments:"..plan.instrument.."_copper]".. + "tooltip[1.5,1.5;0.8,0.9;"..F(minetest.registered_items["instruments:"..plan.instrument.."_copper"].description).."]" -- show error message for unkown tools elseif( plan.instrument and plan.instrument ~= "" ) then formspec = formspec.."label[0.5,2.5;ERROR]"; diff --git a/mods/scribing_table/init.lua b/mods/scribing_table/init.lua index 68c5d4e..9306ff5 100644 --- a/mods/scribing_table/init.lua +++ b/mods/scribing_table/init.lua @@ -1,5 +1,7 @@ scribing_table = {} +local F = minetest.formspec_escape + realtest.registered_instrument_plans = {} function realtest.register_instrument_plan(name, PlanDef) if PlanDef.bitmap then @@ -282,7 +284,9 @@ realtest.show_craft_guide_scribing_table = function( player, formname, fields) "box[6.5,0.5;0.8,0.9;#BBBBBB]".. "box[6.5,4.5;0.8,0.9;#BBBBBB]".. "item_image[6.5,0.5;1,1;"..plan.paper.."]".. + "tooltip[6.5,0.5;0.8,0.9;"..F(minetest.registered_items[plan.paper].description).."]".. "item_image[6.5,4.5;1,1;"..plan.name.."]".. + "tooltip[6.5,4.5;0.8,0.9;"..F(minetest.registered_items[plan.name].description).."]".. "image[5.5,1.5;2,3.4;scribing_table_arrow.png]".. "label[0,5.5;Select plan to show:]"; @@ -294,7 +298,8 @@ realtest.show_craft_guide_scribing_table = function( player, formname, fields) -- show symbolic green dye where needed (green is cheapest) if( plan.bitmap[ x+5*(y-1)]==1 ) then formspec = formspec.. - "item_image["..(-0.5+x)..","..(-0.5+y)..";1,1;dye:green]"; + "item_image["..(-0.5+x)..","..(-0.5+y)..";1,1;dye:green]".. + "tooltip["..(-0.5+x)..","..(-0.5+y)..";0.8,0.9;Any dye]" end end end