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)
table.insert(magicalities.data[player_name].abilities, item)
success = true
msgname = "to " .. ability_n
msgname = ability_n
end
end

View File

@ -35,18 +35,40 @@ local function book_read_page(book, user, page, ptype)
check = magicalities.player_has_recipe
end
if not check(uname, page) then return book end
if not check(uname, page) then return false end
local chapter = "#"..ptype..""..page
if not page_cache[chapter] then
return
return false
end
minetest.show_formspec(uname, "magicalities:book", book_formspec(uname, chapter, 0))
return true
end
local function book_read(book, user, pointed_thing)
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()
minetest.show_formspec(uname, "magicalities:book", book_formspec(uname, nil, meta:get_int("scrolli")))
return book
@ -133,6 +155,7 @@ end)
minetest.register_craftitem("magicalities:book", {
description = "Magicalities' Guide for Witches and Wizards",
inventory_image = "magicalities_book.png",
on_use = book_read,
on_place = book_read,
on_secondary_use = book_read,
_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
end
-- Check if the player knows anything about the Element Ring, if not, surprise them!
local element_ring = magicalities.player_has_recipe(player, "magicalities:element_ring")
-- The player learned about crystal tapping
local element_ring = magicalities.player_has_recipe(player, "magicalities:crystal")
if not element_ring then
magicalities.player_learn(player, "magicalities:element_ring", true)
magicalities.player_learn(player, "magicalities:crystal")
end
-- Check if player can preserve this crystal

View File

@ -226,9 +226,9 @@ local recipes = {
},
{
input = {
{"magicalities:tellium"},
{"magicalities:transterra"},
{"default:stick"}
{"", "magicalities:tellium", ""},
{"", "magicalities:transterra", ""},
{"", "default:stick", ""}
},
output = "magicalities:shovel_tellium",
requirements = {
@ -242,9 +242,9 @@ local recipes = {
},
{
input = {
{"magicalities:tellium"},
{"magicalities:transterra"},
{"default:stick"}
{"", "magicalities:tellium", ""},
{"", "magicalities:tellium", ""},
{"", "magicalities:transterra", ""}
},
output = "magicalities:sword_tellium",
requirements = {
@ -428,6 +428,8 @@ end
-- Treasurer mod, add Research Notes as a form of treasure.
if minetest.get_modpath("treasurer") then
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
---------------
@ -442,13 +444,6 @@ magicalities.register_recipe_learnable({
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({
name = "magicalities:table",
description = "Research Table\nDo research about the magic world",
@ -467,10 +462,19 @@ magicalities.register_recipe_learnable({
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({
name = "magicalities:crystal_preserve",
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({

View File

@ -44,7 +44,7 @@ function magicalities.researching.generate_formspec_list(list, x, y, w, h, index
end
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
return i

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB