This commit is contained in:
Evert Prants 2019-11-09 14:32:59 +02:00
parent 7649065f41
commit 1ce5b1c3ba
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
6 changed files with 48 additions and 21 deletions

View File

@ -106,7 +106,7 @@ function magicalities.player_learn(player_name, item, recipe, silent)
ability_n = no_newline(ability_n.description) ability_n = no_newline(ability_n.description)
table.insert(magicalities.data[player_name].abilities, item) table.insert(magicalities.data[player_name].abilities, item)
success = true success = true
msgname = "to " .. ability_n msgname = ability_n
end end
end end

View File

@ -35,18 +35,40 @@ local function book_read_page(book, user, page, ptype)
check = magicalities.player_has_recipe check = magicalities.player_has_recipe
end end
if not check(uname, page) then return book end if not check(uname, page) then return false end
local chapter = "#"..ptype..""..page local chapter = "#"..ptype..""..page
if not page_cache[chapter] then if not page_cache[chapter] then
return return false
end end
minetest.show_formspec(uname, "magicalities:book", book_formspec(uname, chapter, 0)) minetest.show_formspec(uname, "magicalities:book", book_formspec(uname, chapter, 0))
return true
end end
local function book_read(book, user, pointed_thing) local function book_read(book, user, pointed_thing)
local uname = user:get_player_name() local uname = user:get_player_name()
if pointed_thing and pointed_thing.type == "node" then
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local ptype = 2
local page = node.name
-- Special case for crystals
if minetest.get_item_group(node.name, "crystal_cluster") > 0 then
ptype = 1
page = "magicalities:crystal"
end
-- Open a page instead
if page_cache["#"..ptype..""..page] then
local read = book_read_page(book, user, page, ptype)
if read then
return book
end
end
end
local meta = book:get_meta() local meta = book:get_meta()
minetest.show_formspec(uname, "magicalities:book", book_formspec(uname, nil, meta:get_int("scrolli"))) minetest.show_formspec(uname, "magicalities:book", book_formspec(uname, nil, meta:get_int("scrolli")))
return book return book
@ -133,6 +155,7 @@ end)
minetest.register_craftitem("magicalities:book", { minetest.register_craftitem("magicalities:book", {
description = "Magicalities' Guide for Witches and Wizards", description = "Magicalities' Guide for Witches and Wizards",
inventory_image = "magicalities_book.png", inventory_image = "magicalities_book.png",
on_use = book_read,
on_place = book_read, on_place = book_read,
on_secondary_use = book_read, on_secondary_use = book_read,
_wand_created = function (itemstack, wand, user, pos) _wand_created = function (itemstack, wand, user, pos)

View File

@ -101,10 +101,10 @@ local function crystal_rightclick(pos, node, clicker, itemstack, pointed_thing)
return itemstack return itemstack
end end
-- Check if the player knows anything about the Element Ring, if not, surprise them! -- The player learned about crystal tapping
local element_ring = magicalities.player_has_recipe(player, "magicalities:element_ring") local element_ring = magicalities.player_has_recipe(player, "magicalities:crystal")
if not element_ring then if not element_ring then
magicalities.player_learn(player, "magicalities:element_ring", true) magicalities.player_learn(player, "magicalities:crystal")
end end
-- Check if player can preserve this crystal -- Check if player can preserve this crystal

View File

@ -226,9 +226,9 @@ local recipes = {
}, },
{ {
input = { input = {
{"magicalities:tellium"}, {"", "magicalities:tellium", ""},
{"magicalities:transterra"}, {"", "magicalities:transterra", ""},
{"default:stick"} {"", "default:stick", ""}
}, },
output = "magicalities:shovel_tellium", output = "magicalities:shovel_tellium",
requirements = { requirements = {
@ -242,9 +242,9 @@ local recipes = {
}, },
{ {
input = { input = {
{"magicalities:tellium"}, {"", "magicalities:tellium", ""},
{"magicalities:transterra"}, {"", "magicalities:tellium", ""},
{"default:stick"} {"", "magicalities:transterra", ""}
}, },
output = "magicalities:sword_tellium", output = "magicalities:sword_tellium",
requirements = { requirements = {
@ -428,6 +428,8 @@ end
-- Treasurer mod, add Research Notes as a form of treasure. -- Treasurer mod, add Research Notes as a form of treasure.
if minetest.get_modpath("treasurer") then if minetest.get_modpath("treasurer") then
treasurer.register_treasure("magicalities:note", 0.35, 5, {1,3}, nil, "tool") treasurer.register_treasure("magicalities:note", 0.35, 5, {1,3}, nil, "tool")
treasurer.register_treasure("magicalities:tellium", 0.8, 8, {1,3}, nil, "crafting_component")
treasurer.register_treasure("magicalities:transterra", 0.8, 5, {1,3}, nil, "crafting_component")
end end
--------------- ---------------
@ -442,13 +444,6 @@ magicalities.register_recipe_learnable({
default = true, default = true,
}) })
magicalities.register_ability_learnable({
name = "magicalities:crystal",
description = "Crystal Tapping\nExtract elements from crystals",
icon = "magicalities_crystal_gui.png",
default = true,
})
magicalities.register_recipe_learnable({ magicalities.register_recipe_learnable({
name = "magicalities:table", name = "magicalities:table",
description = "Research Table\nDo research about the magic world", description = "Research Table\nDo research about the magic world",
@ -467,10 +462,19 @@ magicalities.register_recipe_learnable({
default = true default = true
}) })
-- Crystals
magicalities.register_ability_learnable({
name = "magicalities:crystal",
description = "Crystal Tapping\nExtract elements from crystals",
icon = "magicalities_crystal_gui.png",
})
magicalities.register_ability_learnable({ magicalities.register_ability_learnable({
name = "magicalities:crystal_preserve", name = "magicalities:crystal_preserve",
description = "Crystal Preservation\nAvoid collecting every last drop of elements", description = "Crystal Preservation\nAvoid collecting every last drop of elements",
icon = "magicalities_crystal_preservation.png" icon = "magicalities_crystal_preservation.png",
depends = {"magicalities:crystal"}
}) })
magicalities.register_ability_learnable({ magicalities.register_ability_learnable({

View File

@ -44,7 +44,7 @@ function magicalities.researching.generate_formspec_list(list, x, y, w, h, index
end end
if pages > index + 1 then if pages > index + 1 then
i = i .. "button["..(x+w)..","..(y+h-0.25)..";1,1;dn;Down]" i = i .. "button["..(x+w)..","..(y+ty-1)..";1,1;dn;Down]"
end end
return i return i

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB