Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

Commit 032c01d

Browse files
committed
script thingies 1
1 parent 0ced585 commit 032c01d

9 files changed

Lines changed: 95 additions & 52 deletions

File tree

Project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163

164164
<!-- _________________________ Polymod Configuration ________________________ -->
165165

166+
<haxedef name="POLYMOD_SCRIPT_EXT" value=".hscript" />
166167
<haxedef name="POLYMOD_ROOT_PATH" value="game/"/> <!-- This is used to tell polymod where scripts are-->
167168
<haxedef name="POLYMOD_MOD_METADATA_FILE" value="meta.json" />
168169
<haxedef name="POLYMOD_MOD_ICON_FILE" value="icon.png" />

source/MusicBeatState.hx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package;
22

3+
import modding.backend.RedirectHandler;
34
import modding.PolymodHandler;
45
import modding.LoadState;
56
import Conductor.BPMChangeEvent;
@@ -24,6 +25,8 @@ import sys.io.File;
2425

2526
using StringTools;
2627

28+
class ScriptHandler {} // stub
29+
2730
class MusicBeatState extends modchart.modcharting.ModchartMusicBeatState
2831
{
2932
private var curSection:Int = 0;
@@ -41,12 +44,8 @@ class MusicBeatState extends modchart.modcharting.ModchartMusicBeatState
4144
inline function get_controls():Controls
4245
return PlayerSettings.player1.controls;
4346

44-
public var scriptsAllowed:Bool = true;
45-
46-
public static var lastScriptName:String = null;
47-
public static var lastStateName:String = null;
48-
49-
public var scriptName:String = null;
47+
public static var redirects:Array<RedirectHandler> = [];
48+
public var loadedScripts:ScriptHandler;
5049

5150
function loadScript() // Stubbed untill later, this will be re-used for loading polymod scripts.
5251
{

source/modding/ModFolder.hx

Lines changed: 0 additions & 13 deletions
This file was deleted.

source/modding/PolymodHandler.hx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@ import polymod.Polymod.PolymodError;
88
import polymod.util.DefineUtil.getDefineString;
99
import polymod.util.DefineUtil.getDefineBool;
1010

11-
import modding.ModFolder;
12-
import modding.ScriptContext;
13-
import modding.ScriptContext.ModScriptContexts;
14-
1511
import sys.FileSystem as Fs;
1612
import sys.io.File;
1713

1814
class PolymodHandler {
1915
static var modRoot:String = #if TEST_BUILD "../../../new_example_mods" #else "mods" #end;
2016
static var apiVersion:String = "1.0.0"; // This should match the current engine version.
21-
static var scriptContexts:Array<ModScriptContexts> = [];
2217

2318
static var modsList:Array<ModMetadata> = [];
2419
static var customAssetLibrary:Map<String, String> = [
@@ -40,7 +35,6 @@ class PolymodHandler {
4035
public static function initModList()
4136
{
4237
modsList = [];
43-
scriptContexts = [];
4438

4539
trace("Searching for mods!");
4640

source/modding/ScriptContext.hx

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package modding;
2+
3+
import polymod.hscript.HScriptedClass;
4+
5+
@:hscriptClass
6+
class ScriptedBeatState extends MusicBeatState implements HScriptedClass {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package modding;
2+
3+
import polymod.hscript.HScriptedClass;
4+
5+
@:hscriptClass
6+
class ScriptedBeatSubstate extends MusicBeatSubstate implements HScriptedClass {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package modding.backend;
2+
3+
import polymod.hscript.HScriptedClass;
4+
5+
/*
6+
* This is the global script
7+
*/
8+
class GlobalScript
9+
{
10+
public var curBeat(get, null):Int;
11+
public var curStep(get, null):Int;
12+
public var curSection(get, null):Int;
13+
public var game(default, set):Dynamic;
14+
public var onPlayState:Bool = false;
15+
16+
public function new()
17+
{
18+
if (game == null) game = FlxG.state;
19+
}
20+
21+
// Basic script functions
22+
public function onCreate() {}
23+
public function onCreatePost() {}
24+
public function onUpdate(elapsed:Float) {}
25+
public function onUpdatePost(elapsed:Float) {}
26+
public function onStateSwitch(nextState:FlxState) {}
27+
public function postStateSwitch(nextState:FlxState) {}
28+
29+
// PlayState specific functions
30+
public function onBeatHit() {}
31+
public function onSectionHit() {}
32+
public function onStepHit() {}
33+
34+
// Other loader specific things
35+
public function addRedirect(b:Class<FlxState>, r:Class<FlxState>)
36+
{
37+
MusicBeatState.redirects.push(new RedirectHandler(b, r));
38+
}
39+
40+
// Variable getters
41+
function get_curBeat():Int
42+
{
43+
return MusicBeatState.curBeat;
44+
}
45+
function get_curStep():Int
46+
{
47+
return MusicBeatState.curStep;
48+
}
49+
function get_curSection():Int
50+
{
51+
return MusicBeatState.curSection;
52+
}
53+
54+
// Variable Setters
55+
function set_game(v:Dynamic):Dynamic
56+
{
57+
onPlayState = Std.isOfType(v, PlayState);
58+
game = v;
59+
return v;
60+
}
61+
}
62+
63+
@:hscriptClass
64+
class GScript extends GlobalScript implements HScriptedClass {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package modding.backend;
2+
3+
class RedirectHandler
4+
{
5+
public var baseState:Class<FlxState>;
6+
public var redirect:Class<FlxState>;
7+
8+
public function new(b:Class<FlxState>, r:Class<FlxState>)
9+
{
10+
baseState = b;
11+
redirect = r;
12+
}
13+
}

0 commit comments

Comments
 (0)