-
Notifications
You must be signed in to change notification settings - Fork 9
Modding API
TurtleMiner provides a public API for registering, interacting with, controlling, and tracking turtles.
There are two main formspecs each with their own functions and are used for the same turtles at different stages.
Func: turtleminer.show_naming_formspec(name, t_id)
Show the naming formspec to allow a player to name the turtle. t_id
must be the ID of a valid turtle, otherwise when the player submits a name, the operation will fail and send send the player a message in chat. The formspec uses this ID provided to recognize the turtle when parameters are received back.
Func: turtleminer.show_main_formspec(name, pos)
Show the main formspec allowing a player to interact with the turtle. This is the formspec used for all turtles, and requires the player name
(i.e. playerobject:get_player_name()
) to which the form must be shown, and the pos
(i.e. position) of the turtle (note: not the t_id
).
Usage:
turtleminer.register_turtle("turtlestring", {
description = "",
tiles = {},
nodebox = {},
})
As seen above, the process is almost identical to registering a normal node with minetest.register_node
but with added fields specific to turtles. The first parameter, turtlestring
, is like the normal itemstring
used with the normal register_node
function. However, unlike register_node
, no mod name is needed, but just the "codename" for the new turtle (e.g. tech_turtle
). description
is a string variable storing the description of the turtle node for use in the tooltip. tiles
is a table storing the texture names as strings in the default format (see this for info on registering basic nodes). nodebox
is a table allowing you to make a turtle that is not cubic (see this for info on the nodebox drawtype).