0 votes

The game my team and i are making should have checkpoints so then you don't have to start from the first battle when pressing "restart battle" button.
How can i save current level's value and just use it if that button it's pressed?

extends MarginContainer

var BattleScene = load("res://Battle/Battle.tscn")

func _on_Button_mouse_entered():

func _on_Buttons_pressed():
    get_tree().call_group("Main", "set_scene", BattleScene)

func _on_RestartBattleButton_pressed():
    # Use current level's value to restart the game in the battle you was.


if fsm.state_curr == fsm.states.EnemyTurn and anim_name == "exit_enemy_attack":
        if State.get_value("player_health") <= 0:
            fsm.state_next = fsm.states.PlayerLost
            fsm.state_next = fsm.states.PlayerTurn


extends Node

var current_letter_bank = []
var dictionary = []

func set_initial_game_state():
    State.set_value("player_health", get_starting_player_health())
    State.set_value("current_level", 1)

    State.set_value("enemy_type", Enums.EnemyType.SLIME)
    State.set_value("enemy_health", get_starting_enemy_health(Enums.EnemyType.SLIME))

func _ready():

func advance_to_next_level():
    var current_level = State.get_value("current_level")
    var next_level = current_level + 1 # How can i save this change (i.e current level = 3 if you losed in that level) ?
    State.set_value("current_level", next_level)

Edit: Nevermind, solved it.

in Engine by (122 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.