You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-9Lines changed: 27 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ MyMod
122
122
|-- myBackground.png
123
123
```
124
124
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.
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
126
127
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
128
```python
@@ -149,18 +149,36 @@ The AWSW mod tools do not modify any of the core game files. They will survive a
149
149
This sample code will remove Kevin's encounter and main menu icon. The full mod structure can be found in mods/.
150
150
151
151
```python
152
-
import modlib
153
152
import renpy
154
153
import renpy.ast as ast
155
-
ml = modlib.base
154
+
from modloader import modinfo
155
+
from modloader.modlib import sprnt
156
+
from modloader.modlib import base as ml # ml shortcut
157
+
from modloader.modclass import Mod, loadable_mod # Import the base class and the decorator
156
158
157
-
found = ml.searchPostNode(ml.findlabel("c4hatchery"), ast.Scene, 20) # search max of 20 nodes after c4hatchery label, look for the first scene initialization (which happens to be one opcode away, for now)
158
-
hook = ml.hook_opcode(found, None) # insert a hooking node after scene, but before the narrator's say statement
159
-
hook.chain(ml.searchPostNode(found, ast.Scene)) # normally the hooking node would point back to the dialogue. Skip all the way to the next scene instead.
159
+
@loadable_mod
160
+
classAWSWMod(Mod):
161
+
defmod_info(self):
162
+
return ("byekevin", "v0.1", "")
163
+
164
+
defmod_load(self):
165
+
found = ml.searchPostNode(ml.findlabel("c4hatchery"), ast.Scene, 20) # search max of 20 nodes after c4hatchery label, look for the first scene initialization (which happens to be one opcode away, for now)
166
+
hook = ml.hook_opcode(found, None) # insert a hooking node after scene, but before the narrator's say statement
167
+
hook.chain(ml.searchPostNode(found, ast.Scene)) # normally the hooking node would point back to the dialogue. Skip all the way to the next scene instead.
160
168
161
-
mainscr = ml.getsls('main_menu') # get the main screen (cache is disabled)
162
-
ml.nullPyexpr(mainscr, 'persistent.playedkevin') # remove the if block
163
-
```
169
+
mainscr = ml.getsls('main_menu') # get the main screen (cache is disabled)
170
+
ml.nullPyexpr(mainscr, 'persistent.playedkevin') # remove the if block
if node.next isnotNoneandisinstance(node.next, renpy.ast.Show) and node.next.imspec[0][0] =='meetingkevin': # imspec is part of the image ID in show opcodes.
177
+
returnTrue
178
+
179
+
kevin_credits = ml.searchPostNodeCB(true_search, kevinCB, 800) # search for a node using the kevinCB callback.
180
+
kevin_credits.chain(ml.searchPostNode(kevin_credits, ast.Scene)) # Show and with are separate instructions.
181
+
164
182
165
183
See the mods/and devmods/ folders for further sample code. devmods/ contains a few different examples with fully annotated code.
0 commit comments