Skip to content

Commit 5100568

Browse files
AWSWCommunityAWSWCommunity
authored andcommitted
Update docs
1 parent f08b1dd commit 5100568

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Simply extract bootstrap.rpy, modloader, and mods to the game folder in your AWS
55

66
## Api
77

8-
To access all the helper functions for modifying game behaviour, put ```import modlib``` at the top of your mod file. ```modlib``` comes preloaded with a class called ```AWSWModBase``` initialized in the ```base``` member of ```modlib```. It is recommended to redeclare ```base``` as something easy to access in your mod file, such as with ```ml = modlib.base```. Useful functions in the class are listed below.
8+
To access all the helper functions for modifying game behaviour, put ```from modloader.modlib import base as ml``` at the top of your mod file. ```modlib``` comes preloaded with a class called ```AWSWModBase``` initialized in the ```base``` member of ```modlib```. The line above will automatically redeclare ```base``` as ```ml```. Useful functions in the class are listed below.
99

1010
#### ```Screen getscreen(string screen_name)```
1111
This gets a Ren'py Screen object(long name: renpy.display.screen.Screen). This is used to get a handle to a screen you might want to edit, such as the status overlay or the main_menu.
@@ -106,8 +106,6 @@ This will need to be called if you're hooking after an ending. The game disables
106106

107107
## Magic
108108

109-
Defining ```def mod_init():``` in the root of your mod file will cause this function to get called after all mods are loaded. This is useful for interaction with other loaded mods, or accessing the ```modinfo``` module to get information about the mods.
110-
111109
Anywhere in Ren'py code, you can access the global variable ```mod_currentChapter``` to get an integer value of the current chapter. For example, during chapter one, ```mod_currentChapter``` will equal ```1```. During chapter two, it will be equal to ```2```, and so on. This variable is useful for rate limiting routes or events to one per chapter. If you want to access this variable in python, use ```modlib.base.getRGlobal('mod_currentChapter')```.
112110

113111
## Writing Mods
@@ -117,14 +115,28 @@ Each mod has two components: the patcher and the additive game code. The patcher
117115
To construct a mod, see the tree below.
118116
```
119117
MyMod
120-
|-- mod.py
118+
|-- __init__.py
121119
|-- myResource.rpy
122120
|-- resource
123121
|-- custbg
124122
|-- myBackground.png
125123
```
126124

127-
Any *.rpy file is optional, and will be loaded automatically. The main mod file is mandatory for your mod to be loaded, and **must** be named ```mod.py```. Every mod should start with ```import modlib```. This will include all the utilities needed to get started. Using ```modlib``` is as simple as declaring ```ml = modlib.base``` and accessing the class's functions. The ```resource``` folder is optional as well. Files in this folder will be loaded into that game as if they were local to the game/ folder or the root of the archive. Should a file have the same name and location as one in the original game, the mod file will override the original.
125+
Any *.rpy file is optional, and will be loaded automatically. The main mod file is mandatory for your mod to be loaded, and **must** be named ```__init__.py```. Every mod should start with ```from modloader.modlib import base as ml```. This will include all the utilities needed to get started. Using ```modlib``` is as simple as calling functions on ```ml```. The ```resource``` folder is optional as well. Files in this folder will be loaded into that game as if they were local to the game/ folder or the root of the archive. Should a file have the same name and location as one in the original game, the mod file will override the original.
126+
127+
To get full functionality from the modloader, it is recommended that you inherit from the modclass.Mod class. This will give you access to hooks at various stages during mod loading, and properly inform the user of your mod's status. To do this, include ```from modloader.modclass import Mod, loadable_mod``` at the top of your mod file. Define a class with a decorator as shown below:
128+
```python
129+
@loadable_mod
130+
class AWSWMod(Mod):
131+
def mod_info(self):
132+
return ("MyModName", "v0.1", "AuthorName")
133+
134+
def mod_load(self): # called immediately after loading. Most code should go here.
135+
pass
136+
137+
def mod_complete(self): # called after all mods are loaded.
138+
pass
139+
```
128140

129141
## Python and the Dangers of Rollback
130142
Rollback is an integral feature of Ren'py, allowing the user to step back in time and make different choices. Usually rollback will play well with mods, but there are some cases that can introduce non-deterministic behavior. The main issue that rollback has is only Python objects encoded in Ren'Py's AST(and then, only a select few statements) are rolled back. For this reason, Python functions should not be used in hooks if you can avoid them.

0 commit comments

Comments
 (0)