use markdown and not rest...

This commit is contained in:
groug 2023-02-14 16:25:49 +01:00
parent 296cb41e45
commit cd73ac037a

View File

@ -3,7 +3,7 @@ TODO
# How to use # How to use
- Add a Node2D node named "StateMachine" with the script state_machine.gd - Add a Node2D node named "StateMachine" with the script state_machine.gd
- Initialize the states, initial state and conditions: - Initialize the states, initial state and conditions:
{{{ ```
$StateMachine.add_state("idle") $StateMachine.add_state("idle")
$StateMachine.add_state("hurt") $StateMachine.add_state("hurt")
$StateMachine.add_state("dead") $StateMachine.add_state("dead")
@ -11,21 +11,21 @@ TODO
$StateMachine.add_transition("idle", "hurt", [], "fire") $StateMachine.add_transition("idle", "hurt", [], "fire")
$StateMachine.add_transition("hurt", "dead", ["has_stuff_been_handled", "is_dead"]) $StateMachine.add_transition("hurt", "dead", ["has_stuff_been_handled", "is_dead"])
$StateMachine.add_transition("hurt", "idle", ["has_stuff_been_handled"]) $StateMachine.add_transition("hurt", "idle", ["has_stuff_been_handled"])
}}} ```
- Trigger an event - Trigger an event
{{{ ```
$StateMachine.trigger("fire") $StateMachine.trigger("fire")
}}} ```
- Add a condition: it's just a func returning a bool - Add a condition: it's just a func returning a bool
{{{ ```
def has_stuff_been_handled(): def has_stuff_been_handled():
return true return true
}}} ```
- Add callbacks for state entering/update/exiting: just add the state name in on_XXXXX_state_YYYY() - Add callbacks for state entering/update/exiting: just add the state name in on_XXXXX_state_YYYY()
{{{ ```
func on_idle_state_enter(): func on_idle_state_enter():
pass pass
@ -34,21 +34,21 @@ TODO
func on_idle_state_exit(): func on_idle_state_exit():
pass pass
}}} ```
- Enabling debug mode (logs when changing states) - Enabling debug mode (logs when changing states)
{{{ ```
$StateMachine.set_debug_enabled(true) $StateMachine.set_debug_enabled(true)
}}} ```
- Get the current state - Get the current state
{{{ ```
$StateMachine.get_current_state() $StateMachine.get_current_state()
}}} ```
- Get the last known state (before the current one) - Get the last known state (before the current one)
{{{ ```
$StateMachine.get_last_state() $StateMachine.get_last_state()
}}} ```
# Credits # Credits
icon: made by Freepik from https://www.flaticon.com, license: Creative Commons BY 3.0 icon: made by Freepik from https://www.flaticon.com, license: Creative Commons BY 3.0