diff --git a/rt-shell/objects/obj_shell/Create_0.gml b/rt-shell/objects/obj_shell/Create_0.gml index 7557801..d1a4ffc 100644 --- a/rt-shell/objects/obj_shell/Create_0.gml +++ b/rt-shell/objects/obj_shell/Create_0.gml @@ -19,6 +19,25 @@ if (instance_number(obj_shell) > 1) { instance_destroy(); } +/// @function open +/// Opens the shell +function open() { + isOpen = true; + keyboard_string = ""; + if (!is_undefined(openFunction)) { + openFunction(); + } +} + +/// @function close +/// Closes the shell +function close() { + isOpen = false; + if (!is_undefined(closeFunction)) { + closeFunction(); + } +} + // Create a list of shell functions in the global namespace to // filter for autocompletion autocompleteFunctions = []; diff --git a/rt-shell/objects/obj_shell/Step_0.gml b/rt-shell/objects/obj_shell/Step_0.gml index f39b4ab..76b8ca6 100644 --- a/rt-shell/objects/obj_shell/Step_0.gml +++ b/rt-shell/objects/obj_shell/Step_0.gml @@ -6,20 +6,13 @@ if (!surface_exists(shellSurface)) { if (!isOpen) { if (self.keyComboPressed()) { - isOpen = true; - keyboard_string = ""; - if (!is_undefined(openFunction)) { - openFunction(); - } + self.open(); } } else { var prevConsoleString = consoleString; if (keyboard_check_pressed(vk_escape)) { - isOpen = false; - if (!is_undefined(closeFunction)) { - closeFunction(); - } + self.close() } else if (self.keyboardCheckDelay(vk_backspace)) { consoleString = string_delete(consoleString, cursorPos - 1, 1); cursorPos = max(1, cursorPos - 1); diff --git a/rt-shell/scripts/scr_shell_scripts/scr_shell_scripts.gml b/rt-shell/scripts/scr_shell_scripts/scr_shell_scripts.gml index f98111d..5eb94ea 100644 --- a/rt-shell/scripts/scr_shell_scripts/scr_shell_scripts.gml +++ b/rt-shell/scripts/scr_shell_scripts/scr_shell_scripts.gml @@ -24,7 +24,9 @@ function sh_help() { "set_shell_width \n" + " sets the shell's width in pixels\n" + "set_shell_height \n" + - " sets the shell's height in pixels" + " sets the shell's height in pixels\n" + + "close\n" + + " closes the shell" ) } @@ -91,6 +93,10 @@ function sh_say_greeting(args) { return "Hello " + whomToGreet + "!"; } +function sh_close() { + obj_shell.close(); +} + function sh_theme_rtshell_dark() { obj_shell.consoleAlpha = 0.9; obj_shell.consoleColor = c_black;