Skip to content
This repository was archived by the owner on Oct 18, 2025. It is now read-only.

Commit c6d7b3a

Browse files
get/set object order
1 parent 9cc1076 commit c6d7b3a

File tree

11 files changed

+356
-276
lines changed

11 files changed

+356
-276
lines changed

source/funkin/visuals/game/Note.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class Note extends FlxSprite
3737

3838
public var ignorable:Bool = false;
3939

40+
public var character:Character;
41+
4042
public var ableToHit(get, never):Bool;
4143
function get_ableToHit():Bool
4244
return state == NEUTRAL && Math.abs(strumTime - Conductor.songPosition) < 175;

source/funkin/visuals/game/StrumLine.hx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class StrumLine extends FlxGroup
8282
continue;
8383

8484
var note:Note = new Note(chartNote[0], chartNote[1], chartNote[2], chartNote[3], character.type, NORMAL);
85+
note.character = character;
8586

8687
var length:Float = chartNote[2];
8788

@@ -99,6 +100,7 @@ class StrumLine extends FlxGroup
99100
for (i in 0...susLoop)
100101
{
101102
var sustain:Note = new Note(chartNote[0] + Conductor.stepCrochet * i, chartNote[1], chartNote[2], chartNote[3], character.type, i == susLoop - 1 ? SUSTAIN_END : SUSTAIN);
103+
sustain.character = character;
102104

103105
unspawnNotes.push(sustain);
104106

@@ -277,17 +279,22 @@ class StrumLine extends FlxGroup
277279

278280
public function onNoteMiss(note:Note)
279281
{
282+
if (noteMissCallback != null)
283+
noteMissCallback(note);
284+
280285
for (sound in voices)
281286
if (sound.volume != 0)
282287
sound.volume = 0;
283288

284289
note.state = LOST;
285290

286291
if (note.ignorable || note.noteType != NORMAL)
287-
return;
292+
{
293+
if (postNoteMissCallback != null)
294+
postNoteMissCallback(note);
288295

289-
if (noteMissCallback != null)
290-
noteMissCallback(note);
296+
return;
297+
}
291298

292299
character.idleTimer = 0;
293300

@@ -306,18 +313,21 @@ class StrumLine extends FlxGroup
306313
}) + 'miss',
307314
true
308315
);
316+
317+
if (postNoteMissCallback != null)
318+
postNoteMissCallback(note);
309319
}
310320

311321
public function onNoteHit(note:Note, ?rating:Rating)
312322
{
323+
if (noteHitCallback != null)
324+
noteHitCallback(note, rating);
325+
313326
note.state = HIT;
314327

315328
for (child in note.children)
316329
child.state = HELD;
317330

318-
if (noteHitCallback != null)
319-
noteHitCallback(note, rating);
320-
321331
removeNote(note);
322332

323333
strums.members[note.data].animation.play('hit', true);
@@ -347,6 +357,9 @@ class StrumLine extends FlxGroup
347357
for (sound in voices)
348358
if (sound.volume != 1)
349359
sound.volume = 1;
360+
361+
if (postNoteHitCallback != null)
362+
postNoteHitCallback(note, rating);
350363
}
351364

352365
public function addNote(note:Note)

source/scripting/haxe/HScript.hx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import flixel.system.macros.FlxMacroUtil;
1616
import core.enums.ScriptType;
1717

1818
import flixel.ui.FlxButton;
19+
import flixel.FlxObject;
1920

