Compare commits

...

2 Commits

Author SHA1 Message Date
be06769ef6 Added comments/refractored 2023-02-19 19:05:23 -05:00
0d14f9fc5e Added a drop on use for each card 2023-02-19 18:43:15 -05:00
2 changed files with 76 additions and 69 deletions

View File

@ -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

144
init.lua
View File

@ -1,58 +1,8 @@
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_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_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_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"},
}
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_gold_lump", description = "Gold Card\nMTG Card #22"},
}
rare_cards = {
{name = "card_default_mese_crystal", description = "Mese Crystal Card\nMTG Card #23"},
{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"},
}
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_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_diamond", description = "Diamond Card\nMTG Card #37"},
}
-- This function generates cards
-- It uses a table that has 3 values:
-- name
-- description
-- on_use_items
function generate_cards(cards)
for key,value in pairs(cards) do
local card_id = "tradingcards:" .. cards[key]["name"]
@ -61,18 +11,31 @@ 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
end
-- This function generates a random card in a table
-- It uses a table that has 3 values:
-- name
-- description
function get_random_card(card_type)
local card = card_type[ math.random( #card_type )]
return "tradingcards:" .. card["name"]
end
-- Get a random card based on rarity
function get_card_for_pack()
-- 60% common
-- 25% uncommon
@ -96,6 +59,7 @@ function get_card_for_pack()
return card
end
-- Add card pack item, gives 3 random cards
minetest.register_craftitem("tradingcards:card_pack", {
description = "MTG Card Pack!",
inventory_image = 'card_pack.png',
@ -120,22 +84,66 @@ minetest.register_craftitem("tradingcards:card_pack", {
local card = get_card_for_pack()
user:get_inventory():add_item("main", card)
end
--[[
itemstack:take_item()
card = get_random_card(common_cards)
user:get_inventory():add_item("main", card)
card = get_random_card(common_cards)
user:get_inventory():add_item("main", card)
card = get_random_card(common_cards)
print(user:get_inventory():room_for_item("main", card))
print(user:get_inventory():add_item("main", card))
print(user:get_inventory():get_size("main"))
print(dump(user:get_inventory():get_list("main")))
]]--
return itemstack
end,
})
-- Cards separated by rarity
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: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: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: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: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", 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", on_use_item = "default:gold_lump 1",},
}
rare_cards = {
{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", 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", 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", 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", on_use_item = "default:diamond 1"},
}
generate_cards(common_cards)
generate_cards(uncommon_cards)