Skip to content

Commit

Permalink
fixed some script documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Nov 20, 2024
1 parent b430345 commit bcc2b62
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assets/scripts/template.hxs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ function noteMiss(direction:String) {}
function endSong() {}

/**
* Called when leaving PlayState.
* Called when the script is destroyed.
*/
function destroy() {}
14 changes: 6 additions & 8 deletions docs/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ The following are not supported:
* `Function_Stop` - Cancels functions (e.g., `startCountdown`, `endSong`).
* `Function_Continue` - Continues the game like normal.
* `platform` - Returns the current platform (e.g., Windows, Linux).
* `version` - Returns the current game version.

## Default Functions
* `import` - See [Imports](https://github.com/Joalor64GH/Rhythmo-SC/wiki/Scripting#imports) for more.
* `trace` - The equivalent of `trace` in normal Haxe.
* `stopScript` - Stops the current script.
* `addScript` - Adds a new script to `scriptArray` (Used in PlayState only).
* `trace(_)` - The equivalent of `trace` in normal Haxe.
* `stopScript()` - Stops the current script.
* `addScript(path:String)` - Adds a new script to `scriptArray` (Used in PlayState only).
* `importScript(source:String)` - Gives the given script's local functions and variables.

## Imports
To import a class, use:
Expand Down Expand Up @@ -115,11 +117,6 @@ Otherwise, here is a list of the current classes you can use that are already im
* `Song`
* `Utilities`

Additionally, if you want to import another script, use:
```hx
importScript('path.to.script');
```

## Templates
Some useful templates. For the default template, use [this](https://raw.githubusercontent.com/Joalor64GH/Rhythmo-SC/main/assets/scripts/template.hxs).

Expand Down Expand Up @@ -195,6 +192,7 @@ And just in case your script doesn't load or something goes wrong, press `F4` to
### Using Imported Scripts
Script 1:
```hx
// assets/helpers/spriteHandler.hxs
import('flixel.FlxSprite');
import('backend.Paths');
import('flixel.FlxG');
Expand Down
1 change: 1 addition & 0 deletions source/modding/Hscript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Hscript extends FlxBasic {
});

setVariable('platform', PlatformUtil.getPlatform());
setVariable('version', Lib.application.meta.get('version'));

setVariable('importScript', function(source:String) {
var name:String = StringTools.replace(source, '.', '/');
Expand Down
2 changes: 1 addition & 1 deletion source/states/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class MenuState extends ExtendableState {
grpSelection.add(menuItem);
}

final versii:FlxText = new FlxText(5, FlxG.height - 24, 0, 'Rhythmo v${Lib.application.meta.get('version')} (${MacrosUtil.getCommitId()})', 12);
final versii:FlxText = new FlxText(5, FlxG.height - 24, 0, 'Rhythmo v${Lib.application.meta.get('version')}' #if debug + ' (${MacrosUtil.getCommitId()})' #end, 12);
versii.setFormat(Paths.font('vcr.ttf'), 26, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
versii.scrollFactor.set();
add(versii);
Expand Down

0 comments on commit bcc2b62

Please sign in to comment.