Skip to content

variable in other scene is returning nil even when set #46

Answered by gilzoide
TrainzMarcel asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @TrainzMarcel.
Well, setting something to nil in Lua is the same as deleting it from the table. So to declare an Object property with default value of null, you should use suspensionarm.ray = Object.null. This would declare a property in the script's manifest, so it could be accessed by GDScript or by Godot Objects in Lua via get/get_indexed/set/set_indexed.

Now, if you had the Lua script instance that is attached to the Object instead of the Object itself, it wouldn't matter if the property was declared or not to Godot and you would be able to set/get it without any fuzz, Lua table style. You can get the Lua script instance today by using GD.get_lua_instance(v). But now that I'm thin…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@TrainzMarcel
Comment options

@TrainzMarcel
Comment options

@gilzoide
Comment options

Answer selected by TrainzMarcel
Comment options

You must be logged in to vote
1 reply
@TrainzMarcel
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants