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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 809ed7e commit bcfe44b
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
@@ -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;
35 changes: 21 additions & 14 deletions rt-shell/objects/obj_shell/Step_0.gml
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit bcfe44b

Please sign in to comment.