Skip to content

Hardcoded scripts (wip)#1033

Draft
TheZoroForce240 wants to merge 3 commits into
CodenameCrew:mainfrom
TheZoroForce240:script-testing
Draft

Hardcoded scripts (wip)#1033
TheZoroForce240 wants to merge 3 commits into
CodenameCrew:mainfrom
TheZoroForce240:script-testing

Conversation

@TheZoroForce240

Copy link
Copy Markdown
Contributor

No description provided.

@r6915ee

r6915ee commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

I'm quite curious, what would be the main use case of this? I can see this having some potential, but I'm somewhat concerned how this will work for different platforms.

@TheZoroForce240

Copy link
Copy Markdown
Contributor Author

It's mainly meant for large mods with lots of big scripts, where hscript just isn't fast enough to handle it.
You can either setup your mod to use a hybrid method where you use hscript to make/debug the script and then use a flag to auto generate source files when finished, or just do the hardcoded scripts manually, I've designed it to not be too different from using hscript and still supports things like public and static script vars.
For getting it working on other platforms, it should be as simple as forking the cne repo, edit project.xml to enable hardcoded scripts, drop the script files in the modSource folder and then run workflows. I've got wip documentation for it I'll pr to the wiki as well with how it should be used

A basic script looks something like this:

@:registerScript("songs/bopeebo/scripts/script.hx")
class Script extends HardcodedScript<PlayState> {

	var a:Int = 0;
	
	@:publicVar var testPublic:Float = 50.0;  //@:publicVar generates a get/set func to directly access the publicVariables map
	
	@:publicVarRef var testPublicFromAnotherScript:Float; //same as @:publicVar but doesn't init the variable, mainly for helping the compiler know which type it is

	public function create() {
		trace("script loaded");
	}

	override public function update(elapsed:Float) {
		parent.dad.angle += testPublic*elapsed;
	}
	
	function onNoteHit(event:NoteHitEvent) {
		trace("note hit");
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants