

More thorough intro into Minetest moddingĪn essential resource for any mod author.Quite a basic intro into Minetest modding,.That I used to learn the language myself. set_node ( pos, b ) end end end References width do p = img : getPixel ( z, x ) h = get_height ( p ) for y = 1, h do pos = minetest. height then local p = img : getPixel ( z, x + 1 ) if is_water ( p ) then return true end end return false end local function generate_blocks ( img ) clean () for x = 1, img. R = 100 end local function get_height ( px ) if is_water ( px ) then return 2 end local b = get_lum ( px ) return math.floor ( b / 10 ) + 3 end local function near_water ( img, z, x ) if z > 1 then local p = img : getPixel ( z - 1, x ) if is_water ( p ) then return true end end if z 1 then local p = img : getPixel ( z, x - 1 ) if is_water ( p ) then return true end end if x < img. Greens: (113, 245, 80), (54, 173, 80), (83, 204, 128).Īs an easily explainable solution (remember, this had to be parseable by anĨ-year-old), I chose this solution: local function is_grass ( px ) return px. Usually different for even nearby green pixels. They are written in Lua using Minetests modding API.
MINETEST MODDING API MODS
Mods : What all games consist of, or can be added on top of an existing game. minetestgame: Repository name of Minetest Game and technical name of the game. There’s quite a bit of explanation involved in determining color of a pixel.Īfter all, we see it as green, while the program sees a tuple of numbers, Minetest Game (abbreviated MTG): The name of the default game that is shipped with Minetest. What to do when the color is neither green nor blue? We chose to place stoneīlocks in those places in real examples, those appeared where we darkened the We decided that water should always be at the “sea level”, so we ignoreīrightness of blue pixels and set it to be 2. Places blocks of dirt from 1 to the calculated height, followed by a blockĬhosen depending on the color of the corresponding pixel - water or grass. Gives a nice max hills height of 25 blocks, so there should be a loop that The algorithm is quite simple really: for each pixel of the original image,ĭetermine its color (blue or green) and brightness. Program that my daughter actually wrote herself turned out to be less than 100īy that time, we had mastered loops and tables and the project seemed doable. (painted blue) and grass (painted green). Hand-drawn map, where height is represented by brightness, there’s water

We chose this project: a mod that is capable of generating a world out of a Its licensed under the GNU LGPL 2.1, with artwork generally covered by CC BY-SA 3.0. Had large enough community, and mods in Lua Minetest is a game engine inspired by Minecraft, Infiniminer and others. Minetest that appeared to be quite like Minecraft, So instead, I started looking for an open-sourceĪlternative, found a few and decided to use Mod, but that turned out to be hard and borderline illegal due to decompilation

Since my daughter liked playing Minecraft, we thought of doing something like a Teaching programming with Lua: a Minetest mod
