Skip to content

Commit b3f17cd

Browse files
red-001paramat
authored andcommittedJun 14, 2017
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.
1 parent 15ba964 commit b3f17cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

Diff for: ‎mods/default/craftitems.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ local function book_on_use(itemstack, user)
7575
return itemstack
7676
end
7777

78+
local max_text_size = 10000
7879
minetest.register_on_player_receive_fields(function(player, formname, fields)
7980
if formname ~= "default:book" then return end
8081
local inv = player:get_inventory()
@@ -103,8 +104,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
103104
data.title = fields.title
104105
data.owner = player:get_player_name()
105106
data.description = "\""..fields.title.."\" by "..data.owner
106-
data.text = fields.text
107-
data.text_len = #data.text
107+
data.text = fields.text:sub(1, max_text_size)
108108
data.page = 1
109109
data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp)
110110

0 commit comments

Comments
 (0)
Please sign in to comment.