Skip to content

Commit 62f9852

Browse files
committed
ghfdgdsgfd
1 parent f5b4775 commit 62f9852

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed
Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Custom Options
22
You may find it useful to have custom options specific to your mod, thankfully you can do just that!
33

4-
To get started, put a file in `data/config` called `options.xml` in whatever folder your mod resides in.
4+
To get started, put a file in `./data/config` called `options.xml`.
55

6-
> [!NOTE]
7-
> You can also put these into an addon, but do note that addons currently override mod options (as of writing)!
8-
9-
There is a template ready for you in `assets/data/config/options.xml`, here's what it looks like:
6+
There already exists a template for you to look on, and it looks something like this:
107

118
```xml
129
<menu name="Mod Options" desc="Modify mod options here">
10+
1311
<checkbox id="checkboxExample" name="Checkbox example" />
12+
1413
<number id="numberExample" name="Number example" min="0" max="10" change="1"/>
14+
1515
<choice id="choiceExample" name="Choice Example">
1616
<value name="Disabled" value="disabled"/>
1717
<value name="This only" value="thisOnly"/>
@@ -21,14 +21,9 @@ There is a template ready for you in `assets/data/config/options.xml`, here's wh
2121
<menu name="Submenu Example" desc="Submenu test">
2222
<checkbox id="levelOfIdk2" name="Level of idk" />
2323
</menu>
24+
2425
</menu>
2526
```
26-
I recommend just dumping this template into your `options.xml` file, and going off of that.
27-
28-
It will look something like this in-game:
29-
<img src="./Custom options.png"/>
30-
31-
# Option Types
3227
You're likely wondering: "how does each type of option work?"
3328
That's what is about to be explained!!
3429

@@ -55,19 +50,20 @@ All option types (except for `menu`) share 2 common properties:
5550
- `name` - This is the name of the value displayed on screen
5651
- `value` - This is the actual data/value applied to the option when chosen
5752

58-
# Save Data
59-
You may have noticed that none of the option types have a default value property,
60-
this is because you have to set the default values in a global script.
53+
Accessing them in Scripts is done via ``FlxG.save.data``, as you can see below.
54+
```hx
55+
var checkboxExample = FlxG.save.data.checkboxExample;
56+
```
6157

58+
You may have noticed that none of the option types have a default value property,
59+
this is because you have to set the default values yourself *(in a global script)*.<br>
60+
You have to do this otherwise your options won't save correctly!
6261

63-
This is rather easy to do, put this in `data/global.hx`:
62+
This is rather easy to do, put this in `./data/global.hx`:
6463
```haxe
6564
function create() {
6665
// FlxG.save is your mod's savedata
67-
if(FlxG.save.data.myOptionID == null)
68-
FlxG.save.data.myOptionID = "defaultValue";
66+
if(FlxG.save.data.checkboxExample == null)
67+
FlxG.save.data.checkboxExample = "defaultValue";
6968
}
70-
```
71-
72-
> [!WARNING]
73-
> You have to do this otherwise your options won't save correctly!
69+
```

0 commit comments

Comments
 (0)