From 37542065d6c1297ac63eac27e0cf69d6b7d9b7ff Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Fri, 4 Nov 2022 20:10:35 +0100 Subject: [PATCH] bug fix (now it works as intended) --- hscript/Interp.hx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index e2dc4a3..526138c 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -70,6 +70,10 @@ class Interp { var returnValue:Dynamic; public var importEnabled:Bool = true; + + public var allowStaticVariables:Bool = false; + public var allowPublicVariables:Bool = false; + public var importBlocklist:Array = [ // "flixel.FlxG" ]; @@ -168,9 +172,9 @@ class Interp { } function setVar(name:String, v:Dynamic) { - if (staticVariables.exists(name)) + if (allowStaticVariables && staticVariables.exists(name)) staticVariables.set(name, v); - else if (publicVariables.exists(name)) + else if (allowPublicVariables && publicVariables.exists(name)) publicVariables.set(name, v); else variables.set(name, v); @@ -608,7 +612,7 @@ class Interp { if (name != null) { if (depth == 0) { // global function - (isStatic == true ? staticVariables : (isPublic ? publicVariables : variables)).set(name, f); + ((isStatic && allowStaticVariables) ? staticVariables : ((isPublic && allowPublicVariables) ? publicVariables : variables)).set(name, f); } else { // function-in-function is a local function declared.push({n: name, old: locals.get(name), depth: depth});