Skip to content

Commit

Permalink
someone kill me
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryFrosty committed Sep 8, 2024
1 parent b05b3d1 commit 968ec30
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 82 deletions.
24 changes: 0 additions & 24 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,6 @@ class Main extends Sprite
fpsVar.visible = ClientPrefs.data.showFPS;
}

#if HSCRIPT_ALLOWED
crowplexus.iris.Iris.logLevel = function(level:crowplexus.iris.ErrorSeverity, x, ?pos:haxe.PosInfos):Void {
if (pos == null) {
pos = {
fileName: "hscript-iris",
lineNumber: -1,
className: "UnknownClass",
methodName: "unknownFunction",
customParams: null
}
}

var errorMsg = 'ERROR (${pos.fileName})';
if (pos.lineNumber != -1)
errorMsg += ':${pos.lineNumber}';
errorMsg += ' - ${x}';

if (PlayState.instance != null) {
PlayState.instance.addTextToDebug(errorMsg, FlxColor.RED);
}
trace(errorMsg);
}
#end

#if linux
var icon = Image.fromFile("icon.png");
Lib.current.stage.window.setIcon(icon);
Expand Down
74 changes: 17 additions & 57 deletions source/psychlua/HScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class HScript extends Iris
}
else
{
try
{
hs.executeScript(code, varsToBring);
hs.varsToBring = varsToBring;
try {
hs.scriptCode = code;
hs.execute();
}
catch(e:Dynamic)
{
Iris.error(e, hs.interp.posInfos());
catch(e:Dynamic) {
PlayState.instance.addTextToDebug('ERROR ON LOADING (${hs.origin}):${hs.interp.posInfos().lineNumber} - ${e}', FlxColor.RED);
}
}
}
Expand Down Expand Up @@ -90,9 +90,11 @@ class HScript extends Iris
scriptThing = File.getContent(f);
}
}
scriptCode = scriptThing;

this.varsToBring = varsToBring;
preset();
executeScript(scriptThing, varsToBring);
execute();
}

var varsToBring(default, set):Any = null;
Expand All @@ -113,8 +115,6 @@ class HScript extends Iris
set('Countdown', backend.BaseStage.Countdown);
set('PlayState', PlayState);
set('Paths', Paths);
set('StorageUtil', StorageUtil);
set('MobileControls', mobile.objects.MobileControls);
set('Conductor', Conductor);
set('ClientPrefs', ClientPrefs);
#if ACHIEVEMENTS_ALLOWED
Expand Down Expand Up @@ -265,7 +265,7 @@ class HScript extends Iris
{
if(funk == null) funk = parentLua;

if(parentLua != null) funk.addLocalCallback(name, func);
if(funk != null) funk.addLocalCallback(name, func);
else FunkinLua.luaTrace('createCallback ($name): 3rd argument is null', false, false, FlxColor.RED);
});
#end
Expand Down Expand Up @@ -321,48 +321,6 @@ class HScript extends Iris
set('addBehindDad', PlayState.instance.addBehindDad);
set('addBehindBF', PlayState.instance.addBehindBF);
}
#if LUA_ALLOWED
set("addTouchPad", (DPadMode:String, ActionMode:String) -> {
PlayState.instance.makeLuaTouchPad(DPadMode, ActionMode);
PlayState.instance.addLuaTouchPad();
});

set("removeTouchPad", () -> {
PlayState.instance.removeLuaTouchPad();
});

set("addTouchPadCamera", () -> {
if(PlayState.instance.luaTouchPad == null){
FunkinLua.luaTrace('addTouchPadCamera: VPAD does not exist.');
return;
}
PlayState.instance.addLuaTouchPadCamera();
});

set("touchPadJustPressed", function(button:Dynamic):Bool {
if(PlayState.instance.luaTouchPad == null){
//FunkinLua.luaTrace('touchPadJustPressed: VPAD does not exist.');
return false;
}
return PlayState.instance.luaTouchPadJustPressed(button);
});

set("touchPadPressed", function(button:Dynamic):Bool {
if(PlayState.instance.luaTouchPad == null){
//FunkinLua.luaTrace('touchPadPressed: VPAD does not exist.');
return false;
}
return PlayState.instance.luaTouchPadPressed(button);
});

set("touchPadJustReleased", function(button:Dynamic):Bool {
if(PlayState.instance.luaTouchPad == null){
//FunkinLua.luaTrace('touchPadJustReleased: VPAD does not exist.');
return false;
}
return PlayState.instance.luaTouchPadJustReleased(button);
});
#end
}

public function executeCode(?funcToRun:String = null, ?funcArgs:Array<Dynamic> = null):IrisCall {
Expand Down Expand Up @@ -473,12 +431,14 @@ class HScript extends Iris
}
#end

public function executeScript(code:String, ?varsToBring:Any = null):Dynamic
{
this.varsToBring = varsToBring;
scriptCode = code;
override function execute():Dynamic {
if (interp == null)
throw "Attempt to run script failed, script is probably destroyed.";

parse(true);
return returnValue = execute();
Iris.instances.set(this.name, this);
var value = interp.execute(expr);
return returnValue = value;
}

/*override function irisPrint(v):Void
Expand Down
2 changes: 1 addition & 1 deletion source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,7 @@ class PlayState extends MusicBeatState
{
var newScript:HScript = cast (Iris.instances.get(file), HScript);
@:privateAccess
Iris.error(e, (newScript.interp != null ? newScript.interp.posInfos() : Iris.getDefaultPos()));
addTextToDebug('ERROR ON LOADING (${file}):${newScript.interp.posInfos().lineNumber} - ${e}', FlxColor.RED);

if(newScript != null)
newScript.destroy();
Expand Down

0 comments on commit 968ec30

Please sign in to comment.