Skip to content

Commit fcdda74

Browse files
Merge branch 'FunkinCrew:master' into master
2 parents 5791e66 + b0ef18f commit fcdda74

File tree

13 files changed

+194
-19
lines changed

13 files changed

+194
-19
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Addition Pull Request
2+
description: Suggest a new article.
3+
title: "[ADDITION] "
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: "# PLEASE READ THE [ARTICLE STANDARTS](https://github.com/FunkinCrew/code-cookbook/blob/master/authoring.md) BEFORE OPENING PULL REQUESTS!"
8+
9+
- type: textarea
10+
attributes:
11+
label: What does this pull request add?
12+
placeholder: Describe your additions here...
13+
validations:
14+
required: true
15+
16+
- type: textarea
17+
attributes:
18+
label: Screenshots/Videos
19+
placeholder: Demonstrate your additions here...
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Enhancement Pull Request
2+
description: Add improvements/new information to an existing article.
3+
title: "[ENHANCEMENT] "
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: "# PLEASE READ THE [ARTICLE STANDARTS](https://github.com/FunkinCrew/code-cookbook/blob/master/authoring.md) BEFORE OPENING PULL REQUESTS!"
8+
9+
- type: textarea
10+
attributes:
11+
label: What does this pull request add?
12+
placeholder: Describe your enhancements here...
13+
validations:
14+
required: true
15+
16+
- type: textarea
17+
attributes:
18+
label: Screenshots/Videos
19+
placeholder: Demonstrate your enhancements here...
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Fix Pull Request
2+
description: Correct typos/formatting issues/inaccurate information that may be present in the articles.
3+
title: "[FIX] "
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: "# PLEASE READ THE [ARTICLE STANDARTS](https://github.com/FunkinCrew/code-cookbook/blob/master/authoring.md) BEFORE OPENING PULL REQUESTS!"
8+
9+
- type: textarea
10+
attributes:
11+
label: What does this pull request fix?
12+
placeholder: Describe your fixes here...
13+
validations:
14+
required: true
15+
16+
- type: textarea
17+
attributes:
18+
label: Screenshots/Videos
19+
placeholder: Demonstrate your fixes here...

