Skip to content

Add support for stack_max - #76

Merged
wsor4035 merged 1 commit into
mt-mods:masterfrom
Sheriff-Unit-3:stack_max
Sep 6, 2026
Merged

wsor4035 merged 1 commit into
mt-mods:masterfrom
Sheriff-Unit-3:stack_max

Conversation

@Sheriff-Unit-3

@Sheriff-Unit-3 Sheriff-Unit-3 commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Adds xcompat.functions.get_default_stack_max() which returns the current game's default stack size.

Includes documentation for utilities

@Sheriff-Unit-3
Sheriff-Unit-3 force-pushed the stack_max branch 2 times, most recently from 69ba7b4 to 3d9ed9a Compare September 5, 2026 03:07
Comment thread src/utilities.lua Outdated
@SwissalpS SwissalpS changed the title Add xcompat support for stack_max Add support for stack_max Sep 5, 2026
@wsor4035

wsor4035 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Utilities is for internal only functionality. Hence it not being documented or supported. Additionally dunno if the current method will work with mod sec in other mods

@Sheriff-Unit-3

Sheriff-Unit-3 commented Sep 5, 2026 •

Copy link
Copy Markdown
Member Author

Ok thanks for the info on utilities, removed the utilities documentation and moved get_stack_max() to functions. I don't know of any mods that change the default stack_max, but it wouldn't be to hard to change the function to support them.

@SwissalpS

Copy link
Copy Markdown
Contributor

Shouldn't the function be called get_default_stack_max? From the current name I was expecting an itemname passed as argument - not that such a function would make much sense in xcompat scope.

@SwissalpS

SwissalpS commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Shouldn't the function first check if the server settings have set a non-default default value for default_stack_max?
Return that if exists and fallback to the hardcoded values only if not existing.

@Sheriff-Unit-3

Sheriff-Unit-3 commented Sep 5, 2026 •

Copy link
Copy Markdown
Member Author

Shouldn't the function first check if the server settings have set a non-default default value for default_stack_max?
Return that if exists and fallback to the hardcoded values only if not existing.

Well that's were it gets messy, so mineclonia manually sets the stack_max size to 64 for each of it's items/nodes, whereas minetest and many others just use the engine default (99). Therefore default_stack_max would work for minetest and some others, but wouldn't work for mineclonia.

Another thing to consider is Exile has 3 different default stack_max's: https://codeberg.org/Mantar/Exile/src/branch/master/mods/exile_game/init.lua#L3-L5

@SwissalpS

Copy link
Copy Markdown
Contributor

Shouldn't the function first check if the server settings have set a non-default default value for default_stack_max?
Return that if exists and fallback to the hardcoded values only if not existing.

Well that's were it gets messy, so mineclonia manually sets the stack_max size to 64 for each of it's items/nodes, whereas minetest and many others just use the engine default (99). Therefore default_stack_max would work for minetest and some others, but wouldn't work for mineclonia.

In that case mineclonia needs to be treated separately. A server based on MTG can still set the default to something else and the current state of this new function wouldn't catch that.

@Sheriff-Unit-3

Copy link
Copy Markdown
Member Author

Addressed @SwissalpS comments. The function now takes into account if the game currently running uses the engine setting/default or sets it's own.

@wsor4035
wsor4035 merged commit 758684d into mt-mods:master Sep 6, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants