Skip to content

Commit fe6a70a

Browse files
Docs: add documentation for options comparison (#2505)
1 parent 6718fa4 commit fe6a70a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

docs/options api.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,33 @@ or if I need a boolean object, such as in my slot_data I can access it as:
7777
```python
7878
start_with_sword = bool(self.options.starting_sword.value)
7979
```
80-
80+
All numeric options (i.e. Toggle, Choice, Range) can be compared to integers, strings that match their attributes,
81+
strings that match the option attributes after "option_" is stripped, and the attributes themselves.
82+
```python
83+
# options.py
84+
class Logic(Choice):
85+
option_normal = 0
86+
option_hard = 1
87+
option_challenging = 2
88+
option_extreme = 3
89+
option_insane = 4
90+
alias_extra_hard = 2
91+
crazy = 4 # won't be listed as an option and only exists as an attribute on the class
92+
93+
# __init__.py
94+
from .options import Logic
95+
96+
if self.options.logic:
97+
do_things_for_all_non_normal_logic()
98+
if self.options.logic == 1:
99+
do_hard_things()
100+
elif self.options.logic == "challenging":
101+
do_challenging_things()
102+
elif self.options.logic == Logic.option_extreme:
103+
do_extreme_things()
104+
elif self.options.logic == "crazy":
105+
do_insane_things()
106+
```
81107
## Generic Option Classes
82108
These options are generically available to every game automatically, but can be overridden for slightly different
83109
behavior, if desired. See `worlds/soe/Options.py` for an example.

0 commit comments

Comments
 (0)