Luanti
This is the starting point for this library. With creating a Luanti object you also connect to a Luanti server.
In this object are all functions that targets Luanti itself. There is also some properties inside, to get other objects like players or nodes.
- Example:
>>> from miney import Luanti >>> >>> lt = Luanti() >>> >>> # We set the time to midday. >>> lt.time_of_day = 0.5 >>> >>> # Write to the servers log >>> lt.log("Time is set to midday ...")
- class miney.Luanti([server, playername, password[, port]])[source]
The Miney server object. All other objects are accessable from here. By creating an object you connect to Luanti.
Parameters aren’t required, if you run miney and Luanti on the same computer.
Miney connects as player with the playername you provided and also registers this player to the server with the password.
If you connect with miney the first time to the luanti server outside your computer (something else than 127.0.0.1), you need to give the miney player the “miney” priviledge. Do that by opening the chat (with the T key) and type /priv miney miney (/priv <player_name> <privledge>).
If you connect over LAN or Internet to a Luanti server with installed miney mod, you should use a strong password! The miney mod allows this player to run commands and scripts; this could be abused if you choose a weak password!
>>> lt = Luanti("luantiserver.in.the.internet.com", "ChatBot", "SuperSecretPasswordNobodyWouldKnowCauseItsRandom!")
Account creation is done by starting Luanti and connect to a server with a playername and password. https://docs.luanti.org/for-players/getting-started/#play-online
- Parameters:
- property callbacks: Callback
Provides access to the callback manager.
See
Callbackfor the available methods.
- property chat
Provides access to chat functions.
See
Chatfor a full list of methods.- Example:
>>> lt.chat.send_to_all("My chat message")
- Returns:
- disconnect()[source]
Shuts down all services and disconnects from the Luanti server.
This method automatically unregisters all event callbacks and chat commands before closing the network connection to ensure a clean shutdown. It is called automatically when the object is deleted or when exiting a ‘with’ block.
- property game_info: GameInfo
Get information about the current game.
This property returns an object providing details about the game running on the server.
- Example:
>>> game = lt.game_info >>> print(game.id) 'mineclone2' >>> print(game.title) 'VoxeLibre' >>> print(game['author']) 'Wuzzy'
- Returns:
A
GameInfoobject.
- log(line: str)[source]
Write a line in the servers logfile.
- Parameters:
line – The log line
- Returns:
None
- property lua
Provides access to functions for running raw Lua code on the server.
See
Luafor a full list of methods.- Returns:
- property nodes
Provides access to node manipulation functions.
See
Nodesfor a full list of methods.- Returns:
- off_event(name: str, run: Callable[[Event], None]) None[source]
Unregister a previously registered event callback.
- Parameters:
name – The name of the event the callback is subscribed to.
run – The function reference of the callback to unregister.
- on_event(name: str, run: Callable[[Event], None], parameters: Dict[str, Any] | None = None) None[source]
Register an event callback without using a decorator.
This is a procedural alternative to the
@lt.callbacks.on()decorator.- Parameters:
name – The name of the event to subscribe to (e.g., “chat_message”).
run – The function to execute when the event occurs. It will receive an Event object.
parameters – Optional filters for the event subscription.
- property players: PlayerIterable
Provides access to online players.
This property returns an iterable object that allows access to individual
Playerinstances.- Examples:
Make a player 5 times faster:
>>> lt.players.MyPlayername.speed = 5
Get a list of all players:
>>> list(lt.players) [<Luanti Player "MineyPlayer">, <Luanti Player "SecondPlayer">, ...]
- Returns:
An iterable object for players.
- property settings: dict
Receive all server settings defined in “minetest.conf”.
- Returns:
A dict with all non-default settings.
- property time_of_day: int
Get and set the time of the day between 0 and 1, where 0 stands for midnight, 0.5 for midday.
- Returns:
time of day as float.
- property tool: ToolIterable
Provides an iterable helper for accessing all available tool types.
This is a shortcut for getting tool item strings with IDE auto-completion. See
ToolIterablefor more details.- Examples:
>>> lt.tool.default.pick_mese 'default:pick_mese'
>>> lt.players[0].inventory.add(lt.tool.default.pick_diamond, 1)
- Returns:
An iterable object for tool types.
Related Data Structures
- class miney.luanti.GameInfo(id: str, title: str, author: str, path: str)[source]
Holds information about the current game.
This dataclass provides both attribute-style and dictionary-style access to the game’s properties.
API Components
All interaction with the game world starts with the Luanti object. The following pages document the major classes and components that are accessed through the Luanti object and its properties.