-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yes custom states, video functions, camera functions,
- Loading branch information
1 parent
c436352
commit f22862a
Showing
22 changed files
with
1,467 additions
and
761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package psychlua; | ||
|
||
class CameraFunctions | ||
{ | ||
public static function implement(funk:FunkinLua) | ||
{ | ||
var lua = funk.lua; | ||
Lua_helper.add_callback(lua, "makeLuaCamera", function(tag:String, ?x:Float, ?y:Float, ?width:Int, ?height:Int, ?zoom:Float) { | ||
tag = tag.replace('.', ''); | ||
LuaUtils.resetTag(tag, psychlua.ScriptHandler.modchartCameras); | ||
var newCam:FlxCamera = new FlxCamera(x, y, width, height, zoom); | ||
newCam.bgColor.alpha = 0; | ||
psychlua.ScriptHandler.modchartCameras.set(tag, newCam); | ||
}); | ||
|
||
|
||
Lua_helper.add_callback(lua, "addLuaCamera", function(tag:String, defaultDraw:Bool = false) { | ||
if(psychlua.ScriptHandler.modchartCameras.exists(tag)) { | ||
var shit:FlxCamera = psychlua.ScriptHandler.modchartCameras.get(tag); | ||
FlxG.cameras.add(shit, defaultDraw); | ||
} | ||
}); | ||
Lua_helper.add_callback(lua, "removeLuaCamera", function(tag:String, destroy:Bool = true) { | ||
if(!psychlua.ScriptHandler.modchartCameras.exists(tag)) { | ||
return; | ||
} | ||
|
||
var pee:FlxCamera = psychlua.ScriptHandler.modchartCameras.get(tag); | ||
if(destroy) pee.kill(); | ||
|
||
FlxG.cameras.remove(pee, false); | ||
if(destroy) { | ||
pee.destroy(); | ||
psychlua.ScriptHandler.modchartCameras.remove(tag); | ||
} | ||
}); | ||
|
||
Lua_helper.add_callback(lua, "getCameraOrder", function(camera:String) { | ||
var cam:FlxCamera = LuaUtils.cameraFromString(camera); | ||
if(cam != null) return FlxG.cameras.list.indexOf(cam); | ||
FunkinLua.luaTrace("getCameraOrder: Default camera doesn't exist!", false, false, FlxColor.RED); | ||
return -1; | ||
}); | ||
Lua_helper.add_callback(lua, "setCameraOrder", function(camera:String, position:Int) { | ||
var cam:FlxCamera = LuaUtils.cameraFromString(camera); | ||
if(cam != null) { | ||
if(FlxG.cameras.list.contains(cam)){ | ||
var list:Array<FlxCamera> = FlxG.cameras.list.copy(); | ||
var defaults:Array<FlxCamera> = @:privateAccess FlxG.cameras.defaults.copy(); | ||
|
||
for(flxCam in list) FlxG.cameras.remove(flxCam, false); | ||
|
||
list.remove(cam); | ||
list.insert(position, cam); | ||
|
||
for(flxCam in list){ | ||
var defaultDraw = defaults.contains(flxCam); | ||
FlxG.cameras.add(flxCam, defaultDraw); | ||
} | ||
|
||
return; | ||
}else{ | ||
FunkinLua.luaTrace('setCameraOrder: Camera $camera isn\'t in the list yet! Use "addLuaCamera($camera)" first', false, false, FlxColor.RED); | ||
} | ||
} | ||
FunkinLua.luaTrace("setCameraOrder: Default camera doesn't exist!", false, false, FlxColor.RED); | ||
}); | ||
|
||
Lua_helper.add_callback(lua, "cameraShake", function(camera:String, ?intensity:Float, ?duration:Float) { | ||
LuaUtils.cameraFromString(camera).shake(intensity, duration); | ||
}); | ||
Lua_helper.add_callback(lua, "cameraFlash", function(camera:String, ?color:String, ?duration:Float, ?forced:Bool) { | ||
LuaUtils.cameraFromString(camera).flash(CoolUtil.colorFromString(color), duration, null, forced); | ||
}); | ||
Lua_helper.add_callback(lua, "cameraFade", function(camera:String, ?color:String, ?duration:Float, ?fadeIn:Bool, ?forced:Bool) { | ||
LuaUtils.cameraFromString(camera).fade(CoolUtil.colorFromString(color), duration, fadeIn, null, forced); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package psychlua; | ||
|
||
import flixel.FlxObject; | ||
import flixel.FlxState; | ||
import flixel.addons.transition.FlxTransitionableState; | ||
|
||
final packageMap:Map<String, String> = [ | ||
'CustomState' => 'psychlua.', | ||
|
||
'FlashingState' => 'states.', | ||
'TitleState' => 'states.', | ||
'OutdatedState' => 'states.', | ||
'MainMenuState' => 'states.', | ||
'StoryMenuState' => 'states.', | ||
'PlayState' => 'states.', | ||
'FreeplayState' => 'states.', | ||
'ModsMenuState' => 'states.', | ||
'CreditsState' => 'states.', | ||
'AchievementsMenuState' => 'states.', | ||
|
||
'OptionsState' => 'options.', | ||
'NoteOffsetState' => 'options.', | ||
|
||
'CharacterEditorState' => 'states.editors.', | ||
'ChartingState' => 'states.editors.', | ||
'DialogueCharacterEditorState' => 'states.editors.', | ||
'MasterEditorMenu' => 'states.editors.', | ||
'MenuCharacterEditorState' => 'states.editors.', | ||
'NoteSplashDebugState' => 'states.editors.', | ||
'WeekEditorState' => 'states.editors.' | ||
]; | ||
|
||
class CustomState extends MusicBeatState | ||
{ | ||
public static var name:String = 'unnamed'; | ||
public static var newName:Bool = false; | ||
public static var instance:CustomState; | ||
|
||
#if LUA_ALLOWED | ||
public static function implement(funk:FunkinLua) | ||
{ | ||
var lua:State = funk.lua; | ||
Lua_helper.add_callback(lua, "switchState", function(name:String, ?args:Array<Dynamic> = null, ?load:Bool = false, ?stopMusic:Bool = false) { | ||
if (args == null) args = []; | ||
if (!name.contains('.') && packageMap.get(name) != null) | ||
name = packageMap.get(name) + name; | ||
|
||
var state:FlxState = Type.createInstance(Type.resolveClass(name), args); | ||
|
||
if(state != null) { | ||
if(load) { | ||
LoadingState.loadAndSwitchState(() -> state, stopMusic); | ||
} else { | ||
if (stopMusic) FlxG.sound.music.stop(); | ||
FlxG.switchState(() -> state); | ||
} | ||
} else { | ||
FunkinLua.luaTrace('switchState: State "$name" doesn\'t exist!', false, false, FlxColor.RED); | ||
} | ||
}); | ||
Lua_helper.add_callback(lua, "setSkipTransition", function(skipIn:Null<Bool>, skipOut:Null<Bool>) { | ||
if(skipIn != null) FlxTransitionableState.skipNextTransIn = skipIn; | ||
if(skipOut != null) FlxTransitionableState.skipNextTransOut = skipOut; | ||
}); | ||
Lua_helper.add_callback(lua, "resetState", function() { | ||
FlxG.resetState(); | ||
}); | ||
Lua_helper.add_callback(lua, "clearStoredMemory", function() { | ||
Paths.clearStoredMemory(); | ||
}); | ||
Lua_helper.add_callback(lua, "clearStoredMemory", function() { | ||
Paths.clearStoredMemory(); | ||
}); | ||
Lua_helper.add_callback(lua, "clearUnusedMemory", function() { | ||
Paths.clearUnusedMemory(); | ||
}); | ||
} | ||
#end | ||
|
||
override function create() | ||
{ | ||
instance = this; | ||
newName = false; | ||
|
||
persistentUpdate = persistentDraw = true; | ||
initPsychCamera(); | ||
|
||
psychlua.ScriptHandler.startScripts(); | ||
#if LUA_ALLOWED psychlua.ScriptHandler.startLuasNamed('states/$name.lua'); #end | ||
#if HSCRIPT_ALLOWED psychlua.ScriptHandler.startLuasNamed('states/$name.hx'); #end | ||
|
||
super.create(); | ||
psychlua.ScriptHandler.callOnScripts('onCreatePost'); | ||
} | ||
|
||
public function new(name:String) | ||
{ | ||
CustomState.name = name; | ||
newName = true; | ||
super(); | ||
} | ||
|
||
override function update(elapsed:Float) | ||
{ | ||
psychlua.ScriptHandler.callOnScripts('onUpdate', [elapsed]); | ||
super.update(elapsed); | ||
psychlua.ScriptHandler.callOnScripts('onUpdatePost', [elapsed]); | ||
} | ||
|
||
override function destroy() | ||
{ | ||
psychlua.ScriptHandler.destroyScripts(); | ||
if(!newName) name = 'unnamed'; | ||
|
||
super.destroy(); | ||
} | ||
} |
Oops, something went wrong.