Skip to content
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

Allow custom FlxCameras to be used on LuaUtils.cameraFromString #14430

Closed
wants to merge 5 commits into from

Conversation

LarryFrosty
Copy link
Contributor

@LarryFrosty LarryFrosty commented Apr 6, 2024

Allow custom FlxCameras to be used so long as they are in the variables map

@DetectiveBaldi
Copy link
Contributor

I would probably move this functionality into the LuaUtils.cameraFromString function itself, firstly check the PlayState cameras, and then check the variables map

@LarryFrosty
Copy link
Contributor Author

LarryFrosty commented Apr 6, 2024

I would probably move this functionality into the LuaUtils.cameraFromString function itself, firstly check the PlayState cameras, and then check the variables map

Something like this?

public static function cameraFromString(cam:String):FlxCamera {
    switch(cam.toLowerCase()) {
        case 'camgame' | 'game': return PlayState.instance.camGame;
        case 'camhud' | 'hud': return PlayState.instance.camHUD;
        case 'camother' | 'other': return PlayState.instance.camOther;
    }
    var camera:Dynamic = PlayState.instance.variables.get(cam);
    if (camera == null || !Std.isOfType(camera, FlxCamera)) camera = PlayState.instance.camGame;
    return camera;
}

@DetectiveBaldi
Copy link
Contributor

I would probably move this functionality into the LuaUtils.cameraFromString function itself, firstly check the PlayState cameras, and then check the variables map

Something like this?

public static function cameraFromString(cam:String):FlxCamera {
    switch(cam.toLowerCase()) {
        case 'camgame' | 'game': return PlayState.instance.camGame;
        case 'camhud' | 'hud': return PlayState.instance.camHUD;
        case 'camother' | 'other': return PlayState.instance.camOther;
    }
    var camera:Dynamic = PlayState.instance.variables.get(cam);
    if (camera == null || !Std.isOfType(camera, FlxCamera)) camera = PlayState.instance.camGame;
    return camera;
}

yea, looks good

@LarryFrosty LarryFrosty changed the title Allow custom FlxCameras to be used on setObjectCamera Allow custom FlxCameras to be used on LuaUtils.cameraFromString Apr 6, 2024
@LarryFrosty
Copy link
Contributor Author

#15088

@LarryFrosty LarryFrosty deleted the tree-branch branch July 12, 2024 13:17
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.

3 participants