8000 GitHub - C-Bookie/python-computer-craft: Pythonization of ComputerCraft Minecraft mod. Write Python instead Lua!
[go: up one dir, main page]

Skip to content

Pythonization of ComputerCraft Minecraft mod. Write Python instead Lua!

Notifications You must be signed in to change notification settings

C-Bookie/python-computer-craft

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pythonized ComputerCraft API

  1. Create module named examplemod.py:

    async def hello(api):
        await api.print('Hello world!')
  2. Start a server:

    python -m computercraft.server examplemod
  3. In minecraft, open up any computer and type:

    wget http://127.0.0.1:8080/ py
    py hello

py is short Lua program that interacts with the server. Argument is the name of coroutine inside the module. api object contains almost everything as is in ComputerCraft documentation:

async def program(api):
    await api.disk.eject('right')
    await api.print(await api.os.getComputerLabel())
    # ...

Using python coroutines allows launching commands in parallel, effectively replacing parallel API:

async def program(api):
    # Since os.sleep is mostly waiting for events, it doesn't block execution of parallel threads
    # and this snippet takes approximately 2 seconds to complete.
    await asyncio.gather(api.os.sleep(2), api.os.sleep(2))

About

Pythonization of ComputerCraft Minecraft mod. Write Python instead Lua!

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 81.8%
  • Lua 18.2%
0