From cc23e4c24f6ac3900175565c716a0ec63aa22d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sat, 3 Feb 2024 03:37:48 +0100 Subject: [PATCH] bye onDestroy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from lunar suggestion since it was confusing as fuckkk😭 --- pages/funkin/backend/scripting/DummyScript.html | 2 +- pages/funkin/backend/scripting/Script.html | 2 +- source/funkin/backend/MusicBeatState.hx | 2 +- source/funkin/backend/MusicBeatSubstate.hx | 2 +- source/funkin/backend/scripting/GlobalScript.hx | 2 +- source/funkin/backend/scripting/HScript.hx | 4 ---- source/funkin/backend/scripting/MultiThreadedScript.hx | 2 +- source/funkin/backend/scripting/Script.hx | 7 ------- source/funkin/backend/scripting/ScriptPack.hx | 3 ++- source/funkin/game/GameOverSubstate.hx | 2 +- source/funkin/menus/PauseSubState.hx | 2 +- 11 files changed, 10 insertions(+), 20 deletions(-) diff --git a/pages/funkin/backend/scripting/DummyScript.html b/pages/funkin/backend/scripting/DummyScript.html index d7eba55f..1dcf9cc0 100644 --- a/pages/funkin/backend/scripting/DummyScript.html +++ b/pages/funkin/backend/scripting/DummyScript.html @@ -7,5 +7,5 @@ float: none; text-shadow: 0 0 0 transparent; } -

Simple class for empty scripts or scripts whose language isn't imported yet.

Constructor

new(path:String)

Variables

@:value([])variables:Map<String, Dynamic> = []

Methods

Inherited Variables

Defined by Script

fileName:String

Script name (with extension)

@:value(null)path:String = null

Path to the script.

Inherited Methods

Defined by Script

call(func:String, ?parameters:Array<Dynamic>):Dynamic

Calls the function func defined in the script.

Parameters:

func

Name of the function

parameters

(Optional) Parameters of the function.

Returns:

Result (if void, then null)

error(text:String, ?additionalInfo:Dynamic):Void

Shows an error from this script.

Parameters:

text

Text of the error (ex: Null Object Reference).

additionalInfo

Additional information you could provide.

load():Void

Loads the script

onCreate(path:String):Void

onDestroy():Void

onLoad():Void

reload():Void

Hot-reloads the script, if possible

setParent(variable:Dynamic):Void

Sets a script's parent object so that its properties can be accessed easily. Ex: Passing PlayState.instance will allow boyfriend to be typed instead of PlayState.instance.boyfriend.

Parameters:

variable

Parent variable.

setPublicMap(map:Map<String, Dynamic>):Void

HSCRIPT ONLY FOR NOW +

Simple class for empty scripts or scripts whose language isn't imported yet.

Constructor

new(path:String)

Variables

@:value([])variables:Map<String, Dynamic> = []

Methods

Inherited Variables

Defined by Script

fileName:String

Script name (with extension)

@:value(null)path:String = null

Path to the script.

Inherited Methods

Defined by Script

call(func:String, ?parameters:Array<Dynamic>):Dynamic

Calls the function func defined in the script.

Parameters:

func

Name of the function

parameters

(Optional) Parameters of the function.

Returns:

Result (if void, then null)

error(text:String, ?additionalInfo:Dynamic):Void

Shows an error from this script.

Parameters:

text

Text of the error (ex: Null Object Reference).

additionalInfo

Additional information you could provide.

load():Void

Loads the script

onCreate(path:String):Void

destroy():Void

onLoad():Void

reload():Void

Hot-reloads the script, if possible

setParent(variable:Dynamic):Void

Sets a script's parent object so that its properties can be accessed easily. Ex: Passing PlayState.instance will allow boyfriend to be typed instead of PlayState.instance.boyfriend.

Parameters:

variable

Parent variable.

setPublicMap(map:Map<String, Dynamic>):Void

HSCRIPT ONLY FOR NOW Sets the "public" variables map for ScriptPack

trace(v:Dynamic):Void

Traces something as this script.

\ No newline at end of file diff --git a/pages/funkin/backend/scripting/Script.html b/pages/funkin/backend/scripting/Script.html index b88b973f..a353203f 100644 --- a/pages/funkin/backend/scripting/Script.html +++ b/pages/funkin/backend/scripting/Script.html @@ -8,5 +8,5 @@ text-shadow: 0 0 0 transparent; }

