Skip to content

Commit

Permalink
Implement hscript-improved
Browse files Browse the repository at this point in the history
will fix rejection shaders

from my cool pr!!!!!!!
ShadowMario/FNF-PsychEngine#13304
  • Loading branch information
TheLeerName committed Sep 19, 2023
1 parent 7399a69 commit 15f3a02
Show file tree
Hide file tree
Showing 17 changed files with 478 additions and 525 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

<!--Psych stuff needed-->
<haxelib name="linc_luajit" if="LUA_ALLOWED"/>
<haxelib name="SScript" version="5.0.0" if="HSCRIPT_ALLOWED"/>
<haxelib name="hscript" if="HSCRIPT_ALLOWED"/>
<haxelib name="hxCodec" version="3.0.2" if="VIDEOS_ALLOWED"/>
<haxelib name="discord_rpc" if="desktop"/>
<haxelib name="tjson" version="1.4.0"/>
Expand Down
2 changes: 1 addition & 1 deletion art/building.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Building mod
1. Install [**Haxe 4.3.2**](https://haxe.org/download/version/4.3.2/)
1. Install [**Haxe 4.3.2**](https://haxe.org/download/version/4.3.2/) or 4.2.5 if you want
2. Do this command in cmd:
```
haxelib install hmm
Expand Down
12 changes: 7 additions & 5 deletions hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
"type": "haxelib",
"version": "3.0.2"
},
{
"name": "SScript",
"type": "haxelib",
"version": "5.0.0"
},
{
"name": "hxcpp-debug-server",
"type": "haxelib",
Expand All @@ -61,6 +56,13 @@
"dir": null,
"ref": "master",
"url": "https://github.com/Aidan63/linc_discord-rpc"
},
{
"name": "hscript",
"type": "git",
"dir": null,
"ref": "master",
"url": "https://github.com/TheLeerName/hscript-improved"
},
{
"name": "linc_luajit",
Expand Down
2 changes: 1 addition & 1 deletion source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Main extends Sprite
game.height = Math.ceil(stageHeight / game.zoom);
}

#if LUA_ALLOWED Lua.set_callbacks_function(cpp.Callable.fromStaticFunction(psychlua.CallbackHandler.call)); #end
#if LUA_ALLOWED llua.Lua.set_callbacks_function(cpp.Callable.fromStaticFunction(psychlua.CallbackHandler.call)); #end
Controls.instance = new Controls();
ClientPrefs.loadDefaultKeys();
addChild(new FlxGame(game.width, game.height, game.initialState, #if (flixel < "5.0.0") game.zoom, #end game.framerate, game.framerate, game.skipSplash, game.startFullscreen));
Expand Down
7 changes: 4 additions & 3 deletions source/backend/Discord.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package backend;
import Sys.sleep;
import discord_rpc.DiscordRpc;
import lime.app.Application;
import psychlua.FunkinLua;

class DiscordClient
{
Expand Down Expand Up @@ -143,12 +144,12 @@ class DiscordClient
#end

#if LUA_ALLOWED
public static function addLuaCallbacks(lua:State) {
Lua_helper.add_callback(lua, "changeDiscordPresence", function(details:String, state:Null<String>, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float) {
public static function addLuaCallbacks(funk:FunkinLua) {
funk.set("changeDiscordPresence", function(details:String, state:Null<String>, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float) {
changePresence(details, state, smallImageKey, hasStartTimestamp, endTimestamp);
});

Lua_helper.add_callback(lua, "changeDiscordClientID", function(?newID:String = null) {
funk.set("changeDiscordClientID", function(?newID:String = null) {
if(newID == null) newID = _defaultID;
clientID = newID;
});
Expand Down
12 changes: 11 additions & 1 deletion source/backend/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,18 @@ class Paths
return null;
}

static public function getTextFromFile(key:String, ?ignoreMods:Bool = false):String
static public function getTextFromFile(key:String, ?ignoreMods:Bool = false, ?absolute:Bool = false):String
{
if (absolute) {
#if sys
if (FileSystem.exists(key))
return File.getContent(key);
#end
if(OpenFlAssets.exists(key, TEXT))
return Assets.getText(key);

return null;
}
#if sys
#if MODS_ALLOWED
if (!ignoreMods && FileSystem.exists(modFolders(key)))
Expand Down
5 changes: 0 additions & 5 deletions source/import.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import backend.Discord;
#end

//Psych
#if LUA_ALLOWED
import llua.*;
import llua.Lua;
#end

import backend.Paths;
import backend.Controls;
import backend.CoolUtil;
Expand Down
7 changes: 3 additions & 4 deletions source/psychlua/CustomSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class CustomSubstate extends MusicBeatSubstate
public static function implement(funk:FunkinLua)
{
#if LUA_ALLOWED
var lua = funk.lua;
Lua_helper.add_callback(lua, "openCustomSubstate", openCustomSubstate);
Lua_helper.add_callback(lua, "closeCustomSubstate", closeCustomSubstate);
Lua_helper.add_callback(lua, "insertToCustomSubstate", insertToCustomSubstate);
funk.set("openCustomSubstate", openCustomSubstate);
funk.set("closeCustomSubstate", closeCustomSubstate);
funk.set("insertToCustomSubstate", insertToCustomSubstate);
#end
}

Expand Down
29 changes: 14 additions & 15 deletions source/psychlua/DeprecatedFunctions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ class DeprecatedFunctions
{
public static function implement(funk:FunkinLua)
{
var lua:State = funk.lua;
// DEPRECATED, DONT MESS WITH THESE SHITS, ITS JUST THERE FOR BACKWARD COMPATIBILITY
Lua_helper.add_callback(lua, "addAnimationByIndicesLoop", function(obj:String, name:String, prefix:String, indices:String, framerate:Int = 24) {
funk.set("addAnimationByIndicesLoop", function(obj:String, name:String, prefix:String, indices:String, framerate:Int = 24) {
FunkinLua.luaTrace("addAnimationByIndicesLoop is deprecated! Use addAnimationByIndices instead", false, true);
return LuaUtils.addAnimByIndices(obj, name, prefix, indices, framerate, true);
});

Lua_helper.add_callback(lua, "objectPlayAnimation", function(obj:String, name:String, forced:Bool = false, ?startFrame:Int = 0) {
funk.set("objectPlayAnimation", function(obj:String, name:String, forced:Bool = false, ?startFrame:Int = 0) {
FunkinLua.luaTrace("objectPlayAnimation is deprecated! Use playAnim instead", false, true);
if(PlayState.instance.getLuaObject(obj,false) != null) {
PlayState.instance.getLuaObject(obj,false).animation.play(name, forced, false, startFrame);
Expand All @@ -30,7 +29,7 @@ class DeprecatedFunctions
}
return false;
});
Lua_helper.add_callback(lua, "characterPlayAnim", function(character:String, anim:String, ?forced:Bool = false) {
funk.set("characterPlayAnim", function(character:String, anim:String, ?forced:Bool = false) {
FunkinLua.luaTrace("characterPlayAnim is deprecated! Use playAnim instead", false, true);
switch(character.toLowerCase()) {
case 'dad':
Expand All @@ -44,12 +43,12 @@ class DeprecatedFunctions
PlayState.instance.boyfriend.playAnim(anim, forced);
}
});
Lua_helper.add_callback(lua, "luaSpriteMakeGraphic", function(tag:String, width:Int, height:Int, color:String) {
funk.set("luaSpriteMakeGraphic", function(tag:String, width:Int, height:Int, color:String) {
FunkinLua.luaTrace("luaSpriteMakeGraphic is deprecated! Use makeGraphic instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag))
PlayState.instance.modchartSprites.get(tag).makeGraphic(width, height, CoolUtil.colorFromString(color));
});
Lua_helper.add_callback(lua, "luaSpriteAddAnimationByPrefix", function(tag:String, name:String, prefix:String, framerate:Int = 24, loop:Bool = true) {
funk.set("luaSpriteAddAnimationByPrefix", function(tag:String, name:String, prefix:String, framerate:Int = 24, loop:Bool = true) {
FunkinLua.luaTrace("luaSpriteAddAnimationByPrefix is deprecated! Use addAnimationByPrefix instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
var cock:ModchartSprite = PlayState.instance.modchartSprites.get(tag);
Expand All @@ -59,7 +58,7 @@ class DeprecatedFunctions
}
}
});
Lua_helper.add_callback(lua, "luaSpriteAddAnimationByIndices", function(tag:String, name:String, prefix:String, indices:String, framerate:Int = 24) {
funk.set("luaSpriteAddAnimationByIndices", function(tag:String, name:String, prefix:String, indices:String, framerate:Int = 24) {
FunkinLua.luaTrace("luaSpriteAddAnimationByIndices is deprecated! Use addAnimationByIndices instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
var strIndices:Array<String> = indices.trim().split(',');
Expand All @@ -74,13 +73,13 @@ class DeprecatedFunctions
}
}
});
Lua_helper.add_callback(lua, "luaSpritePlayAnimation", function(tag:String, name:String, forced:Bool = false) {
funk.set("luaSpritePlayAnimation", function(tag:String, name:String, forced:Bool = false) {
FunkinLua.luaTrace("luaSpritePlayAnimation is deprecated! Use playAnim instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
PlayState.instance.modchartSprites.get(tag).animation.play(name, forced);
}
});
Lua_helper.add_callback(lua, "setLuaSpriteCamera", function(tag:String, camera:String = '') {
funk.set("setLuaSpriteCamera", function(tag:String, camera:String = '') {
FunkinLua.luaTrace("setLuaSpriteCamera is deprecated! Use setObjectCamera instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
PlayState.instance.modchartSprites.get(tag).cameras = [LuaUtils.cameraFromString(camera)];
Expand All @@ -89,15 +88,15 @@ class DeprecatedFunctions
FunkinLua.luaTrace("Lua sprite with tag: " + tag + " doesn't exist!");
return false;
});
Lua_helper.add_callback(lua, "setLuaSpriteScrollFactor", function(tag:String, scrollX:Float, scrollY:Float) {
funk.set("setLuaSpriteScrollFactor", function(tag:String, scrollX:Float, scrollY:Float) {
FunkinLua.luaTrace("setLuaSpriteScrollFactor is deprecated! Use setScrollFactor instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
PlayState.instance.modchartSprites.get(tag).scrollFactor.set(scrollX, scrollY);
return true;
}
return false;
});
Lua_helper.add_callback(lua, "scaleLuaSprite", function(tag:String, x:Float, y:Float) {
funk.set("scaleLuaSprite", function(tag:String, x:Float, y:Float) {
FunkinLua.luaTrace("scaleLuaSprite is deprecated! Use scaleObject instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
var shit:ModchartSprite = PlayState.instance.modchartSprites.get(tag);
Expand All @@ -107,7 +106,7 @@ class DeprecatedFunctions
}
return false;
});
Lua_helper.add_callback(lua, "getPropertyLuaSprite", function(tag:String, variable:String) {
funk.set("getPropertyLuaSprite", function(tag:String, variable:String) {
FunkinLua.luaTrace("getPropertyLuaSprite is deprecated! Use getProperty instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
var killMe:Array<String> = variable.split('.');
Expand All @@ -122,7 +121,7 @@ class DeprecatedFunctions
}
return null;
});
Lua_helper.add_callback(lua, "setPropertyLuaSprite", function(tag:String, variable:String, value:Dynamic) {
funk.set("setPropertyLuaSprite", function(tag:String, variable:String, value:Dynamic) {
FunkinLua.luaTrace("setPropertyLuaSprite is deprecated! Use setProperty instead", false, true);
if(PlayState.instance.modchartSprites.exists(tag)) {
var killMe:Array<String> = variable.split('.');
Expand All @@ -140,12 +139,12 @@ class DeprecatedFunctions
FunkinLua.luaTrace("setPropertyLuaSprite: Lua sprite with tag: " + tag + " doesn't exist!");
return false;
});
Lua_helper.add_callback(lua, "musicFadeIn", function(duration:Float, fromValue:Float = 0, toValue:Float = 1) {
funk.set("musicFadeIn", function(duration:Float, fromValue:Float = 0, toValue:Float = 1) {
FlxG.sound.music.fadeIn(duration, fromValue, toValue);
FunkinLua.luaTrace('musicFadeIn is deprecated! Use soundFadeIn instead.', false, true);

});
Lua_helper.add_callback(lua, "musicFadeOut", function(duration:Float, toValue:Float = 0) {
funk.set("musicFadeOut", function(duration:Float, toValue:Float = 0) {
FlxG.sound.music.fadeOut(duration, toValue);
FunkinLua.luaTrace('musicFadeOut is deprecated! Use soundFadeOut instead.', false, true);
});
Expand Down
Loading

0 comments on commit 15f3a02

Please sign in to comment.