1.4 KiB
1.4 KiB
Lua API: Core API
Attributes
openminer.registry
Registry
instance of the server. See C++ classes in lua#Registry for more details.
openminer.mod_loader
Mod loader instance in the server. See C++ classes in lua#ServerModLoader for more details.
Functions
openminer:add_listener(event_type, listener)
Adds a listener to a specific type of event.
Example:
openminer:add_listener(Event.BlockPlaced, function(pos, block, player, world, client, server)
server:send_chat_message(0, "Block placed at " .. pos.x .. ";" .. pos.y .. ";" .. pos.z .. " by Client" .. player:client_id(), client);
end)
openminer:add_listener(Event.BlockDigged, function(pos, block, player, world, client, server)
server:send_chat_message(0, "Block digged at " .. pos.x .. ";" .. pos.y .. ";" .. pos.z .. " by Client" .. player:client_id(), client);
end)
openminer:add_listener(Event.BlockActivated, function(pos, block, player, world, client, server)
if block:string_id() == "default:portal" then
server:send_chat_message(0, "Swoosh! Changing dimension...", client);
end
end)
Possible events:
BlockPlaced
:funcion(pos, block, player, world, client, server)
BlockDigged
:funcion(pos, block, player, world, client, server)
BlockActivated
:function(pos, block, player, world, client, server)
PlayerConnected
:function(pos, player, client, server)