Static variables

@:value(null)staticcurScript:Script = null

Currently executing script.

@:value(["hx", "hscript", "hsc", "hxs", "lua"])staticscriptExtensions:Array<String> = ["hx", "hscript", "hsc", "hxs", "lua"]

All available script extensions

@:value([])staticstaticVariables:Map<String, Dynamic> = []

Use "static var thing = true;" in hscript to use those!! -are reset every mod switch so once you're done with them make sure to make them null!!

Static methods

staticcreate(path:String):Script

Creates a script from the specified asset path. The language is automatically determined.

Parameters:

path

Path in assets

staticgetDefaultPreprocessors():Map<String, Dynamic>

staticgetDefaultVariables(?script:Script):Map<String, Dynamic>

Constructor

new(path:String)

Creates a new instance of the script class.

Parameters:

null

path

Variables

fileName:String

Script name (with extension)

@:value(null)path:String = null

Path to the script.

Methods

call(func:String, ?parameters:Array<Dynamic>):Dynamic

Calls the function func defined in the script.

Parameters:

func

Name of the function

parameters

(Optional) Parameters of the function.

Returns:

Result (if void, then null)

error(text:String, ?additionalInfo:Dynamic):Void

Shows an error from this script.

Parameters:

text

Text of the error (ex: Null Object Reference).

additionalInfo

Additional information you could provide.

get(variable:String):Dynamic

Gets the variable variable from the script's variables.

Parameters:

variable

Name of the variable.

Returns:

