Skip to content

Commit

Permalink
fix crash on read book #1895
Browse files Browse the repository at this point in the history
  • Loading branch information
lord-papirus committed Jan 3, 2025
1 parent 2d1a181 commit 843d051
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mods/lord/Blocks/lord_mail/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,18 @@ minetest.register_craftitem("lord_mail:paper_with_text", {

local function book_on_use(itemstack, user, pointed_thing)
local player_name = user:get_player_name()
local meta = itemstack:get_metadata()
local data = minetest.deserialize(meta)
local meta = itemstack:get_meta()
local title, text, owner = "", "", player_name
if data then

-- 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 ..'"'))
end
Expand Down

0 comments on commit 843d051

Please sign in to comment.