system
April 13, 2016, 10:49am
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
EIREXE
Old Version
Published before Godot 3 was released.
I have made a settings menu, and I would like to save my InputMap from memory and then load it on top of the InputMap from engine.cfg.
Is there any built in way to do this?
system
April 13, 2016, 12:49pm
4
Reply From:
kubecz3k
There is InputMap
object that resides in global scope, so you are able to get it all the time by simply using it’s name(InputMap). It have some methods that allows you to modify mapping in runtime:
bool has_action( String action )
int get_action_id( String action )
String get_action_from_id( int id )
void add_action( String action )
void erase_action( String action )
bool action_has_event ( String action, InputEvent event )
void action_add_event ( String action, InputEvent event )
void action_erase_event ( String action, InputEvent event )
However you need to save state of input map to the file manually, and restore it each time when the game is started.
More informations:
Extras/Hint : You can take look into how Akien implement saving/loading inputs in his game DynaDungeons: https://github.com/akien-mga/dynadungeons/blob/master/scripts/global.gd#L93 Take a look at load_config() function.
Nice to know, I will add this as a hint to the answer for people that will look for this answer in the future
kubecz3k | 2016-04-13 14:06