• Godot HelpProgramming
  • was there previously such a thing as 'get nodes in group' ? and if so, did it get removed?[solved]

hi all.

having a problem with my game. I'm using the steam version, which maybe is a mistake since it auto updates, and an update seems to have broke my game. I was using a function called 'get_nodes_in_group{group_name)' from get_tree(). but after steam updated the game engine, this has not been working.

I would try downloading the previous version and seeing if that fixes my bug, but i'm worried that, if this function was removed, it was removed because maybe it was bad practice.

Does anyone have a suggestion as to if I'm right about this having been removed, and if so, what I can do to fix it in my current game?

TIA

Can you show us the error message and your code? As far as I know this function didn't changed for 3.x.

oh sure. I'll start re loading so i can get the error messages now.

KEep in mind, it could be that i have a different bug, and that i'm wrong about where the code went wrong. (which... is probably why you asked to see the error message :P )

is there any way to attach long scripts to the forum posts? last time i tried pasting in a script of any length it was too long. sorry for my denseness

TRANSPARENCY: this is a lot of me rambling about how the code works. I will post another post where I THINK i've pinpointed the error to... but this one is POSSIBLY irrelevant to others. however, typing it up helped me try to narrow down teh error. so i'm posting it.


okay so in retrospect i'm probably wrong about get_nodes_in_group being removed, even though I can't find it on docs, maybe i was looking in wrong place

cuz when I use it here: func compare_door_id_to_key_id(): if get_tree().get_nodes_in_group("doors") != null: var doors = get_tree().get_nodes_in_group("door") print ("from inventory manager, doors is ") print (doors)

print ("inventory is")

print (inventory)

it DOES show me the doors (as encoded objects, if thats relevant) when i mouse over them with the game paused in the debugger.


okay I apologize for not quite understanding the error (possibly still now, definitely earlier)

I am NOT getting an error message related to this (i have several others that I need to work on that don't SEEM to affect the game in debugger. but i'll post them anyway cuz i could be wrong). they don't 'break' the game though, in that they don't cause the code to stop running. they do cause other issues

but the problem taht is happening is my player's 'spawnpoint' is not getting set. so my set up is, i have a few (messy) scripts managing the player changing rooms. one is the 'doorway' script, another is a 'scene manager' script, and the third is the 'inventory manager' script (For when we have keys to doors, and need to check if they key matches the door)

when the player moves around, if they enter the door, the variable 'is_in_door' is set to true, and when they exit, the variable 'is_in_door' is set to false.

if they press the button to change rooms AND are in door, i call the function move rooms. the move rooms function saves the game to an auto save slot, compares the door id and key id (to see if the key can open the door) and if they are the same, unlocks the door (sets the can_open_door var to true . if the door id is 0 (no key) the can_open_door var starts true, in teh ready function)

from the move rooms function, if can_open_door is true, the code will call from scene manager, teh function 'door_goto_scene(scene_door_leads_to, self)'. this is where, I THINK things went wrong, from teh scene manager script.

in scene_manager, door_goto_scene(path, source_door), calls a deferred version of that script. (_deferred_door_goto_scene(path, source_door)

that function (deferred door...) tries to set the spawn point for the door. it takes note of the scene we were in and the door id we came from, and then saves teh game (NOTE: apparently i saved the game twice in this process Oo as i also saved it in move rooms... something for me to look into i guess). then i have some logic to free the room / delete current persistent objects and load the right ones (not getting into this cuz i think it worked fine, but i'll post script).

CANCELED: THAT Is probalby where my logic went wrong, because right after that is wehre the code stopped working. I will start a new post with that code as this one is quite long.

at some point in here, it gets the new scenes doorS with a get_tree().get_nodes_in_group("door") (which... is where i THOUGHT that function might have been removed, cuz it didn't work here... but it IS working in other parts of my code. leading me to believe i made a logic error somewhere else)

BECAUSE it can't get the doors from teh new scene, when I try to loop through them and check them versus teh key id, it doesn't work...

okay here's the post with the error messages and I'm going to try to attach teh three scripts I've mentioned so far.

there's a lot of yellow ones before, which are mostly me not using a variable when i mentioned it. I know I'm going to have to go back and clean those up at some point

so (Sorry for all the comments) I THINK the logic flaw is, as I hinted at in one of my previous posts, a flaw in scene manager loading in teh game.

so. I have two breakpoints in my code for testing purposes.... one is at the line

var new_scenes_doors = get_tree().get_nodes_in_group("door")

the other is at the line:

print (new_scenes_doors)

which is...weird that at those two different lines they have different values? in teh first breakpoint, against all of my (intended) logic, the value reads as "Autosave". which is reALLY weird to me. autosave is mentioned earlier in teh script, in the line:

var auto_save = SavingAndOptionsMenu.auto_save

(the auto_save variable form SavingAndOptionsMenu is just "Autosave" so i don't typo it and wonder why the hell things aren't working. so thats where MAYBE that value could have come in?)

and then, on the second breakpoint

print (new_scenes_doors)

the value is shown as [] or just a blank array.

Sorry for all my rambling. I hope if anyone here has time/ patience to help, this debugging will help them on the right track. I know its a lot.

Those errors don't appear to be coming from the scripts you attached. If you click on the ">" at the beginning of each line it should expand and show you the script and line number where the error occurred.

The first four appear to be the result of some code trying to find HealthBar, Tween, PauseScreen, and Inventory nodes within the PauseScreen. So maybe PauseScreen has the wrong script attached to it, or maybe another script is getting the PauseScreen confused with some other node or scene. (Or maybe something else.)

The last two errors should be pretty self explanatory, the documentation includes a basic example of opening, writing to, and closing a file.

oh yeah, sorry. I didn't think they were coming from teh scripts, I just posted them for transparency, since I did have errors.

I'll check that documentation though, thanks!

4 days later

okay i found the source of THAT bug, working on a problem i needed to address earlier but failed to but for the curious, the bug was not in scene_manager at all, but in my saving script. and I deleted things before i exited function if not finding a save game, so it deleted things and then just... never put them back up XD

not sure this will help anyone, it was a kind of specific situation, but if it does, have at it.

9 months later