From ef36f97ef663b8a74fbe343d2bd7a53370214e60 Mon Sep 17 00:00:00 2001 From: cmod31 Date: Sun, 19 Feb 2023 11:58:14 +0100 Subject: [PATCH] added renaming cheat --- src/scene-scripts/console.cs | 11 +++++++++++ src/scene-scripts/player.cs | 11 +++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/scene-scripts/console.cs b/src/scene-scripts/console.cs index 32d37e2..7ff5a38 100644 --- a/src/scene-scripts/console.cs +++ b/src/scene-scripts/console.cs @@ -46,6 +46,7 @@ public partial class console : CanvasLayer textblock.AddText("\n============ Help ============"); textblock.AddText("\n1. consoleclear - Clears the console"); textblock.AddText("\n2. speed - Multiplies the player speed by the given value"); + textblock.AddText("\n3. playername - Renames the player"); } public void consoleclear() => textblock.Clear(); public void speed(float multiplier) @@ -53,4 +54,14 @@ public partial class console : CanvasLayer if (GetParent().Name == "player") GetParent().speedMultiplier = Mathf.Clamp(multiplier, 0.01f, 15f); textblock.AddText("\nSet speed to " + Mathf.Clamp(multiplier, 0.01f, 15f)); } + public void playername(string name) + { + if (GetParent().Name == "player") + { + GetParent().playerName = name; + GetParent().ClearPlayerName(); + textblock.AddText("\nYour new name is now: " + GetParent().playerName); + } + + } } diff --git a/src/scene-scripts/player.cs b/src/scene-scripts/player.cs index 3e67dce..a0222e8 100644 --- a/src/scene-scripts/player.cs +++ b/src/scene-scripts/player.cs @@ -15,15 +15,18 @@ public partial class player : CharacterBody2D public RayCast2D dialogRayCast; public override void _Ready() + { + ClearPlayerName(); + animatedSprite = GetNode("animated_sprite_2d"); + rotCenter = GetNode("rotation_center"); + dialogRayCast = GetNode("rotation_center/ray_cast_2d"); + } + public void ClearPlayerName() { playerName = Regex.Replace(playerName, @"\[[^]]+\]", ""); playerName = Regex.Replace(playerName, @"<[^>]*>", ""); if (playerName.Length > 12) playerName = playerName.Substring(0, 12); - - animatedSprite = GetNode("animated_sprite_2d"); - rotCenter = GetNode("rotation_center"); - dialogRayCast = GetNode("rotation_center/ray_cast_2d"); } public override void _PhysicsProcess(double delta) {