Variable (or null if it doesn't exists)

load():Void

Loads the script

onCreate(path:String):Void

onDestroy():Void

onLoad():Void

reload():Void

Hot-reloads the script, if possible

set(variable:String, value:Dynamic):Void

Gets the variable variable from the script's variables.

Parameters:

variable

Name of the variable.

Returns:

Variable (or null if it doesn't exists)

setParent(variable:Dynamic):Void

Sets a script's parent object so that its properties can be accessed easily. Ex: Passing PlayState.instance will allow boyfriend to be typed instead of PlayState.instance.boyfriend.

Parameters:

variable

Parent variable.

setPublicMap(map:Map<String, Dynamic>):Void

HSCRIPT ONLY FOR NOW +are reset every mod switch so once you're done with them make sure to make them null!!

Static methods

staticcreate(path:String):Script

Creates a script from the specified asset path. The language is automatically determined.

Parameters:

path

Path in assets

staticgetDefaultPreprocessors():Map<String, Dynamic>

staticgetDefaultVariables(?script:Script):Map<String, Dynamic>

Constructor

new(path:String)

Creates a new instance of the script class.

Parameters:

null

path

Variables

fileName:String

Script name (with extension)

@:value(null)path:String = null

Path to the script.

Methods

call(func:String, ?parameters:Array<Dynamic>):Dynamic

Calls the function func defined in the script.

Parameters:

func

Name of the function

parameters

(Optional) Parameters of the function.

Returns:

Result (if void, then null)

error(text:String, ?additionalInfo:Dynamic):Void

Shows an error from this script.

Parameters:

text

Text of the error (ex: Null Object Reference).

additionalInfo

Additional information you could provide.

get(variable:String):Dynamic

Gets the variable variable from the script's variables.

Parameters:

variable

Name of the variable.

Returns:

Variable (or null if it doesn't exists)

load():Void

Loads the script

onCreate(path:String):Void

destroy():Void

onLoad():Void

reload():Void

Hot-reloads the script, if possible

set(variable:String, value:Dynamic):Void

Gets the variable variable from the script's variables.

Parameters:

variable

Name of the variable.

Returns:

Variable (or null if it doesn't exists)

setParent(variable:Dynamic):Void

Sets a script's parent object so that its properties can be accessed easily. Ex: Passing PlayState.instance will allow boyfriend to be typed instead of PlayState.instance.boyfriend.

Parameters:

variable

Parent variable.

setPublicMap(map:Map<String, Dynamic>):Void

HSCRIPT ONLY FOR NOW Sets the "public" variables map for ScriptPack

trace(v:Dynamic):Void

Traces something as this script.

\ No newline at end of file diff --git a/source/funkin/backend/MusicBeatState.hx b/source/funkin/backend/MusicBeatState.hx index 1b5499de..ce37405e 100644 --- a/source/funkin/backend/MusicBeatState.hx +++ b/source/funkin/backend/MusicBeatState.hx @@ -240,7 +240,7 @@ class MusicBeatState extends FlxState implements IBeatReceiver public override function destroy() { super.destroy(); graphicCache.destroy(); - call("onDestroy"); + call("destroy"); stateScripts = FlxDestroyUtil.destroy(stateScripts); } diff --git a/source/funkin/backend/MusicBeatSubstate.hx b/source/funkin/backend/MusicBeatSubstate.hx index 4b4315ca..4c96f46b 100644 --- a/source/funkin/backend/MusicBeatSubstate.hx +++ b/source/funkin/backend/MusicBeatSubstate.hx @@ -228,7 +228,7 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver public override function destroy() { super.destroy(); - call("onDestroy"); + call("destroy"); stateScripts = FlxDestroyUtil.destroy(stateScripts); } diff --git a/source/funkin/backend/scripting/GlobalScript.hx b/source/funkin/backend/scripting/GlobalScript.hx index dbca645c..9c6c15dd 100644 --- a/source/funkin/backend/scripting/GlobalScript.hx +++ b/source/funkin/backend/scripting/GlobalScript.hx @@ -87,7 +87,7 @@ class GlobalScript { if (scripts != null) scripts.call(name, args); } public static function onModSwitch(newMod:String) { - call("onDestroy"); + call("destroy"); scripts = FlxDestroyUtil.destroy(scripts); scripts = new ScriptPack("GlobalScript"); for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) { diff --git a/source/funkin/backend/scripting/HScript.hx b/source/funkin/backend/scripting/HScript.hx index 9502b7d1..f8e07b54 100644 --- a/source/funkin/backend/scripting/HScript.hx +++ b/source/funkin/backend/scripting/HScript.hx @@ -171,8 +171,4 @@ class HScript extends Script { public override function setPublicMap(map:Map) { this.interp.publicVariables = map; } - - public override function onDestroy() { - super.onDestroy(); - } } diff --git a/source/funkin/backend/scripting/MultiThreadedScript.hx b/source/funkin/backend/scripting/MultiThreadedScript.hx index 49b7a163..3ba51f52 100644 --- a/source/funkin/backend/scripting/MultiThreadedScript.hx +++ b/source/funkin/backend/scripting/MultiThreadedScript.hx @@ -82,7 +82,7 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe public function destroy() { if (script != null) { - script.call("onDestroy"); + script.call("destroy"); script.destroy(); } diff --git a/source/funkin/backend/scripting/Script.hx b/source/funkin/backend/scripting/Script.hx index bdfe59bf..13687e64 100644 --- a/source/funkin/backend/scripting/Script.hx +++ b/source/funkin/backend/scripting/Script.hx @@ -305,11 +305,4 @@ class Script extends FlxBasic implements IFlxDestroyable { public function onCreate(path:String) {} public function onLoad() {} - - public function onDestroy() {}; - - public override function destroy() { - super.destroy(); - onDestroy(); - } } \ No newline at end of file diff --git a/source/funkin/backend/scripting/ScriptPack.hx b/source/funkin/backend/scripting/ScriptPack.hx index 33799690..32c590fc 100644 --- a/source/funkin/backend/scripting/ScriptPack.hx +++ b/source/funkin/backend/scripting/ScriptPack.hx @@ -95,7 +95,8 @@ class ScriptPack extends Script { for(e in scripts) e.setParent(parent); } - public override function onDestroy() { + public override function destroy() { + super.destroy(); for(e in scripts) e.destroy(); } diff --git a/source/funkin/game/GameOverSubstate.hx b/source/funkin/game/GameOverSubstate.hx index 89479dcf..c9957f14 100644 --- a/source/funkin/game/GameOverSubstate.hx +++ b/source/funkin/game/GameOverSubstate.hx @@ -183,7 +183,7 @@ class GameOverSubstate extends MusicBeatSubstate override function destroy() { - gameoverScript.call("onDestroy"); + gameoverScript.call("destroy"); gameoverScript.destroy(); super.destroy(); diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index c3e9744e..f81319e6 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -164,7 +164,7 @@ class PauseSubState extends MusicBeatSubstate { if(FlxG.cameras.list.contains(camera)) FlxG.cameras.remove(camera, true); - pauseScript.call("onDestroy"); + pauseScript.call("destroy"); pauseScript.destroy(); if (pauseMusic != null)