Skip to content

Cleanup item data creation and parsing#116

Draft
Mamotromico wants to merge 16 commits into
Musholic:devfrom
Mamotromico:cleanup_item_data_creation_and_parsing
Draft

Cleanup item data creation and parsing#116
Mamotromico wants to merge 16 commits into
Musholic:devfrom
Mamotromico:cleanup_item_data_creation_and_parsing

Conversation

@Mamotromico
Copy link
Copy Markdown
Contributor

This is still a WIP. I want to have it readable as a draft PR to facilitate discussion.

Description of the problem being solved:

Currently the code around item parsing is a bit hard to read/understand, and the ItemClass is populated with many duplicate fields while also being slightly complicated to identify some basic info about the item. Ex: When checking a Shield item its not super intuitive on how to get the base (implicit) block chance, which is what spurred me into diving into this section of the code.

There's also some limitations currently on how to identify corrupted items during the offline save import, so I'm trying to investigate that too.

Steps taken to verify a working solution:

  • Ensure old and new tests are passing.

Link to a build that showcases this PR:

Will add later on

Before screenshot:

After screenshot:

Comment thread src/Classes/Item.lua Outdated
--
-- Observed structure so far:
-- item = {
-- affixLimit = 0, -- usually 4 (most items) or 2 (idols). Is this useful? Should this be part of baseItem?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The affixLimit is used when crafting/editing an item, but it can indeed be moved to the baseItem

Comment thread src/Classes/Item.lua Outdated
-- affixLimit = 0, -- usually 4 (most items) or 2 (idols). Is this useful? Should this be part of baseItem?
-- affixes = {}, -- affix text with type and value identification. Ex: "{prefix}{range:31}{rounding:Integer}(6-17)% increased Health Regen". Extra entries or metamethods to get affix by type might be useful. Ex: item.affixes.suffixes
-- base = {}, -- base item data reference
-- classRequirementModLines = {}, -- unsure, shouldn't this be on requirements?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be removed (leftover from POB)

Comment thread src/Classes/Item.lua
-- classRequirementModLines = {}, -- unsure, shouldn't this be on requirements?
-- compatibleAffixes = {}, -- table of compatible modId for crafting (and validation?)
-- corrupted = false, -- corrupted flag
-- crafted = false, -- unsure, seems like leftover from PoB
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be useful

Comment thread src/Classes/Item.lua Outdated
-- compatibleAffixes = {}, -- table of compatible modId for crafting (and validation?)
-- corrupted = false, -- corrupted flag
-- crafted = false, -- unsure, seems like leftover from PoB
-- enchantedModLines = {}, -- list of enchanted mods texts, possibly with parsed results. Are these for enchanted idols or leftovers?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be removed (leftover from POB)

Comment thread src/Classes/Item.lua Outdated
-- corrupted = false, -- corrupted flag
-- crafted = false, -- unsure, seems like leftover from PoB
-- enchantedModLines = {}, -- list of enchanted mods texts, possibly with parsed results. Are these for enchanted idols or leftovers?
-- grantedSkills = {}, -- leftover from PoB, but might be useful
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it will be useful to keep it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was imagining was situations where an Item can enable a skill proc that you might not have otherwise, so having a reference to at least the skill ID so that it can be enabled on DPS calcs could be worthwhile.

Ex: Pillager's Gold or Kuzon's Fury that add ways to proc Burning Dagger

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that the mod (like "(35% to 50%) chance to throw a Burning Dagger on hit (up to 2 times per second)") will be parsed, and it will automatically make the references needed. I think that I changed a bit the logic for the grantedSkills, and I don't need this extra field on item atm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good then!

Comment thread src/Classes/Item.lua Outdated
-- crafted = false, -- unsure, seems like leftover from PoB
-- enchantedModLines = {}, -- list of enchanted mods texts, possibly with parsed results. Are these for enchanted idols or leftovers?
-- grantedSkills = {}, -- leftover from PoB, but might be useful
-- id = 0, -- item id? where does this come from?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is necessary, I think, to reference the items when they are equipped. And to save/load the equipment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaah that explains it! Yes, it makes total sense.

Comment thread src/Classes/Item.lua
-- raw = "", -- full string representation of the item data, useful for direct edit
-- requirements = {}, -- requirements to use the item {level = int} only saw level, but there should be class too
-- title = "", -- unsure whats the difference from name
-- type = "", -- item type string. Examples: "One-Handed Axe", "Shield", "Helmet", etc. Maybe should be a constant reference?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A constant reference should be good 👍

@Musholic
Copy link
Copy Markdown
Owner

Good luck with the cleanup 🙂. Any simplification of the existing logic is welcome. Be careful not to oversimplify, as some variables like explicitModLines or affixes are reused in different places. And several parts of the UI interactions are not automatically tested.

@Mamotromico
Copy link
Copy Markdown
Contributor Author

Mamotromico commented Apr 29, 2026

Good luck with the cleanup 🙂. Any simplification of the existing logic is welcome. Be careful not to oversimplify, as some variables like explicitModLines or affixes are reused in different places. And several parts of the UI interactions are not automatically tested.

Yes, I'm presuming that's the case, and plan to do some extensive testing when this becomes ready.

If necessary I can add some metamethods to ensure compatibility

@Mamotromico Mamotromico reopened this Apr 29, 2026
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.

2 participants