File tree Expand file tree Collapse file tree 1 file changed +15
-23
lines changed
Expand file tree Collapse file tree 1 file changed +15
-23
lines changed Original file line number Diff line number Diff line change 11# Pythonized ComputerCraft API
22
3- First, you need to start a server :
3+ 1 . Create module named ` examplemod.py ` :
44
5- ``` bash
6- cd your_folder_with_programs
7- python -m computercraft.server
8- ```
5+ ``` python
6+ async def hello ( api ):
7+ await api.print( ' Hello world! ' )
8+ ```
99
10- Current directory is the place for your amazing programs.
11- Server tracks files inside this directory and reloads if necessary.
12- You don't (always) have to restart server if you change your programs.
10+ 2 . Start a server:
1311
14- Create simple program named ` hello.py ` :
12+ ```bash
13+ python - m computercraft.server examplemod
14+ ```
1515
16- ``` python
17- async def program (api ):
18- await api.print(' Hello world!' )
19- ```
16+ 3 . In minecraft, open up any computer and type :
2017
21- There must be a separate file for each program with ` program ` coroutine defined.
22-
23- In minecraft, open up any computer and type:
24-
25- ``` bash
26- wget http://127.0.0.1:8080/ py
27- py hello
28- ```
18+ ```bash
19+ wget http:// 127.0 .0.1:8080 / py
20+ py hello
21+ ```
2922
3023`py` is short Lua program that interacts with the server.
31- Argument is the name of program without ` .py ` .
32- In everything else it works exactly like native program on Lua.
24+ Argument is the name of coroutine inside the module.
3325`api` object contains almost everything * as is * in ComputerCraft documentation:
3426
3527```python
You can’t perform that action at this time.
0 commit comments