Skip to content

Commit

Permalink
added lua functions for artemis integration
Browse files Browse the repository at this point in the history
also added custom event triggers for more versatility, and reworked how flashes and blammed lights are handled so they're now events instead of the weird way i did things before
  • Loading branch information
skedgyedgy committed Jan 1, 2022
1 parent 03a3785 commit dcec70e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
16 changes: 12 additions & 4 deletions source/ArtemisIntegration.hx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ class ArtemisIntegration {
public static function setBlammedLights (hexCode:String) {
if (artemisAvailable) {
var request = new haxe.Http (fnfEndpoints + "SetBlammedHex");
request.setPostData (hexCode);
request.setPostData (Json.stringify ({ FlashHex: hexCode, FadeTime: 1 }));
request.request (true);
}
}

public static function setFlashColor (hexCode:String) {
public static function triggerFlash (hexCode:String) {
if (artemisAvailable) {
var request = new haxe.Http (fnfEndpoints + "FlashColorHex");
request.setPostData (hexCode);
var request = new haxe.Http (fnfEndpoints + "TriggerFlash");
request.setPostData (Json.stringify ({ FlashHex: hexCode, FadeTime: 2 }));
request.request (true);
}
}
Expand Down Expand Up @@ -244,4 +244,12 @@ class ArtemisIntegration {
request.request (true);
}
}

public static function triggerCustomEvent (eventName:String, customArgColor:String, customArgInt:Int) {
if (artemisAvailable) {
var request = new haxe.Http (fnfEndpoints + "TriggerCustomEvent");
request.setPostData (Json.stringify ({ Name: eventName, Hex: customArgColor, Num: customArgInt }));
request.request (true);
}
}
}
35 changes: 35 additions & 0 deletions source/FunkinLua.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,41 @@ class FunkinLua {
}
});

// Artemis functions
Lua_helper.add_callback(lua, "setArtemisBackgroundColor", function(color:String) {
ArtemisIntegration.setBackgroundColor (color);
});
Lua_helper.add_callback(lua, "setArtemisAccentColor1", function(color:String) {
ArtemisIntegration.setAccentColor1 (color);
});
Lua_helper.add_callback(lua, "setArtemisAccentColor2", function(color:String) {
ArtemisIntegration.setAccentColor2 (color);
});
Lua_helper.add_callback(lua, "setArtemisAccentColor3", function(color:String) {
ArtemisIntegration.setAccentColor3 (color);
});
Lua_helper.add_callback(lua, "setArtemisAccentColor4", function(color:String) {
ArtemisIntegration.setAccentColor4 (color);
});
Lua_helper.add_callback(lua, "triggerArtemisFlash", function(color:String) {
ArtemisIntegration.triggerFlash (color);
});
Lua_helper.add_callback(lua, "setArtemisFadeColor", function(color:String) {
ArtemisIntegration.setFadeColor (color);
});
Lua_helper.add_callback(lua, "setArtemisBlammedLights", function(color:String) {
ArtemisIntegration.setBlammedLights (color);
});
Lua_helper.add_callback(lua, "toggleArtemisFade", function(enable:Bool) {
ArtemisIntegration.toggleFade (enable);
});
Lua_helper.add_callback(lua, "setArtemisStageName", function(stageName:String) {
ArtemisIntegration.setStageName (stageName);
});
Lua_helper.add_callback(lua, "setArtemisIsPixelStage", function(isPixelStage:Bool) {
ArtemisIntegration.setIsPixelStage (isPixelStage);
});


// DEPRECATED, DONT MESS WITH THESE SHITS, ITS JUST THERE FOR BACKWARD COMPATIBILITY
Lua_helper.add_callback(lua, "luaSpriteMakeGraphic", function(tag:String, width:Int, height:Int, color:String) {
Expand Down
2 changes: 1 addition & 1 deletion source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class MainMenuState extends MusicBeatState

if(ClientPrefs.flashing) {
FlxFlicker.flicker(magenta, 1.1, 0.15, false);
ArtemisIntegration.setFlashColor (StringTools.hex (magenta.color));
ArtemisIntegration.triggerFlash (StringTools.hex (magenta.color));
}

menuItems.forEach(function(spr:FlxSprite)
Expand Down
12 changes: 6 additions & 6 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4049,7 +4049,7 @@ class PlayState extends MusicBeatState
}

if(ClientPrefs.flashing) {
ArtemisIntegration.setFlashColor ("#FFFFFFEF");
ArtemisIntegration.triggerFlash ("#FFFFFFEF");
halloweenWhite.alpha = 0.4;
FlxTween.tween(halloweenWhite, {alpha: 0.5}, 0.075);
FlxTween.tween(halloweenWhite, {alpha: 0}, 0.25, {startDelay: 0.15});
Expand Down Expand Up @@ -4259,15 +4259,15 @@ class PlayState extends MusicBeatState
switch (curLight)
{
case 0:
ArtemisIntegration.setAccentColor1 ("#FF31A2FD");
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FF31A2FD", curBeat);
case 1:
ArtemisIntegration.setAccentColor1 ("#FF31FD8C");
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FF31FD8C", curBeat);
case 2:
ArtemisIntegration.setAccentColor1 ("#FFFB33F5");
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FFFB33F5", curBeat);
case 3:
ArtemisIntegration.setAccentColor1 ("#FFFD4531");
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FFFD4531", curBeat);
case 4:
ArtemisIntegration.setAccentColor1 ("#FFFBA633");
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FFFBA633", curBeat);
}

phillyCityLights.members[curLight].visible = true;
Expand Down
4 changes: 2 additions & 2 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class TitleState extends MusicBeatState
transitioning = true;
// FlxG.sound.music.stop();

ArtemisIntegration.setFlashColor ("#FFFFFFFF");
ArtemisIntegration.triggerFlash ("#3FFFFFFF");

new FlxTimer().start(1, function(tmr:FlxTimer)
{
Expand Down Expand Up @@ -655,7 +655,7 @@ class TitleState extends MusicBeatState
{
remove(ngSpr);

ArtemisIntegration.setFlashColor ("#FFFFFFFF");
ArtemisIntegration.triggerFlash ("#FFFFFFFF");
FlxG.camera.flash(FlxColor.WHITE, 4);
remove(credGroup);
skippedIntro = true;
Expand Down

0 comments on commit dcec70e

Please sign in to comment.