Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
idk EOL update
Browse files Browse the repository at this point in the history
  • Loading branch information
nebulazorua committed Apr 14, 2024
1 parent 8c78ac3 commit 942a9f7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Conductor
public static function beatToSeconds(beat:Float){
var step = beat * 4;
var lastChange = getBPMFromStep(step);
return lastChange.songTime + ((step - lastChange.stepTime) / (lastChange.bpm / 60)/4) * 1000;//step * (lastChange.stepCrochet*4); // TODO: make less shit and take BPM into account PROPERLY
return lastChange.songTime + ((step - lastChange.stepTime) / (lastChange.bpm / 60)/4) * 1000; // TODO: make less shit and take BPM into account PROPERLY
}


Expand Down
46 changes: 46 additions & 0 deletions source/LuaClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,38 @@ class LuaReceptor extends LuaSprite {
class LuaCharacter extends LuaSprite {
private static var state:State;

private static function playAnimForTime(l:StatePointer):Int
{
// 1 = self
// 2 = anim
// 3 = time
// 4 = forced
// 5 = reversed
// 6 = frame
var anim = LuaL.checkstring(state, 2);
var time = LuaL.checknumber(state, 3);
var forced = false;
var reversed = false;
var frame:Int = 0;


if (Lua.isboolean(state, 4))
forced = Lua.toboolean(state, 4);

if (Lua.isboolean(state, 5))
reversed = Lua.toboolean(state, 5);

if (Lua.isnumber(state, 6))
frame = Std.int(Lua.tonumber(state, 6));

Lua.getfield(state, 1, "spriteName");
var spriteName = Lua.tostring(state, -1);
var sprite = PlayState.currentPState.luaSprites[spriteName];
sprite.noIdleTimer = time * 1000;
sprite.playAnim(anim, forced, reversed, frame);
return 0;
}

private static function swapCharacter(l:StatePointer){
// 1 = self
// 2 = character
Expand Down Expand Up @@ -2023,6 +2055,7 @@ class LuaCharacter extends LuaSprite {
}

private static var playAnimC:cpp.Callable<StatePointer->Int> = cpp.Callable.fromStaticFunction(playAnim);
private static var playAnimForTimeC:cpp.Callable<StatePointer->Int> = cpp.Callable.fromStaticFunction(playAnimForTime);
private static var addOffsetC:cpp.Callable<StatePointer->Int> = cpp.Callable.fromStaticFunction(addOffset);
private static var leftToRightC:cpp.Callable<StatePointer->Int> = cpp.Callable.fromStaticFunction(leftToRight);
private static var rightToLeftC:cpp.Callable<StatePointer->Int> = cpp.Callable.fromStaticFunction(rightToLeft);
Expand Down Expand Up @@ -2064,6 +2097,19 @@ class LuaCharacter extends LuaSprite {
return 0;
}
});
properties.set("playAnimForTime", {
defaultValue: 0,
getter: function(l:State, data:Any)
{
Lua.pushcfunction(l, playAnimForTimeC);
return 1;
},
setter: function(l:State)
{
LuaL.error(l, "playAnimForTime is read-only.");
return 0;
}
});
properties.set("addOffset",{
defaultValue:0,
getter:function(l:State,data:Any){
Expand Down
28 changes: 23 additions & 5 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,24 @@ class PlayState extends MusicBeatState
return Main.adjustFPS(num);
});


Lua_helper.add_callback(lua.state, "callEvent", function(name:String, args:Array<String>){
return doEvent({
name: name,
time: Conductor.songPosition,
args: args
});
});

Lua_helper.add_callback(lua.state, "callEventAtTime", function(name:String, time:Float, args:Array<String>)
{
return doEvent({
name: name,
time: time,
args: args
});
});

Lua_helper.add_callback(lua.state,"newOpponent", function(x:Float, y:Float, ?character:String = "bf", ?spriteName:String){
var char = new Character(x,y,character,false,!currentOptions.noChars);
var name = "UnnamedOpponent"+unnamedLuaSprites;
Expand Down Expand Up @@ -1156,6 +1174,9 @@ class PlayState extends MusicBeatState
}else if(currAnim=='idle' || currAnim.startsWith("dance")){
newSprite.dance();
}
if(who == 'bf' || who == 'gf' || who =='dad')
luaSprites[who] = newSprite;


return newSprite;

Expand All @@ -1168,7 +1189,6 @@ class PlayState extends MusicBeatState
var sprite = luaSprites[spriteName];
if(spriteName == 'bf' || spriteName == 'gf' || spriteName =='dad'){
var newChar = swapCharacter(spriteName,newCharacter);
luaSprites[spriteName] = newChar;
return;
}
if(sprite!=null){
Expand All @@ -1187,8 +1207,6 @@ class PlayState extends MusicBeatState
remove(sprite);
// TODO: Make this BETTER!!!
newSprite = new Character(newX,newY,newCharacter);


newSprite.x += newSprite.posOffset.x;
newSprite.y += newSprite.posOffset.y;
healthBar.setIcons(boyfriend.iconName,dad.iconName);
Expand Down Expand Up @@ -2321,7 +2339,7 @@ class PlayState extends MusicBeatState
case 'gf':
char = gf;
case 'opponent':
char=dad;
char = opponent;
}
char.noIdleTimer = args[2]*1000;
char.playAnim(args[1],true);
Expand Down Expand Up @@ -2370,7 +2388,7 @@ class PlayState extends MusicBeatState
}

if(luaModchartExists && lua!=null)
callLua("doEvent",[event.name, event.args]); // TODO: Note lua class???
callLua("doEvent",[event.name, event.args]); // breaking chnage probably but whatever whos using andromeda nowadays LOL

}

Expand Down

0 comments on commit 942a9f7

Please sign in to comment.