OpenMiner/docs/lua-api-mod.md
2020-04-03 02:34:03 +02:00

1.8 KiB

Lua API: Mod API Overview

Introduction

You can create a mod using this function:

openminer.mod_loader:register_mod("mod_name")

Mod name should match this regex: ^[a-zA-Z0-9_]+$

Everytime you define an id for a mod element, this name will be prepended to it. For example, myitem will become mymod:myitem.

The name can't be group because this namespace is already used by the engine.

Example

local mod = openminer.mod_loader:register_mod("mymod")

mod:block {
	id = "myblock",
	name = "My Block",
	tiles = "myblock.png",
}

mod:item {
	id = "myitem",
	name = "My Item",
	tiles = "myitem.png",
}

mod:crafting_recipe {
	result = {
		id = "mymod:myblock",
		amount = 1
	},

	pattern = {
		"###",
		"# #",
		"###"
	},

	keys = {["#"] = "default:cobblestone"}
}

mod:smelting_recipe {
	input = {id = "mymod:myitem", amount = 1},
	output = {id = "mymod:myblock", amount = 1}
}

Functions

id

Returns the string ID of the mod.

path

Returns the path of the mod, relative to current working directory.

Registration functions

block

Defines a block from a table, see this page for more information.

biome

Defines a biome from a table, see this page for more information.

dimension

Defines a dimension from a table, see this page for more information.

item

Defines an item from a table, see this page for more information.

recipe

Defines a recipe from a table, see this page for more information.

sky

Defines a sky type from a table, see this page for more information.

tree

Defines a tree type from a table, see this page for more information.