Giter Site home page Giter Site logo

moon2p8-py's Introduction

Moon2P8

Compiles MoonScript to Pico-8 codes easily and flexibly.

Overview

Pico-8 is a fantasy game console created by Lexaloffle Games. Pico-8 provides a complete package of tools for small-sized videogame development, including code editor (in Lua), sprite editor, tile map editor, and audio/music tools.

MoonScript is a programming language that compiles to Lua.

While Pico-8 cartridge code is written in Lua and allows the inclusion of multiple files, its subset of Lua unfortunately conflicts with MoonScript and prevents a flexible code structure.

Moon2P8 is a tool written in Python that automates the process of MoonScript to Lua compilation and injection to Pico-8 cartridge, while allowing a flexible code structure with a syntax similar to Pico-8's original #include.

Requirement

Moonscript: While a system-wide installation is preferred, moonc only needs to work in the working directory. To confirm, moonc -v should return the version of MoonScript.

Python 3: This has been tested on Python 3.8.3.

An output Pico-8 cartridge: the easiest and simple way to do this is to reboot Pico-8 and save *.p8. This has to be a valid Pico-8 cartridge with __lua__ and __gfx__ markers. The output file has to be created priorly.

Installation

  • Download and save the raw script. Alternative, clone this repository.

  • Keep the script somewhere easy to access, ideally in the same working directory with the source file and the output file.

A system-wide setup is possible and the process varies from OS and OS, but is unnecessary.

Usage

The process will destroy the codes contained in the output Pico-8 cartridge. Do make backup as needed.

moon2p8.py inputFile outputFile [-h] [-v] [-kt]

positional arguments:
  inputFile             your *.moon source file
  outputFile            the output *.p8 Pico-8 cartridge to insert codes to     
                        (must be pre-created and has valid __lua__ and __gfx__  
                        markers)

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         show detailed and verbose output
  -kt, --keeptempfiles  keep temporary files after the operation

Actual example:

python moon2p8.py src.moon DarkDawn.p8 -v

Multiple files inclusion

The syntax differs slightly from Pico-8, but works similarly:

#include("your_file.moon")
#Include("Entities/Player.moon")
#INCLUDE("Components/PlayerControl.moon")

#include can be case insensitive, and DOUBLE-QUOTES are mandatory.

Consolidating instances of #include into the entry source file is recommended. It should work recursively, but this has not been tested.

Remarks

  • The process will destroy the code contained in the output Pico-8 cartridge. Do make backup as needed.
  • This has not been tested with Python 2.
  • This has only been tested on Windows 10.
  • Two temporary files will be created and necessary for the compilation to Lua. Some permission granting might be necessary, and this differs from system to system.

Contribution

Code critiques, issues and pull requests are welcomed.

moon2p8-py's People

Contributors

junongx avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.