The essence of the question is this, there is a button that performs actions, in which many if statements are written in succession and they are sequential, and the problem is that after clicking all if are processed, I need to stop at the first and wait for the next button press, so that everything happens in turn . If any way to stop the action of the button and wait for the next press?

@IBAction func varib1(_ sender: Any) { if sceneNumber == 1 { sceneNumber = 2 labelDisplayScene.text = "Вы выбили дверь несколькими ударами топора, но на вас напали разбойники, которые поджидали у двери" varib1Out.setTitle("Убежать", for: .normal) varib2Out.setTitle("Начать сражаться", for: .normal) varib3Out.setTitle("Попытаться договориться", for: .normal) } if sceneNumber == 2 { sceneNumber = 3 labelDisplayScene.text = "Вы смогли убежать но вас ранил разбойник стрелой" varib1Out.setTitle("Выпить зелье", for: .normal) varib2Out.setTitle("Вернуться и сразиться", for: .normal) varib3Out.setTitle("Следовать в деревню", for: .normal) } 

    1 answer 1

    You have almost written that way, just use else if .

    • a little something else, then in the next button there will be hundreds of if (perhaps this is certainly the wrong approach, but so far) and it will not work here, there are three buttons, each button selects a specific action depending on the scene (variable) and now it turns out that by pressing, it naturally jumps into the very last dialogue, skipping everything before it, you need to somehow stop the button action in a certain place) - Vladislav Bublik
    • figured out the else, but the code is even deeper in terms of the tree will turn out) I would like another solution, but thanks anyway) - Vladislav Bublik