Skip to content

[BACKEND] New scripting backend using cppia #5087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 34 commits into
base: develop
Choose a base branch
from

Conversation

lemz1
Copy link
Contributor

@lemz1 lemz1 commented May 14, 2025

Linked Issues

Closes #5077

Description

This pr changes the scripting backend from hscript to cppia.
cppia is more performant, more type-safe than hscript, and has much better haxe language support.

Problem

It seems as if functions arguments are not passed correctly to the cppia scripts. I noticed some bizarre problems, for example TankmanBloodyCharacter.hx: event in onUpdate is null, which does not make sense.
OtisSpeakerCharacter.hx: scriptEvent in onSongEvent is of type Int with the value 1.

The above seems to rather be an issue with hxcpp, when i tried debugging it, it mentioned that it was trying to access instance fields as static. I dont know why this happens, since i do not see a pattern which leads to this happening. I'm gonna see if i can figure why this happens.

Note

A few scripts had some changes that i deemed necessary to mention, so just look in the scripts for // CPPIA:.

Todo

  • port base game scripts
  • fetch the haxe compiler using environment variable
  • make base game scripts work with cppia
  • figure out how to properly block access to blacklisted classes
  • mod support

@github-actions github-actions bot added status: pending triage Awaiting review. pr: haxe PR modifies game code. size: medium A medium pull request with 100 or fewer changes. labels May 14, 2025
@lemz1 lemz1 changed the base branch from main to develop May 14, 2025 16:15
@lemz1 lemz1 marked this pull request as draft May 14, 2025 16:16
@AbnormalPoof
Copy link
Collaborator

HOLY
image

Comment on lines +80 to +81
"ref": "d914cac17779efad8b3aa6f4a12dff566518d1b9",
"url": "https://github.com/lemz1/hscript"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary compilation fix
will be removed when we remove hscript entirely

@@ -503,7 +503,7 @@ class Project extends HXProject {
FEATURE_POLYMOD_MODS.apply(this, true);
FEATURE_FUNKVIS.apply(this, true);
FEATURE_PARTIAL_SOUNDS.apply(this, true);
FEATURE_VIDEO_PLAYBACK.apply(this, true);
FEATURE_VIDEO_PLAYBACK.apply(this, false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary change to fix compilation issues

@@ -525,7 +525,7 @@ class Project extends HXProject {

// Should be true on desktop, release, non-tester builds.
// We don't want testers to accidentally leak songs to their Discord friends!
FEATURE_DISCORD_RPC.apply(this, isDesktop() && !FEATURE_DEBUG_FUNCTIONS.isEnabled(this));
FEATURE_DISCORD_RPC.apply(this, isDesktop() && !FEATURE_DEBUG_FUNCTIONS.isEnabled(this) && false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary change to fix compilation issues

@Hundrec Hundrec added the type: enhancement Involves an enhancement or new feature. label May 14, 2025
@AbnormalPoof AbnormalPoof added the topic: mods Related to the creation or use of mods. label May 14, 2025
@EliteMasterEric EliteMasterEric added size: medium A medium pull request with 100 or fewer changes. and removed size: medium A medium pull request with 100 or fewer changes. labels May 14, 2025
@github-actions github-actions bot added size: large A large pull request with more than 100 changes. and removed size: medium A medium pull request with 100 or fewer changes. labels May 14, 2025
@github-actions github-actions bot added size: medium A medium pull request with 100 or fewer changes. size: large A large pull request with more than 100 changes. and removed size: large A large pull request with more than 100 changes. size: medium A medium pull request with 100 or fewer changes. labels May 15, 2025
@Hundrec
Copy link
Collaborator

Hundrec commented May 21, 2025

Promoted to huge!

@github-actions github-actions bot added size: large A large pull request with more than 100 changes. and removed size: huge A huge pull request with more than 500 changes. labels May 24, 2025
@github-actions github-actions bot added size: huge A huge pull request with more than 500 changes. and removed size: large A large pull request with more than 100 changes. labels May 24, 2025
@AbnormalPoof AbnormalPoof added the topic: breaking change Introduces a change that is not compatible with older versions. Existing code may need revision. label May 25, 2025
Copy link
Collaborator

@AbnormalPoof AbnormalPoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to just use the haxe installation the user already has? Copying the entire haxe repository seems a bit much, especially considering it'll be extremely difficult to maintain.

@lemz1
Copy link
Contributor Author

lemz1 commented May 25, 2025

Would it be possible to just use the haxe installation the user already has?

No, since this would require people to install haxe when they want to play friday night funkin. Also every user, should have the same haxe version, and by shipping the game with the compiler this requirement is satisfied.

Copying the entire haxe repository seems a bit much, especially considering it'll be extremely difficult to maintain.

We aren't copying the entire haxe repository, later on i will implement fetching the binaries from the releases in the haxe repository.

{
trace('Initializing Haxe compiler...');

var haxeCompilerSrc:String = Path.normalize(Sys.getEnv("HAXEPATH"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure whether it's better to use the installed haxe compiler,
or to fetch a specific version using git

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using git would be nicer, because we have a consistent haxe version and not some useless files like lime.exe, hmm.cmd, etc.

however, we'd need a constant internet connection, and it might be a bit slower than directly copying files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could always fetch from git on first compile, save it somewhere for other compiles, and update it only if the commit has been changed

@TheoDevelops
Copy link

This is impressive, ngl !
If this ends working properly this would be a huge step for FNF scripting

@AbnormalPoof AbnormalPoof added status: needs revision Cannot be approved because it is awaiting some work by the contributor. and removed status: pending triage Awaiting review. labels Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: haxe PR modifies game code. size: huge A huge pull request with more than 500 changes. status: needs revision Cannot be approved because it is awaiting some work by the contributor. topic: breaking change Introduces a change that is not compatible with older versions. Existing code may need revision. topic: mods Related to the creation or use of mods. type: enhancement Involves an enhancement or new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Replace HScript with cppia
6 participants