diff --git a/docs/modchart.md b/docs/modchart.md index 5bf68a5..40c7b14 100644 --- a/docs/modchart.md +++ b/docs/modchart.md @@ -32,6 +32,10 @@ function stepHit (step) -- do nothing end +function keyPressed (key) + -- do nothing +end + print("Mod Chart script loaded :)") ``` @@ -116,6 +120,7 @@ Current calls to functions include, | update | Elapsed frames | Gets called every frame (after the song starts) | | stepHit | Current Step | Gets called when ever a step hits (steps are in between beats, aka 4 steps are in a beat) | | beatHit | Current Beat | Gets called when ever a beat hits | +| keyPressed | Key Pressed | Gets called when a key just got pressed (up, down, left, right, accept) | @@ -435,6 +440,13 @@ Smoothly fade in to an alpha Smoothly fade out to an alpha +##### changeBoyfriendCharacter(string id) + +Changes the Boyfriend sprite to another character + +##### changeDadCharacter(string id) + +Changes the Dad sprite to another character diff --git a/source/ModchartState.hx b/source/ModchartState.hx index 62fdeb7..7c8df78 100644 --- a/source/ModchartState.hx +++ b/source/ModchartState.hx @@ -232,7 +232,23 @@ class ModchartState public static var luaSprites:Map = []; + function changeDadCharacter(id:String) + { var olddadx = PlayState.dad.x; + var olddady = PlayState.dad.y; + PlayState.instance.removeObject(PlayState.dad); + PlayState.dad = new Character(olddadx, olddady, id); + PlayState.instance.addObject(PlayState.dad); + PlayState.instance.iconP2.animation.play(id); + } + function changeBoyfriendCharacter(id:String) + { var oldboyfriendx = PlayState.boyfriend.x; + var oldboyfriendy = PlayState.boyfriend.y; + PlayState.instance.removeObject(PlayState.boyfriend); + PlayState.boyfriend = new Boyfriend(oldboyfriendx, oldboyfriendy, id); + PlayState.instance.addObject(PlayState.boyfriend); + PlayState.instance.iconP2.animation.play(id); + } function makeLuaSprite(spritePath:String,toBeCalled:String, drawBehind:Bool) { @@ -349,6 +365,10 @@ class ModchartState // sprites Lua_helper.add_callback(lua,"makeSprite", makeLuaSprite); + + Lua_helper.add_callback(lua,"changeDadCharacter", changeDadCharacter); + + Lua_helper.add_callback(lua,"changeBoyfriendCharacter", changeBoyfriendCharacter); Lua_helper.add_callback(lua,"getProperty", getPropertyByName); @@ -365,6 +385,10 @@ class ModchartState Lua_helper.add_callback(lua,"setHudAngle", function (x:Float) { PlayState.instance.camHUD.angle = x; }); + + Lua_helper.add_callback(lua,"setHealth", function (heal:Float) { + PlayState.instance.health = heal; + }); Lua_helper.add_callback(lua,"setHudPosition", function (x:Int, y:Int) { PlayState.instance.camHUD.x = x; diff --git a/source/PlayState.hx b/source/PlayState.hx index 8b8f567..ecf029c 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -143,8 +143,8 @@ class PlayState extends MusicBeatState private var generatedMusic:Bool = false; private var startingSong:Bool = false; - private var iconP1:HealthIcon; - private var iconP2:HealthIcon; + public var iconP1:HealthIcon; //making these public for modcharts cause i dont know how else to do it + public var iconP2:HealthIcon; //what could go wrong? public var camHUD:FlxCamera; private var camGame:FlxCamera; @@ -1833,7 +1833,6 @@ class PlayState extends MusicBeatState if (health > 2) health = 2; - if (healthBar.percent < 20) iconP1.animation.curAnim.curFrame = 1; else @@ -2826,6 +2825,14 @@ class PlayState extends MusicBeatState controls.UP_R, controls.RIGHT_R ]; + #if windows + if (luaModchart != null){ + if (controls.LEFT_P){luaModchart.executeState('keyPressed',["left"]);}; + if (controls.DOWN_P){luaModchart.executeState('keyPressed',["down"]);}; + if (controls.UP_P){luaModchart.executeState('keyPressed',["up"]);}; + if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);}; + }; + #end // Prevent player input if botplay is on if(FlxG.save.data.botplay)