project_teddy/scripts/console.gd
2023-04-11 22:37:15 -06:00

59 lines
1.9 KiB
GDScript

extends Node
var scenePlayground = "res://scenes/playground.tscn"
var sceneTutorial = "res://scenes/tutorial.tscn"
func _ready():
pass
func _process(delta):
if not Global.consoleOpen:
self.queue_free()
if Input.is_action_just_pressed("console_send"):
Global.consoleCommand = $consoleEdit.text
print ("Console command run: ", Global.consoleCommand)
run_command(Global.consoleCommand)
func run_command(command):
if command == "tele playground":
get_tree().change_scene_to_file(scenePlayground)
Global.consoleOutput = "Teleported to Playground!"
elif command == "tele tutorial":
get_tree().change_scene_to_file(sceneTutorial)
Global.consoleOutput = "Teleported to Tutorial!"
elif command == "which scene":
Global.consoleOutput = get_tree().get_current_scene().get_name()
elif command == "iamgod":
if not Global.godMode:
Global.consoleOutput = "God mode activated"
Global.godMode = true
elif Global.godMode:
Global.consoleOutput = "God mode deactivated"
Global.godMode = false
elif command == "exit":
Global.consoleOutput = "Byeee loser"
get_tree().quit()
elif command == "paul":
Global.consoleOutput = "Yuppp that's me"
elif command == "jayden":
Global.consoleOutput = "That's the noob artist"
elif command == "resetvars":
Global.consoleOutput = "Reset variables"
Global.reset_variables()
elif command in ["suicide", "kill", "die"]:
Global.consoleOutput = "Oh you didn't want to die?"
Global.playerHealth = 0
elif command == "gps":
Global.consoleOutput = str(Global.get_node(Global.selfTeddy).global_position)
elif command == "toggleHUD":
Global.consoleOutput = "HUD toggled!"
var HUD = get_node(str(Global.currentMapNode.get_path()) + str("/HUD"))
print(str(Global.currentMapNode.get_path()) + str("/HUD"))
if HUD.visible == true:
HUD.visible = false
elif HUD.visible == false:
HUD.visible = true
else:
Global.consoleOutput = "Unknown cheat code"
$output.text = Global.consoleOutput