Skip to content
This repository has been archived by the owner on Nov 12, 2018. It is now read-only.

Commit

Permalink
Add a mana potion.
Browse files Browse the repository at this point in the history
  • Loading branch information
linewriter1024 committed Jan 10, 2017
1 parent a077ab8 commit 802e33f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions kingdoms/gen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if kingdoms.config.mapgen then

default.register_biomes()
default.register_decorations()
flowers.register_decorations()
kingdoms.log("action", "Applied mapgen settings.")
end
magic.register_mapgen()
1 change: 1 addition & 0 deletions magic/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ domodfile("crafts.lua")
domodfile("timegens.lua")
domodfile("crystals.lua")
domodfile("spells.lua")
domodfile("potions.lua")
domodfile("turrets.lua")

domodfile("spells/action.lua")
Expand Down
81 changes: 81 additions & 0 deletions magic/potions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
function magic.register_potion(name, def)
local item_def = {
description = def.description,
drawtype = "plantlike",
tiles = {"vessels_glass_bottle.png^[colorize:"..def.color..":200"},
inventory_image = "vessels_glass_bottle.png^[colorize:"..def.color..":200",
wield_image = "vessels_glass_bottle.png^[colorize:"..def.color..":200",
paramtype = "light",
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
}
local function docost(player)
if def.harmful then
return magic.require_energy(player, def.cost, true)
else
return magic.require_mana(player, def.cost, true)
end
end
if def.on_use then
function item_def.on_use(itemstack, player)
if def.cost then
if not docost(player) then return end
end
if def.on_use(itemstack, player) then
if player:get_inventory():room_for_item("main", "vessels:glass_bottle") then
player:get_inventory():add_item("main", "vessels:glass_bottle")
else
minetest.add_item(pos, "vessels:glass_bottle")
end
itemstack:take_item()
end
return itemstack
end
end
minetest.register_node(name, item_def)
end

magic.register_potion("magic:water_bottle", {
description = "Bottle of Water",
color = "#02A",
})

minetest.register_craft({
output = "magic:water_bottle",
type = "shapeless",
recipe = {"vessels:glass_bottle", "bucket:bucket_water"},
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}},
})

magic.register_potion("magic:purified_water_bottle", {
description = "Purified Bottle of Water",
color = "#23B",
})

minetest.register_craft({
type = "cooking",
output = "magic:purified_water_bottle",
recipe = "magic:water_bottle",
cooktime = 5,
})

magic.register_potion("magic:minor_mana_potion", {
description = "Minor Mana Restoration Potion",
color = "#00F",
on_use = function(itemstack, player)
magic.require_mana(player, -2)
return true
end,
})

minetest.register_craft({
output = "magic:minor_mana_potion",
type = "shapeless",
recipe = {"magic:water_bottle", "flowers:geranium"},
})

0 comments on commit 802e33f

Please sign in to comment.