diff options
author | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-06-10 11:52:46 -0500 |
---|---|---|
committer | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-06-10 11:52:46 -0500 |
commit | 367705cf6826766a9102315d75cd690d8e6b8929 (patch) | |
tree | 982d2b364828c7a5ae57c1c57fb7707920440ddd /src/client/util/Scripting.ts | |
parent | d6e17e1fd23ac867e13d601a2dae61acbf0a7195 (diff) |
fixed add global method in ScriptManager
Diffstat (limited to 'src/client/util/Scripting.ts')
-rw-r--r-- | src/client/util/Scripting.ts | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts index b34bf0406..bb43c9af8 100644 --- a/src/client/util/Scripting.ts +++ b/src/client/util/Scripting.ts @@ -53,7 +53,7 @@ export namespace Scripting { export function addGlobal(global: { name: string }, decription?: string, params?: string): void; export function addGlobal(global: { name: string }, decription?: string, params?: string, name?: string): void; - export function addGlobal(first: any, second?: any, third?: string, fourth?: string) { + export function addGlobal(first: any, second?: any, third?: string) { let n: any; let obj: any; @@ -70,13 +70,6 @@ export namespace Scripting { if (third !== undefined) { obj.push(third); } - if (fourth !== undefined) { - console.log("WE SHOULD BE HERE"); - n = fourth; - } else { - console.log("HOW DID WE GET HERE"); - n = first.name; - } } } else if (first && typeof first.name === "string") { n = first.name; @@ -84,7 +77,9 @@ export namespace Scripting { } else { throw new Error("Must either register an object with a name, or give a name and an object"); } - if (_scriptingGlobals.hasOwnProperty(n)) { + if (n === undefined || n === "undefined") { + return false; + } else if (_scriptingGlobals.hasOwnProperty(n)) { throw new Error(`Global with name ${n} is already registered, choose another name`); } _scriptingGlobals[n] = obj; @@ -99,7 +94,7 @@ export namespace Scripting { } export function removeGlobal(name: string) { - if (_scriptingGlobals.hasKey(name)) { + if (getGlobals().includes(name)) { delete _scriptingGlobals.container[name]; return true; } |