Skip to content

Commit 58e59fa

Browse files
AWSWCommunityAWSWCommunity
authored andcommitted
Reorganize documentation
1 parent cd0c07c commit 58e59fa

File tree

2 files changed

+35
-36
lines changed

2 files changed

+35
-36
lines changed

API.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,19 @@ This function will return an instance of ```AWSWMenuHooks``` which will allow yo
8787
## ```class ASTHook```
8888
The ASTHook class is returned by any of the hooking functions. Its purpose is to all you to modify execution of the game. There are several useful properties on the AST class. First, the ```.next``` member points to the next node that should be executed. This can be set by assigning a node to ```next``` or calling ```chain``` on the class. When the ASTHook node is executed, it checks for a member function called ```hook_func```. If it exists, ```hook_func``` will be executed with the ASTHook class as the first parameter. If ```hook_func``` returns True, the ASTHook will not set the next node. Instead, you must call ```renpy.ast.next_node(Node node)``` manually. This can be used to redirect execution based on circumstances beyond the capabilities of the node alone.
8989

90-
## How to compile like a pro.
91-
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.
90+
## Stubs
91+
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```.
92+
#### ```_mod_fixjmp```
93+
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.
94+
#### ```_mod_incc```
95+
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.
9296

93-
## Debugging
94-
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.
97+
#### ```_mod_getchapter```
98+
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.
9599

96-
While in the root directory of the game, run the command for your appropriate operating system:
97-
#### Windows:
98-
```
99-
"lib/windows-i686/python.exe" -EO "Angels with Scaly Wings.py"
100-
```
101-
### Linux x86 (32 bit)
102-
```
103-
./lib/linux-i686/python.exe -EO "Angels with Scaly Wings.py"
104-
```
105-
### Linux x86_64 (64 bit)
106-
```
107-
./lib/linux-x86_64/python.exe -EO "Angels with Scaly Wings.py"
108-
```
100+
#### ```_mod_fixui```
101+
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*.
109102

110-
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.
103+
## Magic
111104

105+
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')```.

writing_mods.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
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-
191
## Writing Mods
202

213
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
5234
## Steam Updates
5335
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.
5436

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+
5560
## Sample Code
5661

5762
This sample code will remove Kevin's encounter and main menu icon. The full mod structure can be found in mods/.

0 commit comments

Comments
 (0)