• 0 Posts
  • 11 Comments
Joined 1 year ago
cake
Cake day: June 14th, 2023

help-circle
rss

  • There are a couple of issues with this line:

    tilemap_movement.disconnect("movement_finished", _on_movement_to_exit_complete(character))
    

    Firstly, you’re using the old Godot 3 API. You’ll want to do this instead:

    tilemap_movement.movement_finished.disconnect(_on_movement_to_exit_complete(character))
    

    Secondly, the fact that you have parameterized anonymous functions as listeners makes things a little tricky. Let’s say you call signal.connect() and pass a parameterized listener. Later, when you call signal.disconnect(), you have to pass it the same function. Calling _on_movement_exit_complete() with the same arguments returns a different (identical) function. There are a couple of ways you can work around this. A common solution would be to store your own references to the listeners for later use. something like this:

    var movement_listeners = {}
    
    func some_func_where_you_add_listeners():
        var character = # IDK, some reference to a character
        var listener = _on_movement_to_exit_complete(character)
        tilemap_movement.movement_finished.connect(listener)
        movement_listeners[character.name] = listener
    
    func _on_movement_to_exit_complete(character: Node2D):
    	var f = func():
    		# ...
    		if party.get_child_count() == 0:
    			for party_member in initial_party.get_children():
                                    # ....
                                    var listener = movement_listeners[character.name]
    				tilemap_movement.movement_finished.disconnect(listener)
                                    movement_listeners.erase(character.name)
    
    			load_next_level()
    
    	return f
    

    I hope that makes some sense




  • I would say to give yourself the opportunity to have some fun with it. Maybe that could take the form of trying to apply what you know into some fun little project. Think about whatever you just studied and try to imagine what you could do with that knowledge. Don’t worry about constantly making progress. You will learn a lot just from picking a little project and trying to solve all the little problems you run into.