-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
NodePath property is inaccessible in Lua #1
Comments
More DiggingDigging some more, I found that the property is in the property list that is returned by print(self:get_property_list()[#self:get_property_list() - 1])
--> {class_name:, hint:0, hint_string:, name:player_path, type:15, usage:7} Attempting to use Discovering a SolutionWhile looking through the code dealing with properties I noticed some mentions of the default value being kept for indexing purposes. The way I had the code did not have a default value. This lead to me wonder what would happen if I assigned the property Code local function ready(self)
print(self.player_path)
print(self:get_node(self:get("player_path")))
end
return {
_extends = "Node2D",
_ready = ready,
player_path = NodePath()
} Output
ConclusionMaybe we should set Thanks again for the great project! |
Hi there! I see you already found out how properties are working currently. Yeah, the property is registered in ClassDB, but without an initial value, getting it would return I think the way to go is really adding a fallback default value for properties, when absent, thanks for pointing it out! Requiring a default value is reasonable too, but having fallback empty/zero/identity values seems nicer to me. Also, now that I'm thinking better about this, just falling back to Either way, we can always stuff initializers in the Not related but more out of curiosity, what OS are you using? Also, did you use the prebuilt release .zip file? |
Just FYI, now that I'm remembering more stuff, the idea was that default value was sort of required, but I though that having But the "get property" bug still applies, so in the end it was a really bad choice =P |
Thank you for the detailed explanation. I like your solution and I'm glad I could help.
I'm using Arch Linux and I did use the r1 release zip. It was plug-and-play. Very easy to get started. |
I asked because I use mainly a Manjaro Linux, so was curious about how this plugin would behave on other systems.
Awesome! |
Plugin Version: r1
Godot Version: v3.3.3
I'm trying to use a
NodePath
property and access it from Lua.The code appears to register the property with Godot as it shows up and works in the inspector but is inaccessible via
self
in Lua.Properties are working for other primitive types I've used so far but not when the type is
NodePath
. When I inspectself
inside of_ready
with the following code, I get the subsequent outcome.As you can see, the property is not on
self
and printing the field directly shows that it doesn't exist, as it'snil
.I've been loving this project by the way. It's great! Thank you for working on it.
The text was updated successfully, but these errors were encountered: