Books: Limit the size of books
Really large books just waste hard drive space and the engine is not designed to handle that much data in item metadata, this can cause strange things to happen.
This commit is contained in:
parent
15ba96467d
commit
b3f17cda9f
|
@ -75,6 +75,7 @@ local function book_on_use(itemstack, user)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local max_text_size = 10000
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname ~= "default:book" then return end
|
if formname ~= "default:book" then return end
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
@ -103,8 +104,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
data.title = fields.title
|
data.title = fields.title
|
||||||
data.owner = player:get_player_name()
|
data.owner = player:get_player_name()
|
||||||
data.description = "\""..fields.title.."\" by "..data.owner
|
data.description = "\""..fields.title.."\" by "..data.owner
|
||||||
data.text = fields.text
|
data.text = fields.text:sub(1, max_text_size)
|
||||||
data.text_len = #data.text
|
|
||||||
data.page = 1
|
data.page = 1
|
||||||
data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp)
|
data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue