Skip to content

Commit

Permalink
Old book header closes #1925
Browse files Browse the repository at this point in the history
  • Loading branch information
lord-papirus authored and alek13 committed Jan 25, 2025
1 parent 489ce7d commit 2a64d95
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions mods/lord/Blocks/lord_mail/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,17 @@ minetest.register_craftitem("lord_mail:paper_with_text", {
-- books


local function book_on_use(itemstack, user, pointed_thing)
local player_name = user:get_player_name()
local meta = itemstack:get_meta()
local title, text, owner = "", "", player_name

-- Backwards compatibility
local old_data = minetest.deserialize(itemstack:get_meta():get_string(""))
if old_data then
meta:from_table({ fields = old_data })
end

local data = meta:to_table().fields

if data.owner then
title, text, owner = data.title, data.text, data.owner
meta:set_string("description", SL('Book')..': '..colorize('#ee8' , '"'.. title ..'"'))
local function book_on_use(stack, user, pointed_thing)
local player_name = user:get_player_name()
local meta = stack:get_meta():get_string("")
local data = minetest.deserialize(meta)
local title, text, owner = "", "", player_name
if data then
title, text, owner = data.title, data.text, data.owner
stack:get_meta():set_string("description", SL('Book')..': '..colorize('#ee8' , '"'.. title ..'"') )
data = minetest.serialize(data)
stack:set_metadata(data)
user:set_wielded_item(stack)
end
local formspec = ''
.. spec.size(8, 8.5)
Expand Down

0 comments on commit 2a64d95

Please sign in to comment.