Lua API overview
Plextoria mods run inside the standard Minetest Lua sandbox on engine version 5.7.0. The full Minetest Lua API is available to your mod within the limits described on the Restrictions page.
Responding to events
-- Player joins
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
minetest.chat_send_player(name, "Hello, " .. name .. "!")
end)
-- Player leaves
minetest.register_on_leaveplayer(function(player, timed_out)
local name = player:get_player_name()
minetest.chat_send_all(name .. " left the world.")
end)
-- Player dies
minetest.register_on_dieplayer(function(player, reason)
local name = player:get_player_name()
minetest.chat_send_all(name .. " died.")
end)
Chat commands
minetest.register_chatcommand("hello", {
description = "Say hello",
func = function(name, param)
minetest.chat_send_player(name, "Hello, " .. name .. "!")
return true
end,
})
Registering a node
minetest.register_node("my_mod:glowstone", {
description = "Glowstone",
tiles = { "my_mod_glowstone.png" },
light_source = 14,
groups = { cracky = 3 },
})
HUD elements
minetest.register_on_joinplayer(function(player)
player:hud_add({
hud_elem_type = "text",
position = { x = 0.5, y = 0.1 },
text = "Welcome to my world!",
number = 0xf97316,
scale = { x = 100, y = 100 },
})
end)
Full API reference
The complete Minetest 5.7 Lua API is documented at lua_api.md on GitHub. Everything in that reference is available to your mod except the functions listed on the Restrictions page.