added crafting guide button to inventory

This commit is contained in:
cale 2017-01-01 12:37:35 +01:00
parent 7d05b95fd5
commit 010ff20e37
3 changed files with 18 additions and 1 deletions

View File

@ -256,3 +256,11 @@ minetest.register_craftitem("crafting_guide:book", {
minetest.show_formspec(user:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(0, user))
end
})
default.player_inventory.get_tab("Crafting").on_event = function(player, fields)
if fields.crafting_guide then
crafting_guide.pages[player:get_player_name()] = 0
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(0, player))
end
end

View File

@ -8,6 +8,14 @@ function default.player_inventory.register_tab(def)
table.insert(default.player_inventory.tabs, def)
end
function default.player_inventory.get_tab(name)
for i,v in ipairs(default.player_inventory.tabs) do
if v.name == name then
return v
end
end
end
function default.player_inventory.get_formspec(tab, name)
if not(default.player_inventory.tabs[tab]) then
return ""
@ -139,6 +147,7 @@ default.inv_form = default.inv_form.."list[current_player;craftpreview;5.5,1;1,1
default.inv_form = default.inv_form..default.itemslot_bg(5.5,1,1,1)
default.inv_form = default.inv_form.."listring[current_player;craft]"
default.inv_form = default.inv_form.."listring[current_player;main]"
default.inv_form = default.inv_form.."button[0,2.5;1,1;crafting_guide;?]"
default.player_inventory.register_tab({
name = "Crafting",

View File

@ -352,7 +352,7 @@ minetest.register_on_newplayer(function(player)
local q6 = quests.add_dig_goal(quest, "Harvest Logs", {"default:log","default:log_1","default:log_2","default:log_3", "default:jungle_tree"}, 20, "You can use the Stone Axe to harvest logs.")
local q7 = quests.add_dig_goal(quest, "Mine Stone", {"default:stone"}, 20, "You can also mine Stone with your Stone Axe.")
local q8 = quests.add_craft_goal(quest, "Craft a Flint Pick", {"default:flint_pick"}, 1, "Craft a Flint Pick!", "You can use the flint pick to dig harder blocks.")
local q9 = quests.add_dig_goal(quest, "Mine Iron", {"default:stone_with_iron"}, 2, "Your Flint Pick is strong enough to mine Iron.", "Great! You should be on level 2 now.\nEvery time you level up you can upgrade on of your skills.\nTry out /skill warrior or /skill miner\n")
local q9 = quests.add_dig_goal(quest, "Mine Iron", {"default:stone_with_iron"}, 2, "Your Flint Pick is strong enough to mine Iron.", "Great! It is time to upgrade your skills now!\nGoto the skills tab in your inventory\nand level up a skill!")
q3.reward = "default:wood_tutorial 3"