1
1
# Custom Options
2
2
You may find it useful to have custom options specific to your mod, thankfully you can do just that!
3
3
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 ` .
5
5
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:
10
7
11
8
``` xml
12
9
<menu name =" Mod Options" desc =" Modify mod options here" >
10
+
13
11
<checkbox id =" checkboxExample" name =" Checkbox example" />
12
+
14
13
<number id =" numberExample" name =" Number example" min =" 0" max =" 10" change =" 1" />
14
+
15
15
<choice id =" choiceExample" name =" Choice Example" >
16
16
<value name =" Disabled" value =" disabled" />
17
17
<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
21
21
<menu name =" Submenu Example" desc =" Submenu test" >
22
22
<checkbox id =" levelOfIdk2" name =" Level of idk" />
23
23
</menu >
24
+
24
25
</menu >
25
26
```
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
32
27
You're likely wondering: "how does each type of option work?"
33
28
That's what is about to be explained!!
34
29
@@ -55,19 +50,20 @@ All option types (except for `menu`) share 2 common properties:
55
50
- ` name ` - This is the name of the value displayed on screen
56
51
- ` value ` - This is the actual data/value applied to the option when chosen
57
52
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
+ ```
61
57
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!
62
61
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` :
64
63
``` haxe
65
64
function create() {
66
65
// 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";
69
68
}
70
- ```
71
-
72
- > [ !WARNING]
73
- > You have to do this otherwise your options won't save correctly!
69
+ ```
0 commit comments