added new npcs + show anvil recipes in crafting guide
This commit is contained in:
parent
736c784af5
commit
bf15eca09c
@ -50,7 +50,7 @@ function crafting_guide.get_formspec(crafts,back_button)
|
|||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
function crafting_guide.get_furnace_formspec(recipe,back_button)
|
function crafting_guide.get_furnace_formspec(recipe, back_button)
|
||||||
local str = crafting_guide.form
|
local str = crafting_guide.form
|
||||||
if back_button then
|
if back_button then
|
||||||
str = crafting_guide.form_back
|
str = crafting_guide.form_back
|
||||||
@ -64,6 +64,20 @@ function crafting_guide.get_furnace_formspec(recipe,back_button)
|
|||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function crafting_guide.get_anvil_formspec(recipe, back_button)
|
||||||
|
local str = crafting_guide.form
|
||||||
|
if back_button then
|
||||||
|
str = crafting_guide.form_back
|
||||||
|
end
|
||||||
|
|
||||||
|
str = str .. "label[0,0;Anvil:]"
|
||||||
|
|
||||||
|
str = str .. "item_image_button[0,1;1,1;" .. recipe.input .. ";" .. recipe.input .. ";]"
|
||||||
|
str = str .. "item_image_button[2,1;1,1;" .. recipe.output .. ";" .. recipe.output .. ";]"
|
||||||
|
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
function crafting_guide.get_item_formspec(page, player)
|
function crafting_guide.get_item_formspec(page, player)
|
||||||
page = page or 0
|
page = page or 0
|
||||||
local str = crafting_guide.form_items
|
local str = crafting_guide.form_items
|
||||||
@ -86,7 +100,7 @@ function crafting_guide.get_item_formspec(page, player)
|
|||||||
table.sort(items)
|
table.sort(items)
|
||||||
|
|
||||||
for _,name in ipairs(items) do
|
for _,name in ipairs(items) do
|
||||||
if ((minetest.get_all_craft_recipes(name) or furnace.get_recipe(name)) or creative_priv) and
|
if ((minetest.get_all_craft_recipes(name) or furnace.get_recipe(name) or furnace.anvil.get_recipe(name)) or creative_priv) and
|
||||||
i < (8*6)*(page+1) then
|
i < (8*6)*(page+1) then
|
||||||
if i > (8*6)*(page)-1 then
|
if i > (8*6)*(page)-1 then
|
||||||
str = str .. "item_image_button["..x..","..y..";1,1;"..name..";"..name..";]"
|
str = str .. "item_image_button["..x..","..y..";1,1;"..name..";"..name..";]"
|
||||||
@ -193,6 +207,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_formspec(crafts,true))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_formspec(crafts,true))
|
||||||
elseif furnace.get_recipe(i) then
|
elseif furnace.get_recipe(i) then
|
||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_furnace_formspec(furnace.get_recipe(i),true))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_furnace_formspec(furnace.get_recipe(i),true))
|
||||||
|
elseif furnace.anvil.get_recipe(i) then
|
||||||
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_anvil_formspec(furnace.anvil.get_recipe(i),true))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -227,6 +243,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_formspec(crafts,true))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_formspec(crafts,true))
|
||||||
elseif furnace.get_recipe(i) then
|
elseif furnace.get_recipe(i) then
|
||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_furnace_formspec(furnace.get_recipe(i),true))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_furnace_formspec(furnace.get_recipe(i),true))
|
||||||
|
elseif furnace.anvil.get_recipe(i) then
|
||||||
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_anvil_formspec(furnace.anvil.get_recipe(i),true))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,6 +4,28 @@ function furnace.anvil.register_material(name, def)
|
|||||||
furnace.anvil.materials[name] = def
|
furnace.anvil.materials[name] = def
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function furnace.anvil.get_recipe(item)
|
||||||
|
-- search recipe for item
|
||||||
|
for i,recipe in pairs(furnace.anvil.materials) do
|
||||||
|
if item == recipe.items.rod then
|
||||||
|
return nil -- return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if item == recipe.items.plate then
|
||||||
|
return {input = recipe.items.rod, output = item} -- return recipe for item
|
||||||
|
end
|
||||||
|
|
||||||
|
if item == (recipe.items.blade or "none") then
|
||||||
|
return {input = recipe.items.rod, output = item} -- return recipe for item
|
||||||
|
end
|
||||||
|
|
||||||
|
if item == (recipe.items.other or "none") then
|
||||||
|
return {input = recipe.items.rod, output = item} -- return recipe for item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil -- no recipe found
|
||||||
|
end
|
||||||
|
|
||||||
-- formspec
|
-- formspec
|
||||||
|
|
||||||
local anvil_form = "size[8,9]"
|
local anvil_form = "size[8,9]"
|
||||||
|
@ -17,7 +17,7 @@ money.shop.offers = {
|
|||||||
{input="money:silver_coin 2", output="default:box"},
|
{input="money:silver_coin 2", output="default:box"},
|
||||||
{input="money:coin 1", output="default:pick"},
|
{input="money:coin 1", output="default:pick"},
|
||||||
{input="money:silver_coin 4", output="dungeons:custom_treasure_chest"},
|
{input="money:silver_coin 4", output="dungeons:custom_treasure_chest"},
|
||||||
{input="default:stone_item 891", output="money:silver_coin 5"}
|
{input="default:stone_item 999", output="money:silver_coin 5"}
|
||||||
}
|
}
|
||||||
|
|
||||||
function money.shop.get_formspec(page)
|
function money.shop.get_formspec(page)
|
||||||
|
@ -50,6 +50,15 @@ function npcs.register_npc(name, def)
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
quests.show_text(def.npc_text, name)
|
quests.show_text(def.npc_text, name)
|
||||||
end
|
end
|
||||||
|
elseif def.npc_type == "texts" then
|
||||||
|
def.on_rightclick = function(pos, node, player, itemstack, pt)
|
||||||
|
if quests.process_npc_goals(player:get_player_name(), "talk", pt.under) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
quests.show_text(def.npc_texts[math.random(#def.npc_texts)], name)
|
||||||
|
end
|
||||||
elseif def.npc_type == "quests" then
|
elseif def.npc_type == "quests" then
|
||||||
def.on_rightclick = function(pos, node, player, itemstack, pt)
|
def.on_rightclick = function(pos, node, player, itemstack, pt)
|
||||||
if quests.process_npc_goals(player:get_player_name(), "talk", pt.under) then
|
if quests.process_npc_goals(player:get_player_name(), "talk", pt.under) then
|
||||||
@ -115,17 +124,52 @@ minetest.register_abm({
|
|||||||
|
|
||||||
npcs.register_npc("npcs:farmer_1", {
|
npcs.register_npc("npcs:farmer_1", {
|
||||||
tiles = {"npc_1.png"},
|
tiles = {"npc_1.png"},
|
||||||
npc_type = "quest",
|
npc_type = "shop",
|
||||||
npc_get_quest = function(pos, player)
|
npc_text = "Hi! Do you want to buy an item?",
|
||||||
local quest = quests.new(nil, "Test", "Test")
|
npc_items = {
|
||||||
quest.id = tostring(minetest.get_day_count()) .. " " .. minetest.pos_to_string(pos)
|
{
|
||||||
local goal_1 = quests.add_place_goal(quest, "Place dirt", {"default:dirt"}, 1, "Place some dirt blocks!")
|
input = "money:silver_coin",
|
||||||
local goal_2 = quests.add_talk_goal(quest, "Talk", pos, "Place some dirt blocks!")
|
output = "farming:apple 9",
|
||||||
|
text = "1 Silver Coin -> 8 Apple",
|
||||||
|
}, {
|
||||||
|
input = "money:silver_coin 1",
|
||||||
|
output = "farming:slice_of_bread 9",
|
||||||
|
text = "4 Silver Coin -> 4 Slice of Bread",
|
||||||
|
}, {
|
||||||
|
input = "money:silver_coin 1",
|
||||||
|
output = "default:mushroom 2",
|
||||||
|
text = "1 Silver Coin -> 2 Mushroom",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
goal_2.requires = goal_1
|
npcs.register_npc("npcs:miner_1", {
|
||||||
|
tiles = {"npc_3.png"},
|
||||||
return quest
|
npc_type = "shop",
|
||||||
end,
|
npc_text = "Hi! Do you want to buy an item?",
|
||||||
|
npc_items = {
|
||||||
|
{
|
||||||
|
input = "money:silver_coin 10",
|
||||||
|
output = "furnace:furnace",
|
||||||
|
text = "10 Silver Coin -> 1 Furnace",
|
||||||
|
}, {
|
||||||
|
input = "money:silver_coin 10",
|
||||||
|
output = "furnace:anvil",
|
||||||
|
text = "10 Silver Coin -> 1 Anvil",
|
||||||
|
}, {
|
||||||
|
input = "money:silver_coin",
|
||||||
|
output = "torch:torch 4",
|
||||||
|
text = "1 Silver Coin -> 4 Torch",
|
||||||
|
}, {
|
||||||
|
input = "money:coin",
|
||||||
|
output = "default:pick",
|
||||||
|
text = "1 Gold Coin -> 1 Iron Pick",
|
||||||
|
}, {
|
||||||
|
input = "default:stone_item 999",
|
||||||
|
output = "money:silver_coin 5",
|
||||||
|
text = "999 Stone -> 5 Silver Coin",
|
||||||
|
}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
npcs.register_npc("npcs:hunter_1", {
|
npcs.register_npc("npcs:hunter_1", {
|
||||||
@ -143,6 +187,20 @@ npcs.register_npc("npcs:hunter_1", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
npcs.register_npc("npcs:builder_1", {
|
||||||
|
tiles = {"npc_4.png"},
|
||||||
|
npc_type = "texts",
|
||||||
|
npc_texts = {
|
||||||
|
"Hello!",
|
||||||
|
"Hi!",
|
||||||
|
"Hey!",
|
||||||
|
|
||||||
|
"Hello.\nHow are you?",
|
||||||
|
"Hi.\nHow are you?",
|
||||||
|
"Hey.\nHow are you?",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
--TEST
|
--TEST
|
||||||
--npcs.register_npc("npcs:farmer", {
|
--npcs.register_npc("npcs:farmer", {
|
||||||
-- tiles = {"npc_1.png"},
|
-- tiles = {"npc_1.png"},
|
||||||
|
BIN
mods/npcs/textures/npc_3.png
Normal file
BIN
mods/npcs/textures/npc_3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
BIN
mods/npcs/textures/npc_4.png
Normal file
BIN
mods/npcs/textures/npc_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 315 B |
Loading…
x
Reference in New Issue
Block a user