Skip to content
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

Itemstack details #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fluxionary
Copy link

In particular, support for itemstack metadata serialization in the itemstring.

@S-S-X S-S-X added the enhancement New feature or request label Apr 3, 2022
@S-S-X
Copy link
Owner

S-S-X commented Apr 8, 2022

Link #2, implements MetaDataRef:equals(other)

Comment on lines +37 to +43
if wear <= 65535 then
self._wear = wear % 65536
return true
else
self.clear()
return false
end
Copy link
Owner

Choose a reason for hiding this comment

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

Is this updated engine 5.5 behavior? (yeah previous wear behavior was bit weird but kinda useful)

Just in case reminder link #7
Also for assertion link #64 as some technic mod tests depends on strict validation.

Copy link
Author

Choose a reason for hiding this comment

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

Is this updated engine 5.5 behavior? (yeah previous wear behavior was bit weird but kinda useful)

I'm not certain, I'll take a look. If I remember, the reference I was looking at just casts the value as uint16.

Copy link
Author

Choose a reason for hiding this comment

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

It looks like this is how it's been done since at least 0.4.17.1

Copy link
Author

Choose a reason for hiding this comment

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

Are you confusing this with "add_wear"?

Copy link
Owner

@S-S-X S-S-X Apr 8, 2022

Choose a reason for hiding this comment

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

Ah actually it is same behavior but just like engine allows destroying items by setting invalid wear?
Should prob just add some simplified strict mode to throw errors, probably duping assert as strict_assert or something for easy use (and custom error behavior handling)

Copy link
Owner

Choose a reason for hiding this comment

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

Now wondering why I've even done that as it only affects values > 65536 and those will kill stack anyway.... 🤷 well, looks way better now so just have to add assertion thing.
I think I could try to look into that a bit tomorrow, would be nice to get this merged soon anyway.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure what you're talking about w.r.t. simplified strict mode or throwing errors?

Strict mode means that error is raised when something is done that does not seem clearly intended behavior like destroying tool stack by setting invalid value for it. That is also application specific thing as sometimes it is meant to be destroyed while sometimes not, would however like to have assertion near actual call that causes potentially unwanted behavior for this specific case.
Not sure how this case should be exactly handled, so far was handled with straight assertion probably just because that happened to be only use case I needed back then...

Copy link
Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but destroying the stack by setting the value above 65535 is the intended behavior. You used the tool too much, now it's broken. The assertion that was there previously was wrong.

Copy link
Owner

Choose a reason for hiding this comment

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

Which is why clarified with "That is also application specific thing as sometimes it is meant to be destroyed while sometimes not".
True that it is kind of wrong and should probably have been handled different way in tests from beginning, use case for that assertion is with indestructible rechargeable power tools.

It could have been done better with more specific assertions in test set by verifying that stack is still valid but... well, that was not done... but then early error also proved to be useful as when tool stack got accidentally destroyed it eventually caused error on completely irrelevant part of mod and that's reason why "would however like to have assertion near actual call that causes potentially unwanted behavior for this specific case"

Copy link
Owner

Choose a reason for hiding this comment

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

Probably needs way to mark item def as destructible/indestructible through "side effects" and global configuration for default behavior... I think that would work best here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants