Skip to content

Commit f0c01f5

Browse files
committed
Extended date script intergration
1 parent 1ef9daa commit f0c01f5

File tree

4 files changed

+213
-5
lines changed

4 files changed

+213
-5
lines changed

source/psychlua/FunkinLua.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ class FunkinLua {
16111611
#if ACHIEVEMENTS_ALLOWED Achievements.addLuaCallbacks(lua); #end
16121612
#if TRANSLATIONS_ALLOWED Language.addLuaCallbacks(lua); #end
16131613
#if flxanimate FlxAnimateFunctions.implement(this); #end
1614+
yutautil.ExtendedDate.addLuaCallbacks(lua);
16141615
HScript.implement(this);
16151616
ReflectionFunctions.implement(this);
16161617
TextFunctions.implement(this);

source/psychlua/HScript.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ class HScript extends Iris
533533
set('resumeVideo', function(tag:String) {
534534
if (MusicBeatState.getVariables().exists(tag)) MusicBeatState.getVariables().get(tag).resume();
535535
});
536+
537+
set('Date', yutautil.ExtendedDate);
536538
}
537539

538540
#if LUA_ALLOWED

source/substates/RankingSubstate.hx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ class RankingSubstate extends MusicBeatSubstate
131131
}
132132
} else {
133133
trace("in AP");
134-
135-
// have to regrab it cuz memnory clearing's a bastard
136-
try{APInfo.grabLimits(FlxG.save.data.gradesandacc[0], FlxG.save.data.gradesandacc[1]);}
137-
catch(e) {trace("FAILED TO GRAB LIMITS!!");}
138-
139134
if (accRankSetLimit != 0 || comboRankSetLimit != 0) {
140135
var percent:Float = CoolUtil.floorDecimal(PlayState.instance.comboManager.ratingPercent * 100, 4);
141136
if (accRankLimit > accRankSetLimit) hint.text = 'Accuracy Rank not high enough! (${accuracyNeeded - percent}% off.)';

source/yutautil/ExtendedDate.hx

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,4 +535,214 @@ class ExtendedDate extends FlxBasic {
535535
var year = this.getFullYear();
536536
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
537537
}
538+
539+
#if LUA_ALLOWED
540+
public static function addLuaCallbacks(lua:State)
541+
{
542+
Lua_helper.add_callback(lua, "getFullYear", function():Int
543+
{
544+
return instance.getFullYear();
545+
});
546+
547+
Lua_helper.add_callback(lua, "getMonth", function():Int
548+
{
549+
return instance.getMonth();
550+
});
551+
552+
Lua_helper.add_callback(lua, "getDate", function():Int
553+
{
554+
return instance.getDate();
555+
});
556+
557+
Lua_helper.add_callback(lua, "getDay", function():Int
558+
{
559+
return instance.getDay();
560+
});
561+
562+
Lua_helper.add_callback(lua, "getHours", function():Int
563+
{
564+
return instance.getHours();
565+
});
566+
567+
Lua_helper.add_callback(lua, "getMinutes", function():Int
568+
{
569+
return instance.getMinutes();
570+
});
571+
572+
Lua_helper.add_callback(lua, "getSeconds", function():Int
573+
{
574+
return instance.getSeconds();
575+
});
576+
577+
Lua_helper.add_callback(lua, "getTime", function():Float
578+
{
579+
return instance.getTime();
580+
});
581+
582+
Lua_helper.add_callback(lua, "isWeekend", function():Bool
583+
{
584+
return instance.isWeekend();
585+
});
586+
587+
Lua_helper.add_callback(lua, "isWeekday", function():Bool
588+
{
589+
return instance.isWeekday();
590+
});
591+
592+
Lua_helper.add_callback(lua, "isAprilFools", function():Bool
593+
{
594+
return instance.isAprilFools();
595+
});
596+
597+
Lua_helper.add_callback(lua, "isNewYearsDay", function():Bool
598+
{
599+
return instance.isNewYearsDay();
600+
});
601+
602+
Lua_helper.add_callback(lua, "isValentinesDay", function():Bool
603+
{
604+
return instance.isValentinesDay();
605+
});
606+
607+
Lua_helper.add_callback(lua, "isIndependenceDay", function():Bool
608+
{
609+
return instance.isIndependenceDay();
610+
});
611+
612+
Lua_helper.add_callback(lua, "isLaborDay", function():Bool
613+
{
614+
return instance.isLaborDay();
615+
});
616+
617+
Lua_helper.add_callback(lua, "isEaster", function():Bool
618+
{
619+
return instance.isEaster();
620+
});
621+
622+
Lua_helper.add_callback(lua, "isHatsuneMikuDay", function():Bool
623+
{
624+
return instance.isHatsuneMikuDay();
625+
});
626+
627+
Lua_helper.add_callback(lua, "isHatsuneMikuBirthday", function():Bool
628+
{
629+
return instance.isHatsuneMikuBirthday();
630+
});
631+
632+
Lua_helper.add_callback(lua, "isNewYearsEve", function():Bool
633+
{
634+
return instance.isNewYearsEve();
635+
});
636+
637+
Lua_helper.add_callback(lua, "isEasterSeason", function():Bool
638+
{
639+
return instance.isEasterSeason();
640+
});
641+
642+
Lua_helper.add_callback(lua, "isHalloween", function():Bool
643+
{
644+
return instance.isHalloween();
645+
});
646+
647+
Lua_helper.add_callback(lua, "isHalloweenSeason", function():Bool
648+
{
649+
return instance.isHalloweenSeason();
650+
});
651+
652+
Lua_helper.add_callback(lua, "isChristmas", function():Bool
653+
{
654+
return instance.isChristmas();
655+
});
656+
657+
Lua_helper.add_callback(lua, "isChristmasSeason", function():Bool
658+
{
659+
return instance.isChristmasSeason();
660+
});
661+
662+
Lua_helper.add_callback(lua, "isThanksgiving", function():Bool
663+
{
664+
return instance.isThanksgiving();
665+
});
666+
667+
Lua_helper.add_callback(lua, "isPrideMonth", function():Bool
668+
{
669+
return instance.isPrideMonth();
670+
});
671+
672+
Lua_helper.add_callback(lua, "dateAsString", function():String
673+
{
674+
return instance.asString();
675+
});
676+
677+
Lua_helper.add_callback(lua, "getDaysInMonth", function():Int
678+
{
679+
return instance.getDaysInMonth();
680+
});
681+
682+
Lua_helper.add_callback(lua, "getDaysInYear", function():Int
683+
{
684+
return instance.getDaysInYear();
685+
});
686+
687+
Lua_helper.add_callback(lua, "getDaysLeftInMonth", function():Int
688+
{
689+
return instance.getDaysLeftInMonth();
690+
});
691+
692+
Lua_helper.add_callback(lua, "getDaysLeftInYear", function():Int
693+
{
694+
return instance.getDaysLeftInYear();
695+
});
696+
697+
Lua_helper.add_callback(lua, "getDayOfYear", function():Int
698+
{
699+
return instance.getDayOfYear();
700+
});
701+
702+
Lua_helper.add_callback(lua, "getWeekOfYear", function():Int
703+
{
704+
return instance.getWeekOfYear();
705+
});
706+
707+
Lua_helper.add_callback(lua, "getWeekOfMonth", function():Int
708+
{
709+
return instance.getWeekOfMonth();
710+
});
711+
712+
Lua_helper.add_callback(lua, "getWeeksLeftInYear", function():Int
713+
{
714+
return instance.getWeeksLeftInYear();
715+
});
716+
717+
Lua_helper.add_callback(lua, "getWeeksLeftInMonth", function():Int
718+
{
719+
return instance.getWeeksLeftInMonth();
720+
});
721+
722+
Lua_helper.add_callback(lua, "getWeeksLeftInMonth", function():Int
723+
{
724+
return instance.getWeeksLeftInMonth();
725+
});
726+
727+
Lua_helper.add_callback(lua, "time", function():String
728+
{
729+
return instance.time();
730+
});
731+
732+
Lua_helper.add_callback(lua, "exactTimeNow", function():String
733+
{
734+
return exactTimeNow();
735+
});
736+
737+
Lua_helper.add_callback(lua, "formatDate", function(format:String):String
738+
{
739+
return instance.formatDate(format);
740+
});
741+
742+
Lua_helper.add_callback(lua, "isLeapYear", function():Bool
743+
{
744+
return instance.isLeapYear();
745+
});
746+
}
747+
#end
538748
}

0 commit comments

Comments
 (0)