minetest/README.md

2.9 KiB

#lang minetest for Modding Minetest in Racket

This language helps you create Minetest mods. Quick demo:

Alt text

This compiles to a mod that gives you a red block that toggles to a green block when you punch it (and vice versa):

Alt text

The goal of #lang minetest is to help you get procedurally generated art onto Minetest blocks, items, particles, entities, recipes, and schematics. We developed it for educational purposes at ThoughtSTEM.

Getting Started

(Note: #lang minetest works out of the box on Linux. For Mac or Windows, you'll have to make sure your minetest installation is at ~/HOME_DIR/.minetest)

Install Minetest:

sudo apt-get install minetest

Install Racket:

sudo apt-get install racket

Open DrRacket. Add the minetest package (File > Install Package...)

Write a hello world mod:

#lang minetest

(define-block hello "Hello" (text "Hello" 24 "red"))

(compile-mod my-mod)

Run it in DrRacket (this compiles the mod). Launch Minetest. Create a world and add the mod named my_racket_mod.

You will find a "Hello" block in your inventory:

Alt text

Current Status

This language gives you ways of converting images into:

  • Blocks
  • Items
  • (Cube shaped) Entities
  • Recipes
  • Particles
  • Schematics

There are currently also a (limited) set of game rules for defining callbacks. Only a few callbacks are currently supported:

  • on_punch for blocks
  • on_drop for blocks
  • on_drop for items

And for each of the above callbacks there is a (limited) set of effects you can trigger:

  • produce particles
  • spawn entity
  • place schematic
  • place block

We'll probably add more in the future.

Further Reading

  • How to Design Programs: 2nd Edition - For an amazing introduction to Racket and the equally amazing image library (2htdp/image). Anything you can create with the 2htdp/image library can be placed into Minetest with #lang minetest. You should learn this first. Most of the power of #lang minetest comes from the power of Racket and 2htdp/image.

  • The docs for #lang minetest - I'm still working on these. If something isn't documented, a good supplement would be the /examples directory.

  • The docs for Minetest modding in Lua - For when you want to do something that #lang minetest doesn't yet support. The compilation process tries to produce readable Lua code. Feel free to edit it after compilation (just remember that it will get overwritten when you compile again -- so you might want to copy the compiled output directory to a new directory).

Authors

  • Stephen R. Foster - Initial work - srfoster