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

Add a new method to check if Thing has a parent #4810

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

Conversation

ramon-bernardo
Copy link
Contributor

@ramon-bernardo ramon-bernardo commented Oct 15, 2024

Pull Request Prelude

Changes Proposed

Introduces a new method to the Thing class that allows checking if a Thing instance has a parent. This providing a direct way to determine parent-child relationships, in addition to the existing if (getParent()) {}.

Before

Tile* tile = nullptr;
if (!parent->getParent()) {
    tile = parent->getTile();
}

After

Tile* tile = nullptr;
if (!parent->hasParent()) {
    tile = parent->getTile();
}

New Lua method

local container = Container()
if container:hasParent() then
    ...
end

EPuncker
EPuncker previously approved these changes Oct 15, 2024
@@ -44,6 +44,10 @@ if not KeywordHandler then
end

-- Returns the parent of this node or nil if no such node exists.
Copy link
Contributor

Choose a reason for hiding this comment

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

Returns whether or not this node has a parent.

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.

3 participants