Skip to content

Commit

Permalink
Hitting enter at a blank prompt no longer crashes your game
Browse files Browse the repository at this point in the history
  • Loading branch information
nickavv committed Jun 13, 2020
1 parent 809ed7e commit bcfe44b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rt-shell/objects/obj_shell/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function keyboardCheckDelay(input) {
// Graciously borrowed from here: https://www.reddit.com/r/gamemaker/comments/3zxota/splitting_strings/
function string_split(input, delimiter) {
var slot = 0;
var splits; //array to hold all splits
var splits = []; //array to hold all splits
var str2 = ""; //var to hold the current split we're working on building

var i;
Expand Down
35 changes: 21 additions & 14 deletions rt-shell/objects/obj_shell/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,29 @@ if (!isOpen) {
cursorPos = string_length(consoleString) + 1;
} else if (keyboard_check_pressed(vk_enter)) {
var args = string_split(consoleString, " ");
var script = asset_get_index("sh_" + args[0]);
if (script > -1) {
var response = script_execute(script, args);
ds_list_add(history, consoleString);
ds_list_add(output, ">" + consoleString);
if (response != 0) {
ds_list_add(output, string(response));
if (array_length(args) > 0) {
var script = asset_get_index("sh_" + args[0]);
if (script > -1) {
var response = script_execute(script, args);
ds_list_add(history, consoleString);
ds_list_add(output, ">" + consoleString);
if (response != 0) {
ds_list_add(output, string(response));
}
historyPos = ds_list_size(history);
consoleString = "";
savedConsoleString = "";
cursorPos = 1;
} else {
ds_list_add(output, ">" + consoleString);
ds_list_add(output, "No such command: " + consoleString);
ds_list_add(history, consoleString);
consoleString = "";
savedConsoleString = "";
cursorPos = 1;
}
historyPos = ds_list_size(history);
consoleString = "";
savedConsoleString = "";
cursorPos = 1;
} else {
ds_list_add(output, ">" + consoleString);
ds_list_add(output, "No such command: " + consoleString);
ds_list_add(history, consoleString);
ds_list_add(output, ">");
consoleString = "";
savedConsoleString = "";
cursorPos = 1;
Expand Down

0 comments on commit bcfe44b

Please sign in to comment.