Just drivin' by again. I was thinking about creating a save/load GUI tutorial. I have not started to write on it yet, so no harm done if you don't think it's useful enough.
This is the trigger(s) I'd use in the tutorial.
Just for testing
Events
Map initialization
Conditions
Actions
Player - Add 666 to Player 1 (Red) Current lumber
Player - Add 1337 to Player 1 (Red) Current gold
Set hero_types[1] = Paladin
Set hero_types[2] = Archmage
Set hero_types[3] = Mountain King
Set hero_types[4] = Blood Mage
Set hero_names[1] = Paladin
Set hero_names[2] = Archmage
Set hero_names[3] = Mountain King
Set hero_names[4] = Blood Mage
Set hero_count = 4
Set spawn_loc = (Center of Spawn Region <gen>)
Unit - Create 1 hero_types[(Random integer number between 1 and hero_count)] for Player 1 (Red) at spawn_loc facing Default building facing degrees
Set player_hero = (Last created unit)
Hero - Set player_hero Hero-level to (Random integer number between 2 and 10), Hide level-up graphics
Init
Events
Map initialization
Conditions
Actions
Custom script: set udg_local_player = GetLocalPlayer()
GUI Save
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Custom script: local File file
Set mapName = testMap
Set file = exp
Set player = (Triggering player)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
local_player Equal to Player 1 (Red)
Then - Actions
Custom script: set file = File.open(udg_mapName, udg_file, File.Flag.WRITE)
Set what_to_save = (Name of (Triggering player))
Custom script: call file.write(udg_what_to_save)
Set what_to_save = (Name of player_hero)
Custom script: call file.write(udg_what_to_save)
Set what_to_save = (String((Level of player_hero)))
Custom script: call file.write(udg_what_to_save)
Set what_to_save = (String((player Current gold)))
Custom script: call file.write(udg_what_to_save)
Set what_to_save = (String((player Current lumber)))
Custom script: call file.write(udg_what_to_save)
Game - Display to (All players) the text: saved!
Custom script: call file.close()
Else - Actions
GUI Load
Events
Player - Player 1 (Red) types a chat message containing load as An exact match
Conditions
Actions
Custom script: local File file
Set mapName = testMap
Set file = exp
Set player = (Triggering player)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
local_player Equal to Player 1 (Red)
Then - Actions
Custom script: set file = File.open(udg_mapName, udg_file, File.Flag.READ)
Custom script: set udg_what_to_load = file.read()
Player - Set name of player to what_to_load
Custom script: set udg_what_to_load = file.read()
For each (Integer A) from 1 to hero_count, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
what_to_load Equal to hero_names[(Integer A)]
Then - Actions
Unit - Create 1 hero_types[(Integer A)] for Player 1 (Red) at spawn_loc facing Default building facing degrees
Else - Actions
Custom script: set udg_what_to_load = file.read()
Hero - Set (Last created unit) Hero-level to (Integer(what_to_load)), Hide level-up graphics
Custom script: set udg_what_to_load = file.read()
Player - Add (Integer(what_to_load)) to Player 1 (Red) Current gold
Custom script: set udg_what_to_load = file.read()
Player - Add (Integer(what_to_load)) to Player 1 (Red) Current lumber
Custom script: call file.close()
Else - Actions