-
Notifications
You must be signed in to change notification settings - Fork 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
Remove condition by Condition parameters (fixes #3544) #3545
Conversation
A copy of the Condition object was added to the creature in `LuaScriptInterface::luaCreatureAddCondition`, therefore `Creature::removeCondition` could not remove the condition properly, as the Condition object that was constructed from Userdata did not match the one stored in the creature's condition list. Also applied const correctness.
If you use logic, you will realize that this PR does not make any sense This function has two behaviors:
¿How to use the function correctly with userdata? creature:removeCondition(creature:getCondition(...), ...) If you still insist, you can add an overload in lua and it looks much better, although counterintuitive and can lead people to think incorrectly, it is already out of basic logic. |
Read #3544 (comment) |
And I understand what you mean by using a condition and then extracting its properties and then finding the player's condition and so bla bla bla In case you are too lazy to write 20 more letters you can do a help function: function Condition:unpack()
return self:getType(), self:getId(), self:getSubId()
end
-- force: default
creature:removeCondition(condition:unpack())
-- force: false
creature:removeCondition(condition:unpack(), false)
-- force: true
creature:removeCondition(condition:unpack(), true) |
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'm not entirely against it, although we may be requiring in other places the Lua developer to also pass actual condition, not a replica. This behavior does not hurt though.
All checks passing, all reviews passing. LGTM PR is from 2021, its amazing its still able to be merged... Can we do so now? |
Pull Request Prelude
Changes Proposed
A copy of the Condition object was added to the creature in
LuaScriptInterface::luaCreatureAddCondition
, thereforeCreature::removeCondition
could not remove the condition properly, as the Condition object that was constructed from Userdata did not match the one stored in the creature's condition list.Also applied const correctness.
Issues addressed: closes #3544