From c4b0a116bbee02e50644113bb3382dd45140c633 Mon Sep 17 00:00:00 2001 From: cale Date: Wed, 28 Dec 2016 11:08:51 +0100 Subject: [PATCH] added custom treasure chest --- mods/dungeons/depends.txt | 1 + mods/dungeons/init.lua | 39 +++++++++++++++++++++++++++++++++++++++ mods/money/init.lua | 4 +++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 mods/dungeons/depends.txt diff --git a/mods/dungeons/depends.txt b/mods/dungeons/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/dungeons/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/dungeons/init.lua b/mods/dungeons/init.lua index ee9f194..325e832 100644 --- a/mods/dungeons/init.lua +++ b/mods/dungeons/init.lua @@ -15,3 +15,42 @@ minetest.register_on_generated(function(minp, maxp, seed) end, table.copy(g.dungeon)) end end) + +local chest_form = "size[8,7]" +local chest_form = chest_form..default.gui_colors +local chest_form = chest_form..default.gui_bg +local chest_form = chest_form.."list[current_name;main;0,0.3;8,2;]" +local chest_form = chest_form..default.itemslot_bg(0,0.3,8,2) +local chest_form = chest_form.."list[current_player;main;0,2.85;8,1;]" +local chest_form = chest_form..default.itemslot_bg(0,2.85,8,1) +local chest_form = chest_form.."list[current_player;main;0,4.08;8,3;8]" +local chest_form = chest_form..default.itemslot_bg(0,4.08,8,3) +local chest_form = chest_form.."listring[current_name;main]" +local chest_form = chest_form.."listring[current_player;main]" + +minetest.register_node("dungeons:custom_treasure_chest", { + description = "Custom Treasure Chest", + tiles = {"default_treasure_chest.png"}, + groups = {choppy = 3}, + + after_place_node = function(pos, placer, itemstack, pt) + local name = placer:get_player_name() + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + + inv:set_size("main", 8 * 2) + + meta:set_string("owner", name) + meta:set_string("infotext", "Custom Treasure Chest (" .. name .. ")") + meta:set_string("formspec", chest_form) + + itemstack:take_item() + return itemstack + end, + + on_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local name = player:get_player_name() + end, +}) diff --git a/mods/money/init.lua b/mods/money/init.lua index e8e5f2a..768b5ab 100644 --- a/mods/money/init.lua +++ b/mods/money/init.lua @@ -15,7 +15,9 @@ money.shop.page = {} money.shop.offers = { {input="money:silver_coin", output="default:coal_lump"}, {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="default:stone_item 891", output="money:silver_coin 5"} } function money.shop.get_formspec(page)