FunkinCrew / Funkin

A rhythm game made with HaxeFlixel
https://www.newgrounds.com/portal/view/770371
Other
2.97k stars 2.29k forks source link

Bug Report: Unable to import CharacterData classes via HScript #2548

Closed Lethrial closed 5 months ago

Lethrial commented 5 months ago

Please check for duplicates or similar issues, as well performing simple troubleshooting steps (such as clearing cookies, clearing AppData, trying another browser) before submitting an issue.

If you are playing the game in a browser, what site are you playing it from?

If you are playing the game in a browser, what browser are you using?

What version of the game are you using? Look in the bottom left corner of the main menu. (ex: 0.2.7, 0.2.1, shit like that)

0.3.3

Have you identified any steps to reproduce the bug? If so, please describe them below in as much detail as possible. Use images if possible.

Write a script importing any class or enum from CharacterData (e.g. import funkin.play.character.CharacterData.CharacterDataParser;)

Please describe your issue. Provide extensive detail and images if possible.

When attempting to import a class from CharacterData using HScript, an error message pops up saying that the class doesn't exist.

image

Here's the script I've been working on for reference:

import funkin.play.PlayState;
import funkin.play.song.Song;
import funkin.play.character.BaseCharacter;
import funkin.play.stage.Stage;
import funkin.play.character.CharacterData.CharacterDataParser;

class BeachsideSong extends Song 
{
    // Characters
    var boyf:BaseCharacter;
    var girlf:BaseCharacter;

    public function new() {
        super('beachside');
    }

    override function onCreate() 
    {
        super.onCreate();

        // Loads Boyfriend, positions him and adds him to the current stage.
        boyf = CharacterDataParser.fetchCharacter('bf');
        boyf.characterType = CharacterType.DAD;
        boyf.zIndex = 150;
        boyf.flipX = false;
        boyf.x = PlayState.instance.currentStage.getBoyfriend().x - 150;
        boyf.y = PlayState.instance.currentStage.getBoyfriend().y - 50;
        PlayState.instance.currentStage.addCharacter(boyf);

        // Loads Girlfriend, positions her and adds her to the current stage.
        girlf = CharacterDataParser.fetchCharacter('chibi-gf');
        girlf.characterType = CharacterType.DAD;
        girlf.zIndex = 149;
        girlf.x = PlayState.instance.currentStage.getDad().x + 150;
        girlf.y = PlayState.instance.currentStage.getDad().y - 50;
        PlayState.instance.currentStage.addCharacter(girlf);
    }
}

If there's any workaround for loading a character without importing CharacterData then please let me know! I'd appreciate any and all help.

If you're game is FROZEN and you're playing a web version, press F12 to open up browser dev window, and go to console, and copy-paste whatever red error you're getting

gamerbross commented 5 months ago

Importing works different in HScript, with "class path", not by module. you need to import like import funkin.play.character.CharacterDataParser; not import funkin.play.character.CharacterData.CharacterDataParser;

CharacterData is the module, but it has to be skipped when importing in hscript. I hope Eric finds some kind of fix for that, would be awesome

Lethrial commented 5 months ago

Ah I see, thank you so much for the help!