|
1 |
| - |
2 |
| -## Stubs |
3 |
| -This is code you'll probably need to jump to at some point in your additive game code. They are standard Ren'py labels, and can be accessed with ```call stub_label``` or ```jump stub_label```. |
4 |
| -#### ```_mod_fixjmp``` |
5 |
| -Use ```jump _mod_fixjmp``` to access this stub. It will return to the proper chapter menu in the game when you jump to it. You don't need to use this is you're using ```return``` and ```AWSWHomeHook.addRoute```. ```addRoute``` pushes this stub to the callstack automatically. |
6 |
| -#### ```_mod_incc``` |
7 |
| -This will increment the character scene counter in the game for the appropriate chapter. This needs to be called at the start of every additional route. Use ```call _mod_incc``` to access this stub. |
8 |
| - |
9 |
| -#### ```_mod_getchapter``` |
10 |
| -This will get the current chapter as an integer. Access this stub with ```call _mod_getchapter``` and it will put the integer value of the current chapter in ```_return``` for you to check. |
11 |
| - |
12 |
| -#### ```_mod_fixui``` |
13 |
| -This will need to be called if you're hooking after an ending. The game disables interaction with UI at that point, so as soon as your get control of execution, you must ```call _mod_fixui```. If this is called after a say instruction, or any instruction that waits for user input, the game *will hang*. |
14 |
| - |
15 |
| -## Magic |
16 |
| - |
17 |
| -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')```. |
18 |
| - |
19 | 1 | ## Writing Mods
|
20 | 2 |
|
21 | 3 | Each mod has two components: the patcher and the additive game code. The patcher will do all the heavily lifting for modification of the game, and the additive game code will be anything that is new to the game.
|
@@ -52,6 +34,29 @@ Rollback is an integral feature of Ren'py, allowing the user to step back in tim
|
52 | 34 | ## Steam Updates
|
53 | 35 | The AWSW mod tools do not modify any of the core game files. They will survive and (probably) continue working through most changes to the game's code. Hooking via the stable and recommended methods will ensure that a modification to the game's code does not break your mod.
|
54 | 36 |
|
| 37 | +## How to compile like a pro. |
| 38 | +Instead of manually creating AST Nodes to insert code into the game, or even clunkily creating entries in the rpy language and then jumping to the snippets with the patcher, you can assemble small(or big!) bits of code *in-line* by abusing the Ren'py AST Parser. This means you can get a list of objects and insert them wherever with very little effort. We use this method internally to create the mod information menu on the main screen. See the core mod or the dev_test mod for further details. |
| 39 | + |
| 40 | +## Debugging |
| 41 | +There are several obstacles to developing mods for Ren'py. The first(and biggest) is the fact that the developer has no console to watch for output while running the game! We can fix that by starting AWSW via command line with some switches set. The commands are below. |
| 42 | + |
| 43 | +While in the root directory of the game, run the command for your appropriate operating system: |
| 44 | +#### Windows: |
| 45 | +``` |
| 46 | +"lib/windows-i686/python.exe" -EO "Angels with Scaly Wings.py" |
| 47 | +``` |
| 48 | +### Linux x86 (32 bit) |
| 49 | +``` |
| 50 | +./lib/linux-i686/python -EO "Angels with Scaly Wings.py" |
| 51 | +``` |
| 52 | +### Linux x86_64 (64 bit) |
| 53 | +``` |
| 54 | +./lib/linux-x86_64/python -EO "Angels with Scaly Wings.py" |
| 55 | +``` |
| 56 | + |
| 57 | +Should you print to the console in your code, you may run into an error such as ``` LookupError: unknown encoding: cp437```. This occurs because you're executing a local version of python, which only has utf-8 string encodings loaded in. You can fix this by using ```sprnt``` from ```modlib``` or encoding your string with ```myStr.encode('utf-8')``` before printing. |
| 58 | + |
| 59 | + |
55 | 60 | ## Sample Code
|
56 | 61 |
|
57 | 62 | This sample code will remove Kevin's encounter and main menu icon. The full mod structure can be found in mods/.
|
|
0 commit comments