using singleton for playername now

This commit is contained in:
2023-02-22 21:20:54 +01:00
parent ca1957d618
commit a7932ce12b
5 changed files with 23 additions and 20 deletions

View File

@@ -28,7 +28,7 @@ public partial class console : PopupPanel
public void OnLineEditTextSubmitted(string command)
{
line.Clear();
if (command.Length != 0) textblock.AddText(GetParent<player>().playerName + " > " + command + "\n");
if (command.Length != 0) textblock.AddText(player_variables.PlayerName + " > " + command + "\n");
Variant args;
if (command.Split(' ').Length == 2 && commandDict.ContainsKey(command.Split(' ')[0].ToLower()))
{
@@ -102,12 +102,9 @@ public partial class console : PopupPanel
}
public void playername(string name)
{
if (GetParent().Name == "player")
{
GetParent<player>().playerName = name;
GetParent<player>().ClearPlayerName();
textblock.AddText("Your new name is now: " + GetParent<player>().playerName + "\n");
}
player_variables.PlayerName = name;
player_variables.ClearPlayerName();
textblock.AddText("Your new name is now: " + player_variables.PlayerName + "\n");
}
public void reload() => GetTree().ReloadCurrentScene();
}