-
Notifications
You must be signed in to change notification settings - Fork 1
Chapter 4: About HScript
ik this is already in the official modding docs but eh why not
HScript is basically Haxe if it was an interpreted scripting language. Dynamically typed, but allows all Haxe expressions apart from type declarations. Polymod uses this language to provide custom functionality via scripts to be added to games, including Friday Night Funkin'. The game detects scripts, which being .HXC (not .HX lmfao, FNF uses Polymod's scripted classes lol), interprets them. and execute them to perform the custom stuff from them in-game.
Well, mods ain't the only thing to use this stuff, even the game itself uses scripts for playing animations & cutscenes, do some crazy shit with stage props. and even add some cool custom gameplay in such a way that allows for faster iteration. Also helps to edit the code without fucking around with the source code and having to recompile a bunch!
HScript, again, is basically like Haxe, heck even has nearly identical syntax, and provides access to almost all of the classes and variables accesible in the game, however like any other thing, it has some notes and limitations which being:
- Each scripted class must have an unique name from every other scripted class. If your mod has like two scripted classes with the same name, or even if you got two mods with scripted classes using the same name, one of them will get skipped, resulting in pretty abnormal behavior.
- Enums are not actually supported. (Vs. Freya does give abstract enums support via a macro, however.)
- You can only have one variable declaration per
var. - While the parser does support optional types for both
varandfunction, the interpreter just ignores them anyways. This meant you can simply access private variables, be careful by the way. - A handful of classes are blacklisted, y'know just to prevent malicious scripts. (DISABLED IN VS. FREYA, still tho dont make malware through here srsly why would do that???)
-- Based off on Friday Night Funkin' --
