From 28cc2a96d280b6833ca691116eec091fff3b7f86 Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 6 May 2021 18:12:58 -0700 Subject: [PATCH] fuck you --- assets/preload/data/milf/modchart.lua | 17 ++++++++ source/ModchartState.hx | 59 ++++++++++++++++++++++++++- source/PlayState.hx | 2 +- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 assets/preload/data/milf/modchart.lua diff --git a/assets/preload/data/milf/modchart.lua b/assets/preload/data/milf/modchart.lua new file mode 100644 index 0000000..c0fd944 --- /dev/null +++ b/assets/preload/data/milf/modchart.lua @@ -0,0 +1,17 @@ +function start (song) + print("Song: " .. song .. " @ " .. bpm .. " donwscroll: " .. downscroll) +end + +function update (elapsed) -- modified example https://twitter.com/KadeDeveloper/status/1382178179184422918 + print(fuckyou[1]) +end + +function beatHit (beat) + +end + +function stepHit (step) + +end + +print("Mod Chart script loaded :)") \ No newline at end of file diff --git a/source/ModchartState.hx b/source/ModchartState.hx index d3b8e53..4e4b9c2 100644 --- a/source/ModchartState.hx +++ b/source/ModchartState.hx @@ -56,6 +56,52 @@ class ModchartState } + static function toLua(l:State, val:Any):Bool { + switch (Type.typeof(val)) { + case Type.ValueType.TNull: + Lua.pushnil(l); + case Type.ValueType.TBool: + Lua.pushboolean(l, val); + case Type.ValueType.TInt: + Lua.pushinteger(l, cast(val, Int)); + case Type.ValueType.TFloat: + Lua.pushnumber(l, val); + case Type.ValueType.TClass(String): + Lua.pushstring(l, cast(val, String)); + case Type.ValueType.TClass(Array): + Convert.arrayToLua(l, val); + case Type.ValueType.TObject: + objectToLua(l, val); + default: + trace("haxe value not supported - " + val + " which is a type of " + Type.typeof(val)); + return false; + } + + return true; + + } + + static function objectToLua(l:State, res:Any) { + + var FUCK = 0; + for(n in Reflect.fields(res)) + { + trace(Type.typeof(n).getName()); + FUCK++; + } + + Lua.createtable(l, FUCK, 0); // TODONE: I did it + + for (n in Reflect.fields(res)){ + if (!Reflect.isObject(n)) + continue; + Lua.pushstring(l, n); + toLua(l, Reflect.field(res, n)); + Lua.settable(l, -3); + } + + } + function getType(l, type):Any { return switch Lua.type(l,type) { @@ -179,6 +225,11 @@ class ModchartState return luaSprites.get(id); } + function getPropertyByName(id:String) + { + return Reflect.field(PlayState.instance,id); + } + public static var luaSprites:Map = []; @@ -195,9 +246,7 @@ class ModchartState // Cap the scale at x1 if (scale > 1) - { scale = 1; - } sprite.makeGraphic(Std.int(data.width * scale),Std.int(data.width * scale),FlxColor.TRANSPARENT); @@ -301,6 +350,8 @@ class ModchartState trace(Lua_helper.add_callback(lua,"makeSprite", makeLuaSprite)); + trace(Lua_helper.add_callback(lua,"getProperty", getPropertyByName)); + Lua_helper.add_callback(lua,"destroySprite", function(id:String) { var sprite = luaSprites.get(id); if (sprite == null) @@ -639,6 +690,10 @@ class ModchartState FlxG.camera.setFilters([new ShaderFilter(shaders[shaderIndex])]); });*/ + + objectToLua(lua,PlayState.instance.camHUD); + Lua.setglobal(lua,"fuckyou"); + // default strums for (i in 0...PlayState.strumLineNotes.length) { diff --git a/source/PlayState.hx b/source/PlayState.hx index df66df9..5221daf 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -151,7 +151,7 @@ class PlayState extends MusicBeatState var notesHitArray:Array = []; var currentFrames:Int = 0; - var dialogue:Array = ['dad:blah blah blah', 'bf:coolswag']; + public var dialogue:Array = ['dad:blah blah blah', 'bf:coolswag']; var halloweenBG:FlxSprite; var isHalloween:Bool = false;