assets/content/cookbook/Advanced/02.ScriptedClasses.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class BallisticSong extends Song {
2424

2525
There is a predefined list of classes which the game has set up to be scriptable, and will automatically load and execute when relevant. More of these will be added in the future.
2626

27-
- `funkin.play.song.Song` for providing unique behavior to custom songs, including playing cutscenes and other stuff. See [Scripted Songs](3.ScriptedSongs.md).
28-
- See also [Video Cutscenes](6.VideoCutscenes.md), [Ingame Cutscenes](21-scripted-classes/21-04-ingame-cutscenes.md), and [Dialogue Cutscenes](7.DialogueCutscenes.md)
29-
- `funkin.play.character.BaseCharacter` for providing unique behavior to custom characters (such as playing custom animations in certain circumstances). See [Scripted Characters](4.ScriptedCharacters.md).
27+
- `funkin.play.song.Song` for providing unique behavior to custom songs, including playing cutscenes and other stuff. See [Scripted Songs](03.ScriptedSongs.md).
28+
- See also [Video Cutscenes](09.VideoCutscenes.md), [Ingame Cutscenes](21-scripted-classes/21-04-ingame-cutscenes.md), and [Dialogue Cutscenes](08.DialogueCutscenes.md)
29+
- `funkin.play.character.BaseCharacter` for providing unique behavior to custom characters (such as playing custom animations in certain circumstances). See [Scripted Characters](04.ScriptedCharacters.md).
3030

3131
- Note that you need to choose the correct subclass of this class for the animation type of your character!
3232

@@ -42,12 +42,12 @@ There is a predefined list of classes which the game has set up to be scriptable
4242
- `funkin.ui.freeplay.charselect.PlayableCharacter` for providing unique behavior to custom playable characters. See [Scripted Playable Characters](5.ScriptedPlayableCharacters.md)
4343
- `funkin.ui.freeplay.FreeplayStyle` for defining the sprites and colors used by the Freeplay menu when a given character is selected. See [WIP]
4444
- `funkin.play.notes.notestyle.NoteStyle` for modifying the behavior of custom note styles. See [WIP]
45-
- `funkin.play.cutscene.dialogue.Conversation` for providing unique behavior to custom dialogue conversations. See [Dialogue Cutscenes](7.DialogueCutscenes.md)
46-
- `funkin.play.cutscene.dialogue.DialogueBox` for providing unique behavior to custom dialogue boxes used in conversations. See [Dialogue Cutscenes](7.DialogueCutscenes.md)
47-
- `funkin.play.cutscene.dialogue.Speaker` for providing unique behavior to custom speakers used in conversations. See [Dialogue Cutscenes](7.DialogueCutscenes.md)
45+
- `funkin.play.cutscene.dialogue.Conversation` for providing unique behavior to custom dialogue conversations. See [Dialogue Cutscenes](08.DialogueCutscenes.md)
46+
- `funkin.play.cutscene.dialogue.DialogueBox` for providing unique behavior to custom dialogue boxes used in conversations. See [Dialogue Cutscenes](08.DialogueCutscenes.md)
47+
- `funkin.play.cutscene.dialogue.Speaker` for providing unique behavior to custom speakers used in conversations. See [Dialogue Cutscenes](08.DialogueCutscenes.md)
4848
- `funkin.ui.freeplay.Album` for defining custom behavior for Freeplay Albums. See [WIP]
4949

50-
There is also `funkin.modding.module.Module` for custom scripted Modules, which are scripts which receive events everywhere, rather than only in a specific context. See [Scripted Modules](30-scripted-modules/30-00-scripted-modules.md) for more information on how these work.
50+
There is also `funkin.modding.module.Module` for custom scripted Modules, which are scripts which receive events everywhere, rather than only in a specific context. See [Scripted Modules](../Expert/01.ScriptedModules.md) for more information on how these work.
5151

5252
There are also scripted classes are also set up to be scriptable, but will only be useful if they're accessed from another script. Expect more of these to be added in the future.
5353

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[tags]: / "advanced,hscript,events"
2+
3+
# Scripted Song Events
4+
5+
This chapter will walk you through the process of creating a custom song event, which could be used in songs through the chart editor.
6+
7+
Start by creating a scripted class file with the `.hxc` extension (in the `mods/mymod/scripts/events` if you want to keep things organized)
8+
9+
```haxe
10+
// Remember to import each class you want to reference in your script!
11+
import funkin.play.event.SongEvent;
12+
13+
// Choose a name for your scripted class that will be unique, and make sure to specifically extend the SongEvent class.
14+
class FocusCameraSongEvent extends SongEvent {
15+
public function new() {
16+
// The constructor gets called once, when the game loads.
17+
// The constructor takes one parameter, which is the event ID for your custom event.
18+
super('FocusCamera');
19+
}
20+
21+
// Add override functions here!
22+
}
23+
```
24+
25+
You can then add override functions to perform custom behavior.
26+
27+
## Performing behavior when getting called
28+
29+
To provide custom behavior to the event that gets called when the song reaches the event's position, you must override the function `handleEvent`. Overriding this function is mandatory, as if your custom event doesn't include it, the game will crash when attempting to activate the event. The function comes with a parameter from which you can retreive some information about the event, such as the property values provided. An example of this can be found in the event Play Animation[^playanim]
30+
31+
```haxe
32+
// ...
33+
34+
// Line 18
35+
public override function handleEvent(data:SongEventData)
36+
{
37+
// Does nothing if there is no PlayState camera or stage.
38+
if (PlayState.instance == null || PlayState.instance.currentStage == null) return;
39+
40+
var targetName = data.getString('target');
41+
var anim = data.getString('anim');
42+
var force = data.getBool('force');
43+
if (force == null) force = false;
44+
45+
// ...
46+
}
47+
48+
// ...
49+
50+
```
51+
52+
## Providing song event properties
53+
54+
The game supports providing events some additional properties for more leeway in functionality. For this, you need to override the function `getEventSchema` that returns an array of anonymous objects, each representing a property your event can have. The structure of these anonymous objects is as follows:
55+
56+
- `name`: The internal name of the property, which you can use to get the value of the property when executing the event.
57+
58+
- `title`: The visible name of the property, as displayed in the chart editor events toolbox.
59+
60+
- `type`: The type of the event. Can be either `string` (text properties), `integer`, `float`, `bool` or `enum` (dropdown properties).
61+
62+
- `defaultValue`: An optional default value for the property.
63+
64+
- `keys`: Is an optional map with keys representing the visible name and values representing the internal name of the property values.
65+
66+
- Accessible to the `enum `properties.
67+
68+
- `min`: Represents the optional minimum value that the property could have.
69+
70+
- Available to the `integer` and `float` properties.
71+
72+
- `max`: Represents the optional maximum value that the property could have.
73+
74+
- Available to the `integer` and `float` properties.
75+
76+
- `step`: Represents the amount the value steps by for each change in the toolbox. This field is optional and defaults to `0.1`.
77+
78+
- Available to the `integer` and `float` properties.
79+
80+
- `units`: Represents the unit of measure for the numeric value. (i.e. pixels, steps etc.)
81+
82+
- Available to the `integer` and `float` properties.
83+
84+
## Custom song event chart editor icon
85+
86+
Chart editor supports both static and animated song event icons in the spritesheet format. To provide a custom icon for your event in the chart editor, you need to put two things in the `mods/mymod/images/ui/chart-editor/events` folder:
87+
88+
- An image of your song event icon named after what you put in the event's constructor.
89+
90+
- An XML file for your song event icon, even if it's a single frame.
91+
92+
- The frame names must start with the text you put inside the event's constructor.
93+
94+
Once you made sure both assets are where they should be and have the correct names, your song event should have a custom icon in the chart editor.
95+
96+
## Custom song event title
97+
98+
To give your song event an unique title that will be displayed in the chart editor's event toolbox dropdown, you must override the function `getTitle` with the return of your desired event title. An example of this is found in the event Zoom Camera[^camzoom]
99+
100+
```haxe
101+
// ...
102+
103+
// Line 91
104+
public override function getTitle():String
105+
{
106+
return 'Zoom Camera';
107+
}
108+
109+
// ...
110+
```
111+
112+
[^playanim]: <https://github.com/FunkinCrew/Funkin/blob/main/source/funkin/play/event/PlayAnimationSongEvent.hx>
113+
[^camzoom]: <https://github.com/FunkinCrew/Funkin/blob/main/source/funkin/play/event/ZoomCameraSongEvent.hx>
114+
115+
> Author: [KoloInDaCrib](https://github.com/KoloInDaCrib)

assets/content/cookbook/Expert/01.ScriptedModules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ Modules have all the events most scripts have, but the difference is. You also h
5050

5151
Modules also have a priority system for compatibility with other mods, in your construction method, `new()`, you can set the `priority` property (which defaults to `1000`). 1 is processed before anything else.
5252

53-
You can view a detailed list of script events and their callbacks in [here](../Advanced/6.ScriptEventCallbacks.md)
53+
You can view a detailed list of script events and their callbacks in [here](../Advanced/06.ScriptEventCallbacks.md)
5454

5555
> Author: [Kade](https://github.com/Kade-github)

assets/content/cookbook/Intermediate/01.CustomPlayableCharacters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ This chapter goes over adding new playable characters to the game, ensuring that
1010

1111
In order to make a fleshed out custom character that can be used from Character Select in Friday Night Funkin', you need a large number of textures, animations, and audio tracks:
1212

13-
- A [custom character](../Introduction/3.CustomCharacters.md).
13+
- A [custom character](../Introduction/03.CustomCharacters.md).
1414

1515
- This requires a set of singing animations for the character.
16-
- At least one custom song that uses that character; this can be either [a new song](../Introduction/2.CustomSongs.md#adding-the-custom-song) or a [variation added to an existing song](../Introduction/2.CustomSongs.md#adding-variations-to-existing-songs).
16+
- At least one custom song that uses that character; this can be either [a new song](../Introduction/02.CustomSongs.md#adding-the-custom-song) or a [variation added to an existing song](../Introduction/02.CustomSongs.md#adding-variations-to-existing-songs).
1717

1818
- This requires an instrumental and split vocal tracks.
1919
- A pixel icon asset to use for that character's icon in the Character Select grid.
@@ -208,13 +208,13 @@ The available fields are:
208208

209209
- `version`: The version number for the Playable Character data file format. Leave this at `1.0.0`.
210210
- `name`: The readable name for the character, used internally.
211-
- `ownedCharacters`: The list of [Characters](../Introduction/3.CustomCharacters.md) this character owns.
211+
- `ownedCharacters`: The list of [Characters](../Introduction/03.CustomCharacters.md) this character owns.
212212

213213
- When determining which songs to display in Freeplay, the game checks for any songs where the player character is in this list and displays those. Songs where the player character is in another array are not displayed.
214214
- `showUnownedChars`: If this value is `true`, then songs whose player character is not in any `ownedCharacters` list will be displayed for this character.
215215
- `unlocked`: Whether the character is unlocked.
216216

217-
- Create a scripted class for this playable character and override `isUnlocked():Bool` to make this conditional. See [Scripted Playable Characters](../Advanced/5.ScriptedPlayableCharacters.md)
217+
- Create a scripted class for this playable character and override `isUnlocked():Bool` to make this conditional. See [Scripted Playable Characters](../Advanced/05.ScriptedPlayableCharacters.md)
218218
- `freeplayStyle`: The ID for a Freeplay style to display.
219219

220220
- You can use `"bf"` here to use Boyfriend's Freeplay style as a default, or create a new JSON file in the `data/ui/freeplay/styles` folder (copy the Pico one and edit that).

assets/content/cookbook/Intermediate/03.CustomStickerPacks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ For example, to add to Boyfriend's standard sticker pack, you can use the follow
5858

5959
There are two ways the game defines a given sticker pack to be used:
6060

61-
- Each [Playable Character](1.CustomPlayableCharacters.md) defines the `stickerPack` variable, which specifies the sticker pack to be used by songs containing that character. For example, `bf` uses the `standard-bf` sticker pack. You can define a sticker pack to be used for your custom playable character by setting the `stickerPack` value, or modify which sticker pack is used by other playable characters by using [JSONPatch](../Introduction/5.AppendingAndMerge.md#merging) to modify the `stickerPack` value of that character.
61+
- Each [Playable Character](01.CustomPlayableCharacters.md) defines the `stickerPack` variable, which specifies the sticker pack to be used by songs containing that character. For example, `bf` uses the `standard-bf` sticker pack. You can define a sticker pack to be used for your custom playable character by setting the `stickerPack` value, or modify which sticker pack is used by other playable characters by using [JSONPatch](../Introduction/05.AppendingAndMerge.md#merging) to modify the `stickerPack` value of that character.
6262
- Each song has a value in its metadata to define which sticker pack is used. Set the `playData.stickerPack` on a song (or use JSONPatch to modify metadata of an existing song) to override which sticker pack it uses.
6363

6464
The game checks and uses sticker packs in this order:

assets/content/cookbook/Intermediate/04.CustomAlbums.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Animation data is structured like so:
6161

6262
# Using the Album
6363

64-
Albums are defined on a per-song basis, so you have to set the album ID for each song. In order to do this, you first have to make the song the itself. See [Custom Songs and Custom Levels](../Introduction/2.CustomSongs.md).
64+
Albums are defined on a per-song basis, so you have to set the album ID for each song. In order to do this, you first have to make the song the itself. See [Custom Songs and Custom Levels](../Introduction/02.CustomSongs.md).
6565

6666
When you are done creating the song, head over to the `metadata.json` of the song where you want to album to appear and check in `playData` for the `album` key.
6767

assets/content/cookbook/Intermediate/05.Migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ if (Std.isOfType(currentState, OptionsState)) {
138138

139139
v0.6.0 rewrote how stickers get used by the game (and v0.6.3 rewrote it again but better this time). Any existing mods that provided stickers will probably break.
140140

141-
New or updating mods looking to add, remove, or replace stickers should consult the [custom Sticker Packs documentation](3.CustomStickerPacks.md)
141+
New or updating mods looking to add, remove, or replace stickers should consult the [custom Sticker Packs documentation](03.CustomStickerPacks.md)
142142

143143
> Author: [EliteMasterEric](https://github.com/EliteMasterEric)

0 commit comments

Comments
 (0)