2021
@:access(core.backend.ScriptState)
2122
@:access(core.backend.ScriptSubState)
@@ -97,7 +98,27 @@ class HScript extends SScript
9798
'insert' => FlxG.state.insert,
9899
'openSubState' => FlxG.state.openSubState,
99100
'CancelSuperFunction' => ScriptState.instance.CancelSuperFunction,
100-
'debugPrint' => ScriptState.instance.debugPrint
101+
'debugPrint' => ScriptState.instance.debugPrint,
102+
'getObjectOrder' => function(obj:FlxObject)
103+
{
104+
if (type == STATE)
105+
ScriptState.instance.members.indexOf(obj);
106+
else
107+
ScriptSubState.instance.members.indexOf(obj);
108+
109+
return null;
110+
},
111+
'setObjectOrder' => function(obj:FlxObject, index:Int)
112+
{
113+
if (type == STATE)
114+
{
115+
ScriptState.instance.remove(obj);
116+
ScriptState.instance.insert(index, obj);
117+
} else {
118+
ScriptSubState.instance.remove(obj);
119+
ScriptSubState.instance.insert(index, obj);
120+
}
121+
}
101122
];
102123
} else if (type == SUBSTATE) {
103124
instanceVariables = [

source/scripting/lua/LuaCallbackHandler.hx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class LuaCallbackHandler
2929
{
3030
for (script in ScriptState.instance.luaScripts)
3131
{
32-
trace(script);
33-
3432
if (script != LuaScript.lastCalledScript && script != null && script.lua == lua)
3533
{
3634
callFunc = script.callbacks.get(functionName);

source/scripting/lua/LuaCoolUtil.hx

Lines changed: 15 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
package scripting.lua;
22

3-
import funkin.visuals.shaders.ALERuntimeShader;
4-
5-
import scripting.lua.flixel.LuaCamera;
3+
import core.enums.PrintType;
64

75
class LuaCoolUtil extends LuaPresetBase
86
{
97
override public function new(lua:LuaScript)
108
{
119
super(lua);
1210

11+
set('debugPrint', CoolUtil.debugPrint);
12+
13+
set('debugTrace', CoolUtil.debugTrace);
14+
15+
set('switchState', function(fullClassPath:String, params:Array<Dynamic>)
16+
{
17+
CoolUtil.switchState(Type.createInstance(Type.resolveClass(fullClassPath), params));
18+
});
19+
20+
set('switchToCustomState', function(name:String)
21+
{
22+
CoolUtil.switchState(() -> new CustomState(name));
23+
});
24+
1325
set('capitalize', CoolUtil.capitalize);
1426

1527
set('floorDecimal', CoolUtil.floorDecimal);
@@ -47,128 +59,6 @@ class LuaCoolUtil extends LuaPresetBase
4759

4860
set('adjustColorBrightness', CoolUtil.adjustColorBrightness);
4961

50-
set('createRuntimeShader', function(tag:String, file:String)
51-
{
52-
if (CoolUtil.createRuntimeShader(file) != null)
53-
setTag(tag, CoolUtil.createRuntimeShader(file));
54-
}
55-
);
56-
57-
set('setCameraShaders', function(camera:String, shaderTags:Array<String>)
58-
{
59-
var procShaders:Array<ALERuntimeShader> = [];
60-
61-
for (tag in shaderTags)
62-
if (tagIs(tag, ALERuntimeShader))
63-
procShaders.push(getTag(tag));
64-
65-
CoolUtil.setCameraShaders(LuaCamera.cameraFromString(lua, camera), procShaders);
66-
}
67-
);
68-
69-
set('setShaderInt', function(tag:String, id:String, int:Int)
70-
{
71-
if (tagIs(tag, ALERuntimeShader))
72-
getTag(tag).setInt(id, int);
73-
}
74-
);
75-
76-
set('getShaderInt', function(tag:String, id:String):Null<Int>
77-
{
78-
if (tagIs(tag, ALERuntimeShader))
79-
return getTag(tag).getInt(id);
80-
81-
return null;
82-
}
83-
);
84-
85-
set('setShaderIntArray', function(tag:String, id:String, ints:Array<Int>)
86-
{
87-
if (tagIs(tag, ALERuntimeShader))
88-
getTag(tag).setIntArray(id, ints);
89-
}
90-
);
91-
92-
set('getShaderIntArray', function(tag:String, id:String):Null<Array<Int>>
93-
{
94-
if (tagIs(tag, ALERuntimeShader))
95-
return getTag(tag).getIntArray(id);
96-
97-
return null;
98-
}
99-
);
100-
101-
set('setShaderFloat', function(tag:String, id:String, float:Float)
102-
{
103-
if (tagIs(tag, ALERuntimeShader))
104-
getTag(tag).setFloat(id, float);
105-
}
106-
);
107-
108-
set('getShaderFloat', function(tag:String, id:String):Null<Float>
109-
{
110-
if (tagIs(tag, ALERuntimeShader))
111-
return getTag(tag).getFloat(id);
112-
113-
return null;
114-
}
115-
);
116-
117-
set('setShaderFloatArray', function(tag:String, id:String, floats:Array<Float>)
118-
{
119-
if (tagIs(tag, ALERuntimeShader))
120-
getTag(tag).setFloatArray(id, floats);
121-
}
122-
);
123-
124-
set('getShaderFloatArray', function(tag:String, id:String):Null<Array<Float>>
125-
{
126-
if (tagIs(tag, ALERuntimeShader))
127-
return getTag(tag).getFloatArray(id);
128-
129-
return null;
130-
}
131-
);
132-
133-
set('setShaderBool', function(tag:String, id:String, bool:Bool)
134-
{
135-
if (tagIs(tag, ALERuntimeShader))
136-
getTag(tag).setBool(id, bool);
137-
}
138-
);
139-
140-
set('getShaderBool', function(tag:String, id:String):Null<Bool>
141-
{
142-
if (tagIs(tag, ALERuntimeShader))
143-
return getTag(tag).getBool(id);
144-
145-
return null;
146-
}
147-
);
148-
149-
set('setShaderBoolArray', function(tag:String, id:String, bools:Array<Bool>)
150-
{
151-
if (tagIs(tag, ALERuntimeShader))
152-
getTag(tag).setBoolArray(id, bools);
153-
}
154-
);
155-
156-
set('getShaderBoolArray', function(tag:String, id:String):Null<Array<Bool>>
157-
{
158-
if (tagIs(tag, ALERuntimeShader))
159-
return getTag(tag).getBoolArray(id);
160-
161-
return null;
162-
}
163-
);
164-
165-
set('setSpriteShader', function(spriteTag:String, shaderTag:String)
166-
{
167-
if (tagIs(spriteTag, FlxSprite) && tagIs(shaderTag, ALERuntimeShader))
168-
getTag(spriteTag).shader = getTag(shaderTag);
169-
}
170-
);
171-
17262
set('getGameSize', function(type:String)
17363
{
17464
return switch (type.toLowerCase().trim())

0 commit comments

Comments
 (0)