stickycamera and command not found mesage
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://bt4pohi6srcvi"]
|
[gd_scene load_steps=2 format=3 uid="uid://dlkpivjpbxnlg"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://src/scene-scripts/console.cs" id="1_c6bre"]
|
[ext_resource type="Script" path="res://src/scene-scripts/console/console.cs" id="1_gdt1r"]
|
||||||
|
|
||||||
[node name="popup_panel" type="PopupPanel"]
|
[node name="popup_panel" type="PopupPanel"]
|
||||||
transparent_bg = true
|
transparent_bg = true
|
||||||
size = Vector2i(1537, 193)
|
size = Vector2i(1537, 193)
|
||||||
visible = true
|
visible = true
|
||||||
script = ExtResource("1_c6bre")
|
script = ExtResource("1_gdt1r")
|
||||||
|
|
||||||
[node name="v_box_container" type="VBoxContainer" parent="."]
|
[node name="v_box_container" type="VBoxContainer" parent="."]
|
||||||
offset_left = 4.0
|
offset_left = 4.0
|
||||||
@@ -17,17 +17,20 @@ offset_bottom = 189.0
|
|||||||
[node name="rich_text_label" type="RichTextLabel" parent="v_box_container"]
|
[node name="rich_text_label" type="RichTextLabel" parent="v_box_container"]
|
||||||
custom_minimum_size = Vector2(0, 150)
|
custom_minimum_size = Vector2(0, 150)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
focus_mode = 2
|
||||||
bbcode_enabled = true
|
bbcode_enabled = true
|
||||||
text = "[color=red][b]USING CHEATS MAY DISABLE ACHIEVEMENTS[/b][/color]"
|
text = "[color=red][b]USING CHEATS MAY PAUSE ACHIEVEMENTS WHILE THE CHEATS ARE ACTIVE[/b][/color]
|
||||||
|
"
|
||||||
scroll_following = true
|
scroll_following = true
|
||||||
|
selection_enabled = true
|
||||||
|
|
||||||
[node name="line_edit" type="LineEdit" parent="v_box_container"]
|
[node name="line_edit" type="LineEdit" parent="v_box_container"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
placeholder_text = "Type in cheat or command. Use \"help\" for help."
|
placeholder_text = "Type in cheat or command. Use \"help\" for help."
|
||||||
max_length = 200
|
max_length = 200
|
||||||
|
context_menu_enabled = false
|
||||||
clear_button_enabled = true
|
clear_button_enabled = true
|
||||||
flat = true
|
flat = true
|
||||||
draw_control_chars = true
|
|
||||||
select_all_on_focus = true
|
select_all_on_focus = true
|
||||||
caret_blink = true
|
caret_blink = true
|
||||||
caret_blink_interval = 0.5
|
caret_blink_interval = 0.5
|
||||||
|
@@ -45,7 +45,7 @@ metadata/_edit_lock_ = true
|
|||||||
[node name="player" parent="." instance=ExtResource("2_0skrb")]
|
[node name="player" parent="." instance=ExtResource("2_0skrb")]
|
||||||
playerName = "Yannik"
|
playerName = "Yannik"
|
||||||
|
|
||||||
[node name="camera_2d" parent="player" index="2"]
|
[node name="main_cam" parent="player" index="2"]
|
||||||
limit_left = -1791
|
limit_left = -1791
|
||||||
limit_top = -1023
|
limit_top = -1023
|
||||||
limit_right = 1791
|
limit_right = 1791
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
[ext_resource type="Script" path="res://src/scene-scripts/player.cs" id="1_qehox"]
|
[ext_resource type="Script" path="res://src/scene-scripts/player.cs" id="1_qehox"]
|
||||||
[ext_resource type="Texture2D" uid="uid://olceowuycu8c" path="res://assets/textures/debug/dummy-player-atlas.png" id="2_yu1q5"]
|
[ext_resource type="Texture2D" uid="uid://olceowuycu8c" path="res://assets/textures/debug/dummy-player-atlas.png" id="2_yu1q5"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bkm7365u1mm3o" path="res://scenes/gui/dialog_bubble.tscn" id="3_8f573"]
|
[ext_resource type="PackedScene" uid="uid://bkm7365u1mm3o" path="res://scenes/gui/dialog_bubble.tscn" id="3_8f573"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bt4pohi6srcvi" path="res://scenes/gui/console.tscn" id="4_kw3hh"]
|
[ext_resource type="PackedScene" uid="uid://dlkpivjpbxnlg" path="res://scenes/gui/console.tscn" id="4_kw3hh"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tokqm"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_tokqm"]
|
||||||
atlas = ExtResource("2_yu1q5")
|
atlas = ExtResource("2_yu1q5")
|
||||||
@@ -87,7 +87,7 @@ animations = [{
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_38v5o"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_38v5o"]
|
||||||
radius = 7.99997
|
radius = 7.99997
|
||||||
height = 33.9946
|
height = 32.0
|
||||||
|
|
||||||
[node name="player" type="CharacterBody2D"]
|
[node name="player" type="CharacterBody2D"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
@@ -114,9 +114,8 @@ sprite_frames = SubResource("SpriteFrames_2x1cy")
|
|||||||
animation = &"move_down"
|
animation = &"move_down"
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="camera_2d" type="Camera2D" parent="."]
|
[node name="main_cam" type="Camera2D" parent="."]
|
||||||
zoom = Vector2(0.8, 0.8)
|
zoom = Vector2(0.8, 0.8)
|
||||||
process_callback = 0
|
|
||||||
position_smoothing_enabled = true
|
position_smoothing_enabled = true
|
||||||
position_smoothing_speed = 3.0
|
position_smoothing_speed = 3.0
|
||||||
drag_horizontal_enabled = true
|
drag_horizontal_enabled = true
|
||||||
@@ -128,6 +127,10 @@ drag_bottom_margin = 0.15
|
|||||||
editor_draw_drag_margin = true
|
editor_draw_drag_margin = true
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="cheat_cam" type="Camera2D" parent="."]
|
||||||
|
zoom = Vector2(0.8, 0.8)
|
||||||
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="audio_listener_2d" type="AudioListener2D" parent="."]
|
[node name="audio_listener_2d" type="AudioListener2D" parent="."]
|
||||||
current = true
|
current = true
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
@@ -1,74 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
public partial class console : PopupPanel
|
|
||||||
{
|
|
||||||
public RichTextLabel textblock;
|
|
||||||
public LineEdit line;
|
|
||||||
|
|
||||||
public string error = "Not found! :(";
|
|
||||||
|
|
||||||
//functions with capital letters can't be used inside the console
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
textblock = GetNode<RichTextLabel>("v_box_container/rich_text_label");
|
|
||||||
line = GetNode<LineEdit>("v_box_container/line_edit");
|
|
||||||
}
|
|
||||||
public override void _Process(double delta)
|
|
||||||
{
|
|
||||||
if (Input.IsActionJustPressed("console"))
|
|
||||||
{
|
|
||||||
Visible = !Visible;
|
|
||||||
line.GrabFocus();
|
|
||||||
if (GetParent().Name == "player") GetParent<player>().allowMovement = !Visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void OnPopupHide()
|
|
||||||
{
|
|
||||||
if (GetParent().Name == "player") GetParent<player>().allowMovement = true;
|
|
||||||
}
|
|
||||||
public void OnLineEditTextSubmitted(string command)
|
|
||||||
{
|
|
||||||
line.Clear();
|
|
||||||
if (command.Length != 0) textblock.AddText("\n>" + command);
|
|
||||||
Variant args;
|
|
||||||
if (command.Split(' ').Length == 2)
|
|
||||||
{
|
|
||||||
int i = command.IndexOf(" ") + 1;
|
|
||||||
args = command.Substring(i);
|
|
||||||
Call(command.Split(' ')[0].ToLower(), args);
|
|
||||||
}
|
|
||||||
if (command.Split(' ').Length > 2)
|
|
||||||
{
|
|
||||||
int i = command.IndexOf(" ") + 1;
|
|
||||||
args = command.Substring(i).Split(' ');
|
|
||||||
Callv(command.Split(' ')[0].ToLower(), args.AsGodotArray());
|
|
||||||
}
|
|
||||||
else Call(command.ToLower());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void help()
|
|
||||||
{
|
|
||||||
textblock.AddText("\n============ Help ============");
|
|
||||||
textblock.AddText("\n1. consoleclear - Clears the console");
|
|
||||||
textblock.AddText("\n2. speed <multiplier number> - Multiplies the player speed by the given value");
|
|
||||||
textblock.AddText("\n3. playername <new name> - Renames the player");
|
|
||||||
}
|
|
||||||
public void consoleclear() => textblock.Clear();
|
|
||||||
public void speed(float multiplier)
|
|
||||||
{
|
|
||||||
if (GetParent().Name == "player") GetParent<player>().speed = 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<player>().playerName = name;
|
|
||||||
GetParent<player>().ClearPlayerName();
|
|
||||||
textblock.AddText("\nYour new name is now: " + GetParent<player>().playerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
9
src/scene-scripts/console/commands.json
Normal file
9
src/scene-scripts/console/commands.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"help": " - Shows this help\n",
|
||||||
|
"consoleclear": " - Clears the console\n",
|
||||||
|
"speed": " <multiplier number> - Multiplies the player speed by the given value\n",
|
||||||
|
"noclip": " - Toggles the player collision and lets you walk through walls and world barriers\n",
|
||||||
|
"stickycamera": " - Toggles the camera mode. Stickycamera follows the player without limits and extra animation\n",
|
||||||
|
"playername": " <new name> - Renames the player\n",
|
||||||
|
"reload": " - Reloads the current level (for softlocks or other issues)\n"
|
||||||
|
}
|
113
src/scene-scripts/console/console.cs
Normal file
113
src/scene-scripts/console/console.cs
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
using Godot;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
|
public partial class console : PopupPanel
|
||||||
|
{
|
||||||
|
public RichTextLabel textblock;
|
||||||
|
public LineEdit line;
|
||||||
|
public Dictionary commandDict;
|
||||||
|
public string error = "Not found! :(\n";
|
||||||
|
|
||||||
|
//functions with capital letters can't be used inside the console
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
textblock = GetNode<RichTextLabel>("v_box_container/rich_text_label");
|
||||||
|
line = GetNode<LineEdit>("v_box_container/line_edit");
|
||||||
|
commandDict = Json.ParseString(FileAccess.GetFileAsString("res://src/scene-scripts/console/commands.json").ToString()).AsGodotDictionary();
|
||||||
|
}
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
if (Input.IsActionJustPressed("console"))
|
||||||
|
{
|
||||||
|
Visible = !Visible;
|
||||||
|
line.GrabFocus();
|
||||||
|
GetParent<player>().allowMovement = !Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void OnPopupHide() => GetParent<player>().allowMovement = true;
|
||||||
|
public void OnLineEditTextSubmitted(string command)
|
||||||
|
{
|
||||||
|
line.Clear();
|
||||||
|
if (command.Length != 0) textblock.AddText(GetParent<player>().playerName + " > " + command + "\n");
|
||||||
|
Variant args;
|
||||||
|
if (command.Split(' ').Length == 2 && commandDict.ContainsKey(command.Split(' ')[0].ToLower()))
|
||||||
|
{
|
||||||
|
int i = command.IndexOf(" ") + 1;
|
||||||
|
args = command.Substring(i);
|
||||||
|
commandDict.ContainsKey(command.Split(' ')[0].ToLower());
|
||||||
|
Call(command.Split(' ')[0].ToLower(), args);
|
||||||
|
}
|
||||||
|
else if (command.Split(' ').Length > 2 && commandDict.ContainsKey(command.Split(' ')[0].ToLower()))
|
||||||
|
{
|
||||||
|
int i = command.IndexOf(" ") + 1;
|
||||||
|
args = command.Substring(i).Split(' ');
|
||||||
|
commandDict.ContainsKey(command.Split(' ')[0].ToLower());
|
||||||
|
Callv(command.Split(' ')[0].ToLower(), args.AsGodotArray());
|
||||||
|
}
|
||||||
|
else if (commandDict.ContainsKey(command.ToLower()))
|
||||||
|
{
|
||||||
|
Call(command.ToLower());
|
||||||
|
}
|
||||||
|
else textblock.AddText(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void help(/*string key = ""*/) //bug: optional parameters aren't optional in Call()
|
||||||
|
{
|
||||||
|
/*if (key.Length == 0)
|
||||||
|
{*/
|
||||||
|
textblock.AddText("==================================== Help ====================================\n");
|
||||||
|
for (int i = 0; i < commandDict.Count; i++)
|
||||||
|
{
|
||||||
|
textblock.AddText((i + 1) + ". " + Json.ParseString(commandDict.Keys.ToString()).AsStringArray()[i]);
|
||||||
|
textblock.AddText(Json.ParseString(commandDict.Values.ToString()).AsStringArray()[i]);
|
||||||
|
}
|
||||||
|
/*}
|
||||||
|
else if (commandDict.ContainsKey(key))
|
||||||
|
{
|
||||||
|
textblock.AddText(key);
|
||||||
|
textblock.AddText(commandDict[key].ToString());
|
||||||
|
}
|
||||||
|
else textblock.AddText(error);*/
|
||||||
|
}
|
||||||
|
public void consoleclear() => textblock.Clear();
|
||||||
|
public void speed(float multiplier)
|
||||||
|
{
|
||||||
|
GetParent<player>().speed = Mathf.Clamp(multiplier, 0.01f, 15f);
|
||||||
|
textblock.AddText("Set speed to " + Mathf.Clamp(multiplier, 0.01f, 15f) + "\n");
|
||||||
|
}
|
||||||
|
public void noclip()
|
||||||
|
{
|
||||||
|
CollisionShape2D collision = GetParent<player>().GetNode<CollisionShape2D>("collision_shape");
|
||||||
|
collision.Disabled = !collision.Disabled;
|
||||||
|
textblock.AddText("Noclip is now set to: " + collision.Disabled + "\n");
|
||||||
|
}
|
||||||
|
public void stickycamera()
|
||||||
|
{
|
||||||
|
Camera2D cheatCam = GetParent<player>().GetNode<Camera2D>("cheat_cam");
|
||||||
|
Camera2D mainCam = GetParent<player>().GetNode<Camera2D>("main_cam");
|
||||||
|
if (mainCam.Enabled)
|
||||||
|
{
|
||||||
|
cheatCam.Enabled = true;
|
||||||
|
mainCam.Enabled = false;
|
||||||
|
textblock.AddText("cheat_cam has been enabled\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cheatCam.Enabled = false;
|
||||||
|
mainCam.Enabled = true;
|
||||||
|
textblock.AddText("cheat_cam has been disabled\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void reload() => GetTree().ReloadCurrentScene();
|
||||||
|
}
|
Reference in New Issue
Block a user