-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable stack size per ItemType #4854
base: master
Are you sure you want to change the base?
Conversation
@@ -13685,6 +13686,18 @@ int LuaScriptInterface::luaItemTypeGetWorth(lua_State* L) | |||
return 1; | |||
} | |||
|
|||
int LuaScriptInterface::luaItemTypeGetStackSize(lua_State* L) | |||
{ | |||
// itemType:getStackSize() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion
itemType:stackSize(value) // set
itemType:stackSize() // get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used only in shop system
setting stack size should be done only on startup, your change reguest will affect ItemType that is and should be static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I hadn't seen that 😲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of this "revscriptsys" way of getters and setters, make it obvious getAnything, setAnything
anything() is confusing and may result in undefined behaviour if you by any chance pass value or actually pass no value, which could happen, because lua is a dynamic language
@@ -1593,7 +1593,7 @@ void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) | |||
|
|||
money -= currencyCoins * worth; | |||
while (currencyCoins > 0) { | |||
const uint16_t count = std::min<uint32_t>(ITEM_STACK_SIZE, currencyCoins); | |||
const uint16_t count = std::min<uint32_t>(Item::items[it.second].stackSize, currencyCoins); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s better to define a temporary variable to store the stackSize
, then reuse it in the loop. Otherwise, what you’re doing is accessing it
and getting a reference to the itemtype
, then accessing the itemtype
and obtaining a copy of the number in each iteration.
Pull Request Prelude
Changes Proposed
Configurable stack size per ItemType.
Configuration is done in items.xml file by using attribue "stacksize"
Example:
note: npc now can sell multiple bp's with stackable items.
Issues addressed:
N/A
How to test:
Set 'stacksize' in any stackable item