Skip to content

Commit dcec70e

Browse files
committed
added lua functions for artemis integration
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
1 parent 03a3785 commit dcec70e

File tree

5 files changed

+56
-13
lines changed

5 files changed

+56
-13
lines changed

source/ArtemisIntegration.hx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ class ArtemisIntegration {
131131
public static function setBlammedLights (hexCode:String) {
132132
if (artemisAvailable) {
133133
var request = new haxe.Http (fnfEndpoints + "SetBlammedHex");
134-
request.setPostData (hexCode);
134+
request.setPostData (Json.stringify ({ FlashHex: hexCode, FadeTime: 1 }));
135135
request.request (true);
136136
}
137137
}
138138

139-
public static function setFlashColor (hexCode:String) {
139+
public static function triggerFlash (hexCode:String) {
140140
if (artemisAvailable) {
141-
var request = new haxe.Http (fnfEndpoints + "FlashColorHex");
142-
request.setPostData (hexCode);
141+
var request = new haxe.Http (fnfEndpoints + "TriggerFlash");
142+
request.setPostData (Json.stringify ({ FlashHex: hexCode, FadeTime: 2 }));
143143
request.request (true);
144144
}
145145
}
@@ -244,4 +244,12 @@ class ArtemisIntegration {
244244
request.request (true);
245245
}
246246
}
247+
248+
public static function triggerCustomEvent (eventName:String, customArgColor:String, customArgInt:Int) {
249+
if (artemisAvailable) {
250+
var request = new haxe.Http (fnfEndpoints + "TriggerCustomEvent");
251+
request.setPostData (Json.stringify ({ Name: eventName, Hex: customArgColor, Num: customArgInt }));
252+
request.request (true);
253+
}
254+
}
247255
}

source/FunkinLua.hx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,41 @@ class FunkinLua {
14401440
}
14411441
});
14421442

1443+
// Artemis functions
1444+
Lua_helper.add_callback(lua, "setArtemisBackgroundColor", function(color:String) {
1445+
ArtemisIntegration.setBackgroundColor (color);
1446+
});
1447+
Lua_helper.add_callback(lua, "setArtemisAccentColor1", function(color:String) {
1448+
ArtemisIntegration.setAccentColor1 (color);
1449+
});
1450+
Lua_helper.add_callback(lua, "setArtemisAccentColor2", function(color:String) {
1451+
ArtemisIntegration.setAccentColor2 (color);
1452+
});
1453+
Lua_helper.add_callback(lua, "setArtemisAccentColor3", function(color:String) {
1454+
ArtemisIntegration.setAccentColor3 (color);
1455+
});
1456+
Lua_helper.add_callback(lua, "setArtemisAccentColor4", function(color:String) {
1457+
ArtemisIntegration.setAccentColor4 (color);
1458+
});
1459+
Lua_helper.add_callback(lua, "triggerArtemisFlash", function(color:String) {
1460+
ArtemisIntegration.triggerFlash (color);
1461+
});
1462+
Lua_helper.add_callback(lua, "setArtemisFadeColor", function(color:String) {
1463+
ArtemisIntegration.setFadeColor (color);
1464+
});
1465+
Lua_helper.add_callback(lua, "setArtemisBlammedLights", function(color:String) {
1466+
ArtemisIntegration.setBlammedLights (color);
1467+
});
1468+
Lua_helper.add_callback(lua, "toggleArtemisFade", function(enable:Bool) {
1469+
ArtemisIntegration.toggleFade (enable);
1470+
});
1471+
Lua_helper.add_callback(lua, "setArtemisStageName", function(stageName:String) {
1472+
ArtemisIntegration.setStageName (stageName);
1473+
});
1474+
Lua_helper.add_callback(lua, "setArtemisIsPixelStage", function(isPixelStage:Bool) {
1475+
ArtemisIntegration.setIsPixelStage (isPixelStage);
1476+
});
1477+
14431478

14441479
// DEPRECATED, DONT MESS WITH THESE SHITS, ITS JUST THERE FOR BACKWARD COMPATIBILITY
14451480
Lua_helper.add_callback(lua, "luaSpriteMakeGraphic", function(tag:String, width:Int, height:Int, color:String) {

source/MainMenuState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class MainMenuState extends MusicBeatState
211211

212212
if(ClientPrefs.flashing) {
213213
FlxFlicker.flicker(magenta, 1.1, 0.15, false);
214-
ArtemisIntegration.setFlashColor (StringTools.hex (magenta.color));
214+
ArtemisIntegration.triggerFlash (StringTools.hex (magenta.color));
215215
}
216216

217217
menuItems.forEach(function(spr:FlxSprite)

source/PlayState.hx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,7 +4049,7 @@ class PlayState extends MusicBeatState
40494049
}
40504050

40514051
if(ClientPrefs.flashing) {
4052-
ArtemisIntegration.setFlashColor ("#FFFFFFEF");
4052+
ArtemisIntegration.triggerFlash ("#FFFFFFEF");
40534053
halloweenWhite.alpha = 0.4;
40544054
FlxTween.tween(halloweenWhite, {alpha: 0.5}, 0.075);
40554055
FlxTween.tween(halloweenWhite, {alpha: 0}, 0.25, {startDelay: 0.15});
@@ -4259,15 +4259,15 @@ class PlayState extends MusicBeatState
42594259
switch (curLight)
42604260
{
42614261
case 0:
4262-
ArtemisIntegration.setAccentColor1 ("#FF31A2FD");
4262+
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FF31A2FD", curBeat);
42634263
case 1:
4264-
ArtemisIntegration.setAccentColor1 ("#FF31FD8C");
4264+
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FF31FD8C", curBeat);
42654265
case 2:
4266-
ArtemisIntegration.setAccentColor1 ("#FFFB33F5");
4266+
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FFFB33F5", curBeat);
42674267
case 3:
4268-
ArtemisIntegration.setAccentColor1 ("#FFFD4531");
4268+
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FFFD4531", curBeat);
42694269
case 4:
4270-
ArtemisIntegration.setAccentColor1 ("#FFFBA633");
4270+
ArtemisIntegration.triggerCustomEvent ("cityLights", "#FFFBA633", curBeat);
42714271
}
42724272

42734273
phillyCityLights.members[curLight].visible = true;

source/TitleState.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ class TitleState extends MusicBeatState
454454
transitioning = true;
455455
// FlxG.sound.music.stop();
456456

457-
ArtemisIntegration.setFlashColor ("#FFFFFFFF");
457+
ArtemisIntegration.triggerFlash ("#3FFFFFFF");
458458

459459
new FlxTimer().start(1, function(tmr:FlxTimer)
460460
{
@@ -655,7 +655,7 @@ class TitleState extends MusicBeatState
655655
{
656656
remove(ngSpr);
657657

658-
ArtemisIntegration.setFlashColor ("#FFFFFFFF");
658+
ArtemisIntegration.triggerFlash ("#FFFFFFFF");
659659
FlxG.camera.flash(FlxColor.WHITE, 4);
660660
remove(credGroup);
661661
skippedIntro = true;

0 commit comments

Comments
 (0)