From 0d14f9fc5ecbd0a604845b81058a573482bd99ee Mon Sep 17 00:00:00 2001 From: jasonl8446 Date: Sun, 19 Feb 2023 18:43:15 -0500 Subject: [PATCH] Added a drop on use for each card --- README.md | 1 - init.lua | 74 ++++++++++++++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 88fa2a6..8478b90 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ TODO: - Crafting Recipe (Figure out what I want it to be or if there will be a recipe) - Make card pack drop items instead of adding directly to inventory. - Add pack to dungeon loot -- Decide if I want cards to drop the item that it is (example: Apple Tree card on use give apple tree log) - Better Card art - Add other cards based on other mods (and figure out what those cards will be) - Blobcat Cards diff --git a/init.lua b/init.lua index 79ecd76..df3a243 100644 --- a/init.lua +++ b/init.lua @@ -2,55 +2,55 @@ common_cards = { {name = "card_default_tree", description = "Apple Tree Card\nMTG Card #1", on_use_item = "default:tree 5"}, {name = "card_default_acacia_tree", description = "Acacia Tree Card\nMTG Card #2", on_use_item = "default:acacia_tree 5"}, {name = "card_default_aspen_tree", description = "Aspen Tree Card\nMTG Card #3", on_use_item = "default:aspen_tree 5"}, - {name = "card_default_jungle_tree", description = "Jungle Tree Card\nMTG Card #4", on_use_item = "default:jungle_tree 5"}, + {name = "card_default_jungle_tree", description = "Jungle Tree Card\nMTG Card #4", on_use_item = "default:jungletree 5"}, {name = "card_default_pine_tree", description = "Pine Tree Card\nMTG Card #5", on_use_item = "default:pine_tree 5"}, - {name = "card_default_tool_stone_pickaxe", description = "Stone Pickaxe Card\nMTG Card #6", on_use_item = "default:tool_stone 1"}, - {name = "card_default_tool_stone_axe", description = "Stone Axe Card\nMTG Card #7", on_use_item = "default:tool_stone 1"}, - {name = "card_default_tool_stone_sword", description = "Stone Sword Card\nMTG Card #8", on_use_item = "default:tool_stone 1"}, - {name = "card_default_tool_stone_shovel", description = "Stone Shovel Card\nMTG Card #9", on_use_item = "default:tool_stone 1"}, + {name = "card_default_tool_stone_pickaxe", description = "Stone Pickaxe Card\nMTG Card #6", on_use_item = "default:pick_stone 1"}, + {name = "card_default_tool_stone_axe", description = "Stone Axe Card\nMTG Card #7", on_use_item = "default:axe_stone 1"}, + {name = "card_default_tool_stone_sword", description = "Stone Sword Card\nMTG Card #8", on_use_item = "default:sword_stone 1"}, + {name = "card_default_tool_stone_shovel", description = "Stone Shovel Card\nMTG Card #9", on_use_item = "default:shovel_stone 1"}, - {name = "card_default_tool_wood_pickaxe", description = "Wood Pickaxe Card\nMTG Card #10", on_use_item = "default:tool_wood 1"}, - {name = "card_default_tool_wood_axe", description = "Wood Axe Card\nMTG Card #11", on_use_item = "default:tool_wood 1"}, - {name = "card_default_tool_wood_sword", description = "Wood Sword Card\nMTG Card #12", on_use_item = "default:tool_wood 1"}, - {name = "card_default_tool_wood_shovel", description = "Wood Shovel Card\nMTG Card #13", on_use_item = "default:tool_wood 1"}, + {name = "card_default_tool_wood_pickaxe", description = "Wood Pickaxe Card\nMTG Card #10", on_use_item = "default:pick_wood 1"}, + {name = "card_default_tool_wood_axe", description = "Wood Axe Card\nMTG Card #11", on_use_item = "default:axe_wood 1"}, + {name = "card_default_tool_wood_sword", description = "Wood Sword Card\nMTG Card #12", on_use_item = "default:sword_wood 1"}, + {name = "card_default_tool_wood_shovel", description = "Wood Shovel Card\nMTG Card #13", on_use_item = "default:shovel_stone 1"}, - {name = "card_default_coal_lump", description = "Coal Card\nMTG Card #14", on_use_item = "default: 5"}, - {name = "card_default_copper_lump", description = "Copper Card\nMTG Card #15", on_use_item = "default: 5"}, - {name = "card_default_iron_lump", description = "Iron Card\nMTG Card #16", on_use_item = "default: 5"}, - {name = "card_default_tin_lump", description = "Tin Card\nMTG Card #17", on_use_item = "default: 5"}, + {name = "card_default_coal_lump", description = "Coal Card\nMTG Card #14", on_use_item = "default:coal_lump 5"}, + {name = "card_default_copper_lump", description = "Copper Card\nMTG Card #15", on_use_item = "default:copper_lump 5"}, + {name = "card_default_iron_lump", description = "Iron Card\nMTG Card #16", on_use_item = "default:iron_lump 5"}, + {name = "card_default_tin_lump", description = "Tin Card\nMTG Card #17", on_use_item = "default:tin_lump 5"}, } uncommon_cards = { - {name = "card_default_tool_bronze_pickaxe", description = "Bronze Pickaxe Card\nMTG Card #18"}, - {name = "card_default_tool_bronze_axe", description = "Bronze Axe Card\nMTG Card #19"}, - {name = "card_default_tool_bronze_sword", description = "Bronze Sword Card\nMTG Card #20"}, - {name = "card_default_tool_bronze_shovel", description = "Bronze Shovel Tree Card\nMTG Card #21"}, + {name = "card_default_tool_bronze_pickaxe", description = "Bronze Pickaxe Card\nMTG Card #18", on_use_item = "default:pick_bronze 1"}, + {name = "card_default_tool_bronze_axe", description = "Bronze Axe Card\nMTG Card #19", on_use_item = "default:axe_bronze 1"}, + {name = "card_default_tool_bronze_sword", description = "Bronze Sword Card\nMTG Card #20", on_use_item = "default:sword_bronze 1"}, + {name = "card_default_tool_bronze_shovel", description = "Bronze Shovel Tree Card\nMTG Card #21", on_use_item = "default:shovel_bronze 1"}, - {name = "card_default_gold_lump", description = "Gold Card\nMTG Card #22"}, + {name = "card_default_gold_lump", description = "Gold Card\nMTG Card #22", on_use_item = "default:gold_lump 1",}, } rare_cards = { - {name = "card_default_mese_crystal", description = "Mese Crystal Card\nMTG Card #23"}, + {name = "card_default_mese_crystal", description = "Mese Crystal Card\nMTG Card #23", on_use_item = "default:mese_crystal 1"}, - {name = "card_default_tool_steel_pickaxe", description = "Steel Pickaxe Card\nMTG Card #24"}, - {name = "card_default_tool_steel_axe", description = "Steel Axe Card\nMTG Card #25"}, - {name = "card_default_tool_steel_sword", description = "Steel Sword Card\nMTG Card #26"}, - {name = "card_default_tool_steel_shovel", description = "Steel Shovel Tree Card\nMTG Card #27"}, + {name = "card_default_tool_steel_pickaxe", description = "Steel Pickaxe Card\nMTG Card #24", on_use_item = "default:pick_steel 1"}, + {name = "card_default_tool_steel_axe", description = "Steel Axe Card\nMTG Card #25", on_use_item = "default:axe_steel 1"}, + {name = "card_default_tool_steel_sword", description = "Steel Sword Card\nMTG Card #26", on_use_item = "default:sword_steel 1"}, + {name = "card_default_tool_steel_shovel", description = "Steel Shovel Tree Card\nMTG Card #27", on_use_item = "default:shovel_steel 1"}, } super_rare_cards = { - {name = "card_default_tool_diamond_pickaxe", description = "Diamond Pickaxe Card\nMTG Card #28"}, - {name = "card_default_tool_diamond_axe", description = "Diamond Axe Card\nMTG Card #29"}, - {name = "card_default_tool_diamond_sword", description = "Diamond Sword Card\nMTG Card #30"}, - {name = "card_default_tool_diamond_shovel", description = "Diamond Shovel Tree Card\nMTG Card #31"}, + {name = "card_default_tool_diamond_pickaxe", description = "Diamond Pickaxe Card\nMTG Card #28", on_use_item = "default:pick_diamond 1"}, + {name = "card_default_tool_diamond_axe", description = "Diamond Axe Card\nMTG Card #29", on_use_item = "default:axe_diamond 1"}, + {name = "card_default_tool_diamond_sword", description = "Diamond Sword Card\nMTG Card #30", on_use_item = "default:sword_diamond 1"}, + {name = "card_default_tool_diamond_shovel", description = "Diamond Shovel Tree Card\nMTG Card #31", on_use_item = "default:shovel_diamond 1"}, - {name = "card_default_tool_mese_pickaxe", description = "Mese Pickaxe Card\nMTG Card #32"}, - {name = "card_default_tool_mese_axe", description = "Mese Axe Card\nMTG Card #33"}, - {name = "card_default_tool_mese_sword", description = "Mese Sword Card\nMTG Card #34"}, - {name = "card_default_tool_mese_shovel", description = "Mese Shovel Tree Card\nMTG Card #35"}, + {name = "card_default_tool_mese_pickaxe", description = "Mese Pickaxe Card\nMTG Card #32", on_use_item = "default:pick_mese 1"}, + {name = "card_default_tool_mese_axe", description = "Mese Axe Card\nMTG Card #33", on_use_item = "default:axe_mese 1"}, + {name = "card_default_tool_mese_sword", description = "Mese Sword Card\nMTG Card #34", on_use_item = "default:sword_mese 1"}, + {name = "card_default_tool_mese_shovel", description = "Mese Shovel Tree Card\nMTG Card #35", on_use_item = "default:shovel_mese 1"}, - {name = "card_default_diamond", description = "Diamond Card\nMTG Card #37"}, + {name = "card_default_diamond", description = "Diamond Card\nMTG Card #37", on_use_item = "default:diamond 1"}, } function generate_cards(cards) @@ -61,7 +61,15 @@ function generate_cards(cards) description = cards[key]["description"], inventory_image = card_image, on_use = function(itemstack, user, pointed_thing) - minetest.chat_send_player(user:get_player_name(), "Used Item") + if user:get_inventory():room_for_item("main",cards[key]["on_use_item"]) + then + itemstack:take_item() + user:get_inventory():add_item("main", cards[key]["on_use_item"]) + else + minetest.chat_send_player(user:get_player_name(), "No Room in inventory") + end + return itemstack + end, }) end -- 2.34.1