Last active
May 16, 2025 20:53
-
-
Save NAEL2XD/025f1112d9e14d8596823d82e6cbc997 to your computer and use it in GitHub Desktop.
FNF Utils: FNF Chart to AYS converter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package; | |
| /* | |
| FNF CHART TO AYS CONVERTER! | |
| If you need the executable then link is in below. | |
| https://drive.google.com/file/d/1CjXfIDQ0OF_f2TNKPokAsa57Vwc2kVcj/view?usp=sharing | |
| */ | |
| import flixel.util.FlxSort; | |
| import flixel.FlxG; | |
| import flixel.FlxState; | |
| import flixel.text.FlxText; | |
| import haxe.Json; | |
| import lime.ui.FileDialog; | |
| import sys.FileSystem; | |
| import sys.io.File; | |
| import StringTools; | |
| class FNFC2AYS extends FlxState | |
| { | |
| var helpText:FlxText = new FlxText(0, 0, 1280, "Tool by Nael2xd (NOW IN HAXE!)\n\nPress SPACE to convert a chart\nBTW!! Launch as cmd prompt for progress.", 56); | |
| override public function create() | |
| { | |
| if (!FileSystem.exists("out/")) FileSystem.createDirectory("out/"); | |
| add(helpText); | |
| super.create(); | |
| } | |
| public static function round(number:Float, ?precision=4): Float | |
| { | |
| number *= Math.pow(10, precision); | |
| return Math.round(number) / Math.pow(10, precision); | |
| } | |
| function sortByTime(Obj1:Dynamic, Obj2:Dynamic):Int { | |
| var result = FlxSort.byValues(FlxSort.ASCENDING, Obj1[0], Obj2[0]); | |
| return result; | |
| } | |
| override public function update(elapsed:Float) | |
| { | |
| if (FlxG.keys.justPressed.SPACE) { | |
| try { | |
| var file = new FileDialog(); | |
| var storage:Array<Array<Float>> = []; | |
| file.onOpen.add(file -> { | |
| trace("Parsing File..."); | |
| var parsed = Json.parse(file); | |
| trace("Done parsing file, loading chart..."); | |
| var noteData:Array<Dynamic> = parsed.song.notes; | |
| for (section in noteData) { | |
| var mustHit = section.mustHitSection; | |
| var stupid:Array<Dynamic> = section.sectionNotes; | |
| for (notes in stupid) { | |
| var time = round(notes[0]/1000); | |
| var data = notes[1]+(mustHit ? 5 : 1); | |
| if (data >= 9) | |
| data -= 8; | |
| storage.push([time, data]); | |
| } | |
| } | |
| trace("Converting..."); | |
| storage.sort(sortByTime); | |
| var save = storage + ""; | |
| save = StringTools.replace(save, "[", ""); | |
| save = StringTools.replace(save, "],", "\n"); | |
| save = StringTools.replace(save, "]]", ""); | |
| File.saveContent("out/" + parsed.song.song + "_AYS.txt", save); | |
| trace("Done! Cleaning memory."); | |
| openfl.system.System.gc(); | |
| }); | |
| file.open('json', null, "Choose a JSON File to convert."); | |
| } catch(e) { | |
| trace("An error occurred!\n" + e); | |
| } | |
| } | |
| super.update(elapsed); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment