Skip to content

Commit

Permalink
Add default stack size setting (#8873)
Browse files Browse the repository at this point in the history
New setting "default_stack_max" to alter the default stack sizes of all items when desired.

Co-authored-by: Pascal Abresch <nep@packageloss.eu>
  • Loading branch information
SmallJoker and Pascal Abresch committed Apr 13, 2020
1 parent 0ac999d commit 27d611f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions builtin/game/item.lua
Expand Up @@ -675,6 +675,8 @@ end
-- Item definition defaults
--

local default_stack_max = tonumber(minetest.settings:get("default_stack_max")) or 99

core.nodedef_default = {
-- Item properties
type="node",
Expand All @@ -684,7 +686,7 @@ core.nodedef_default = {
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
stack_max = 99,
stack_max = default_stack_max,
usable = false,
liquids_pointable = false,
tool_capabilities = nil,
Expand Down Expand Up @@ -748,7 +750,7 @@ core.craftitemdef_default = {
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
stack_max = 99,
stack_max = default_stack_max,
liquids_pointable = false,
tool_capabilities = nil,

Expand Down Expand Up @@ -786,7 +788,7 @@ core.noneitemdef_default = { -- This is used for the hand and unknown items
inventory_image = "",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
stack_max = 99,
stack_max = default_stack_max,
liquids_pointable = false,
tool_capabilities = nil,

Expand Down
4 changes: 4 additions & 0 deletions builtin/settingtypes.txt
Expand Up @@ -1079,6 +1079,10 @@ map-dir (Map directory) path
# Setting it to -1 disables the feature.
item_entity_ttl (Item entity TTL) int 900

# Specifies the default stack size of nodes, items and tools.
# Note that mods or games may explicitly set a stack for certain (or all) items.
default_stack_max (Default stack size) int 99

# Enable players getting damage and dying.
enable_damage (Damage) bool false

Expand Down
2 changes: 2 additions & 0 deletions doc/lua_api.txt
Expand Up @@ -6735,6 +6735,8 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and

wield_scale = {x = 1, y = 1, z = 1},

-- The default value of 99 may be configured by
-- users using the setting "default_stack_max"
stack_max = 99,

range = 4.0,
Expand Down

0 comments on commit 27d611f

Please sign in to comment.