@@ -51,10 +51,9 @@ function creative_inventory.update(player_name, filter)
51
51
52
52
for name , def in pairs (minetest .registered_items ) do
53
53
if not (def .groups .not_in_creative_inventory == 1 ) and
54
- def .description and def .description ~= " " then
55
- if (filter and def .name :find (filter , 1 , true )) or not filter then
56
- creative_list [# creative_list + 1 ] = name
57
- end
54
+ def .description and def .description ~= " " and
55
+ (not filter or def .name :find (filter , 1 , true )) then
56
+ creative_list [# creative_list + 1 ] = name
58
57
end
59
58
end
60
59
@@ -136,10 +135,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
136
135
local current_page = 0
137
136
local player_name = player :get_player_name ()
138
137
local formspec = player :get_inventory_formspec ()
139
- local start_i = formspec :match (" list%[detached:creative_" .. player_name .. " ;main;[%d.]+,[%d.]+;[%d.]+,[%d.]+;(%d+)%]" )
138
+ local start_i = formspec :match (" list%[detached:creative_" .. player_name .. " ;.*;(%d+)%]" )
139
+ local inv_size = creative_inventory [player_name ].size
140
140
start_i = tonumber (start_i ) or 0
141
141
142
- if fields .creative_prev or start_i >= creative_inventory [ player_name ]. size then
142
+ if fields .creative_prev or start_i >= inv_size then
143
143
start_i = start_i - 4 * 6
144
144
elseif fields .creative_next or start_i < 0 then
145
145
start_i = start_i + 4 * 6
@@ -157,9 +157,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
157
157
creative_inventory .set_creative_formspec (player , 0 , 1 )
158
158
end )
159
159
end
160
-
161
- if start_i < 0 or start_i >= creative_inventory [ player_name ]. size then
160
+
161
+ if start_i >= inv_size then
162
162
start_i = 0
163
+ elseif start_i < 0 then
164
+ start_i = inv_size - (inv_size % (6 * 4 ))
163
165
end
164
166
165
167
creative_inventory .set_creative_formspec (player , start_i , start_i / (6 * 4 ) + 1 )
0 commit comments