#Controls remain disabled after setting disabled to false

9 messages · Page 1 of 1 (latest)

vivid rivet
#

When I set these controls to disabled = true, they respond correctly by disabling, but when I set them to disabled = false afterwards, then they remain disabled. I have tried commenting out the "lock/unlock_grid", "EndTurnButton.disable/enable", and "OutOfTurnLock.disable/enable" lines one lock/unlock pair at a time, but it has not made a difference. Before disabling them for the first time, everything works properly.

Anyone have any idea what I'm missing? I'm having little luck with Google

#

Interestingly, when I run the code as is but set the OutOfTurnLock to opaque (it is normally a transparent rectangle covering everything but the top bar just meant to prevent input to the elements behind it), it becomes visible when I set it to, but when I set to visible = false it remains visible. Turning its visiblity off in the editor at that time does make it invisible again but the controls that were behind it are, of course, still locked (I gather because they fail to unlock in the same way that the OutOfTurnLock fails to become invisible again?)

#

Thinking on it more, I don't necessarily need the controls to disable at all as long as the OutOfTurnLock becomes visible/invisible properly and does (as I think it does) block input to the controles behind it. Still, that relies on at least that visibility setting properly

vivid rivet
#

Came back to it a little later and thought "well, what if I just add and remove that node as a child as needed. No dice.

vivid rivet
#

Well, moving the OutOfTurnLock higher in the scene tree so that it is in front of everything except the button that starts the longer function screenshot above, it works exactly as it should, but whenever it is in front of that button, it's as if the scene can no longer control its visibility. Am I going crazy here?

#

So I set the position of the OutOfTurnLock to where I could still get to the button behind it, and it turns out the toggle works properly in the first call to toggle_control_lock() below (updated since the screenshots) each time I click that button, but the second call to it (in the else) always does nothing despite the print statements on both sides of it printing as expected, indicating that the call should execute. Gonna see if I can figure out why that call specifically doesn't seem to execute at all, but would still welcome any pointers if anyone has 'em

if current_turn_character is NPC:
    current_turn_character.process_turn()
    toggle_control_lock()
else:
    print("should be my turn again")
    toggle_control_lock()
    print("should be unlocked")


func toggle_control_lock():
    out_of_turn_lock.visible = !out_of_turn_lock.visible
vivid rivet
#

Well this is an interesting development. The two NPCs print their greetings appropriately on their turns, but it looks in the output like the call during NPC turns to set out_of_turn_lock.visible to true are processing /after/ control returns to the player and after the player-turn call to make out_of_turn_lock invisible again

vivid rivet
#

Ok. I think I have figured out the cause. Not sure yet the best way to fix it, but that is a separate issue.

I think this is what is happening:

  1. _on_turn_ended() receives the clicked signal from the end turn button

  2. it makes it to line 47 and then processes the first npc turn

  3. The npc turn ends by emitting the turn_ended signal

  4. that signal calls _on_turn_ended() again

  5. it, again, makes it to line 47

  6. repeat lines 3 and 4 for the second npc

  7. after the second npc turn, it cycles back to being the player's turn

  8. since the player's turn does not end with the "turn_ended" signal automatically but is ended by clicking the End Turn button, the _on_turn_ended() function is allowed - at this point - to finish, setting the control lock to false

  9. after _on_turn_ended() for the second NPC (the one which pushes the turn back to the player), control is returned to the instance of _on_turn_ended() which was running for the first NPC pushing the turn to the second NPC (resumes starting with line 48, setting the lock to true)

  10. control is returned to the instance of _on_turn_ended() which was originally triggered by clicking the end turn button which pushed the turn to the first NPC (resumes starting with line 48, setting the lock again to true)

  11. finish

#

So it may just be that I need to set the turn index in that function but handle the processing separately from that signal... which seems obvious now that I am thinking about it. Here's hoping it works. 😅