Skip to content

Commit

Permalink
fix and script formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Nov 21, 2024
1 parent 0151836 commit 68563f4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
28 changes: 14 additions & 14 deletions docs/Adding-a-New-Achievement.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ var condition:Bool = false;
var allowEndSong:Bool = false;
function update(elapsed:Float) {
if (PlayState.instance.score >= 1000000)
condition = true;
if (PlayState.instance.score >= 1000000)
condition = true;
}
function endSong() {
if (!allowEndSong && condition) {
Achievements.unlock('road_to_a_million', {
date: Date.now(),
song: PlayState.song.song
}, {
trace('achievement unlocked successfully!');
});
allowEndSong = true;
return Function_Stop;
} else
return Function_Continue;
if (!allowEndSong && condition) {
Achievements.unlock('road_to_a_million', {
date: Date.now(),
song: PlayState.song.song
}, {
trace('achievement unlocked successfully!');
});
allowEndSong = true;
return Function_Stop;
} else
return Function_Continue;
}
```
40 changes: 20 additions & 20 deletions docs/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Otherwise, here is a list of the current classes you can use that are already im
* `FlxBasic`
* `FlxCamera`
* `FlxColor`
* Fun Fact, `FlxColor` is actually an abstract type which isn't normally supported by `hscript` Luckily, I figured out a little workaround so you can still use `FlxColor` normally, or you can just use plain hex color values.
* Fun Fact, `FlxColor` is actually an abstract type which isn't normally supported by `hscript`. Luckily, I figured out a little workaround so you can still use `FlxColor` normally, or you can just use plain hex color values.
* `FlxEase`
* `FlxG`
* `FlxGroup`
Expand Down Expand Up @@ -127,8 +127,8 @@ import('flixel.FlxSprite');
import('states.PlayState');
function create() {
var spr:FlxSprite = new FlxSprite(0, 0).makeGraphic(50, 50, FlxColor.BLACK);
PlayState.instance.add(spr);
var spr:FlxSprite = new FlxSprite(0, 0).makeGraphic(50, 50, FlxColor.BLACK);
PlayState.instance.add(spr);
}
```

Expand All @@ -138,9 +138,9 @@ import('flixel.text.FlxText');
import('states.PlayState');
function create() {
var text:FlxText = new FlxText(0, 0, 0, "Hello World", 64);
text.screenCenter();
PlayState.instance.add(text);
var text:FlxText = new FlxText(0, 0, 0, "Hello World", 64);
text.screenCenter();
PlayState.instance.add(text);
}
```

Expand All @@ -153,10 +153,10 @@ import('haxe.Json');
var json:Dynamic;
function create() {
if (FileSystem.exists('assets/data.json'))
json = Json.parse(File.getContent('assets/data.json'));
if (FileSystem.exists('assets/data.json'))
json = Json.parse(File.getContent('assets/data.json'));
trace(json);
trace(json);
}
```

Expand All @@ -171,18 +171,18 @@ import('flixel.FlxG');
var state = FlxG.state;
function update(elapsed:Float) {
if (Input.justPressed('accept'))
ExtendableState.switchState(new ScriptedState('name')); // load custom state
if (Input.justPressed('exit'))
state.openSubState(new ScriptedSubState('name', [])); // load custom substate
if (Input.justPressed('accept'))
ExtendableState.switchState(new ScriptedState('name')); // load custom state
if (Input.justPressed('exit'))
state.openSubState(new ScriptedSubState('name', [])); // load custom substate
}
```

Additional template for scripted substates:
```hx
function new(/* arguments, if any */) {
// code goes here...
// code goes here...
}
```

Expand All @@ -201,11 +201,11 @@ import('flixel.FlxG');
var state = FlxG.state;
function createSprite(x:Float, y:Float, graphic:String) {
var spr:FlxSprite = new FlxSprite(x, y);
spr.loadGraphic(Paths.image(graphic));
state.add(spr);
var spr:FlxSprite = new FlxSprite(x, y);
spr.loadGraphic(Paths.image(graphic));
state.add(spr);
trace("sprite " + sprite + " created");
trace("sprite " + sprite + " created");
}
```

Expand All @@ -214,7 +214,7 @@ Script 2:
var otherScript = importScript('assets.helpers.spriteHandler');
function create() {
otherScript.createSprite(0, 0, 'sprite');
otherScript.createSprite(0, 0, 'sprite');
}
```

Expand Down
8 changes: 4 additions & 4 deletions source/modding/ModHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ModHandler {

#if FUTURE_POLYMOD
public static function loadMods(folders:Array<String>):Void {
if (!FileSystem.exists(MOD_DIR + '/'))
FileSystem.createDirectory(MOD_DIR + '/');
if (!FileSystem.exists(MOD_DIR + '/mods-go-here.txt'))
File.saveContent(MOD_DIR + '/mods-go-here.txt', '');
if (!FileSystem.exists('./' + MOD_DIR + '/'))
FileSystem.createDirectory('./' + MOD_DIR + '/');
if (!FileSystem.exists('./' + MOD_DIR + '/mods-go-here.txt'))
File.saveContent('./' + MOD_DIR + '/mods-go-here.txt', '');

var loadedModlist:Array<ModMetadata> = Polymod.init({
modRoot: MOD_DIR,
Expand Down

0 comments on commit 68563f4

Please sign in to comment.