forked from minetest/minetest_game
Books: Ensure backward compatibility for older written books
This commit is contained in:
parent
7a29d26e3e
commit
6749da1070
|
@ -14,18 +14,20 @@ minetest.register_craftitem("default:paper", {
|
|||
local function book_on_use(itemstack, user)
|
||||
local player_name = user:get_player_name()
|
||||
local data = minetest.deserialize(itemstack:get_metadata())
|
||||
local formspec, title, text, text_len, page, page_max, cpp, owner =
|
||||
"", "", "", 1, 1, 1, 1, player_name
|
||||
local formspec, title, text, owner = "", "", "", player_name
|
||||
local page, page_max, cpp = 1, 1, 650
|
||||
|
||||
if data then
|
||||
title = data.title
|
||||
text = data.text
|
||||
owner = data.owner
|
||||
text_len = data.text_len
|
||||
|
||||
if data.page then
|
||||
page = data.page
|
||||
page_max = data.page_max
|
||||
cpp = data.chars_per_page
|
||||
end
|
||||
end
|
||||
|
||||
if owner == player_name then
|
||||
formspec = "size[8,8]" .. default.gui_bg ..
|
||||
|
@ -96,6 +98,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
|
||||
elseif fields.book_next or fields.book_prev then
|
||||
local data = minetest.deserialize(stack:get_metadata())
|
||||
if not data.page then return end
|
||||
|
||||
if fields.book_next then
|
||||
data.page = data.page + 1
|
||||
if data.page > data.page_max then
|
||||
|
|
Loading…
Reference in New Issue
Block a user