New: m7a (API)

m7a (API) 🔗

In this mod I puted API that I missed in Luanti's API (or what I missed in older versions of Minetest), for example my api m7a.get_game_info(), it's almost the same as core.get_game_info(), but with one diference, if you look inside you can see that it checks if this function exist then he just retuns function, but if not, it's take game name by it self. I made this because in Minetest 5.6.1 don't exist this function, so I made this function supported by Minetest 5.6.1 (of course it returns only gameid YET).

function m7a.get_game_info()
if core.get_game_info then return core.get_game_info(); end;
local gameid = settings(worldpath.."/world.mt"):get("gameid");
return { id=gameid, title="", author="", path="" };
end;

And also I made many other functions, like m7a.register_door(name, def), this function supports register "single" and "double door". Another for example is m7a.register_inv_node(name, def), it's allows you to register node with inventory, and it will change node when it's open, it useful for chests, cabinets, and drawers.

I'm planning to make full documentation for this mod, but a little bit latter.

Chat Commands 🔗

/game_id:

Echoes the current game id.

/biome_name:

Echoes the biome name you stand in.

Game 🔗

m7a.get_game_info():

returns { id, title, author, path }.

m7a.get_game_release():

returns game release number.

m7a.impact(default, vars):

returns variable according to the current game.

example:

gold_ingot = m7a.impact(
nil, {
["minetest"] = "default:gold_ingot",
["mineclonia"] = "mcl_core:gold_ingot",
}
);

m7a.mod_impact(default, vars):

returns variable according to the current mods.

m7a.var_impact(equation, var, rtn):

returns variable according to the equation.

m7a.item(items):

returns first registred item from list.

m7a.biome(items):

returns first registred biome from list.

m7a.item_title(title, def):

returns title for item description:

example:

core.register_node("mod:item", {
description = m7a.item_title(S("Item Name"), {
wip = true,
info = S("27 inventory slots."),
extra = S("Right click opens node inventory."),
}),
...
});

m7a.find_biomes_in_area(pos, biomes, radius, height):

returns list of pos with find biomes.

Player 🔗

m7a.get_player_eye_pos(player):

returns player eye position.

m7a.get_player_arm_range(player):

returns current player arm range.

m7a.side_to_yaw(side):

returns yaw from block side.

Inventory 🔗

m7a.get_inventory(pos, [name, size]):

returns node inventory, and creates if not exist (if you set name and size).

m7a.set_inventory(pos, name, size):

sets node inventory.

m7a.add_item_to_inventory(user, item_name, inv_name):

adds itm to the inventory, if not have space drops item beside player/node.

m7a.take_item_if_not_creative(player, itemstack):

takes item from itemstack just like itemstack:take_item(),

but only if it's not creative mode.

m7a.itemstack(item_name[, quantity, itemstack]):

returns itemstack with item inside.

Nodes 🔗

m7a.get_pointed_node(player):

return pointed node with pointed side of block using raycast.

m7a.is_pointing_above_middle(pointer, pointed_thing):

returns true if player clicked node above middle.

m7a.is_pointing_on_left_half(pointer, pointed_thing):

returns true if player clicked node on the left half of side.

m7a.check_on_rightclick(pos, itemstack, placer):

returns nodedef.on_rightclick if node have it.

m7a.on_construct(pos):

returns on_construct function of node.

m7a.node_drop_items(pos[, inv_list]):

drops all items that node have.

m7a.place_item(itemstack, user, pointed_thing[, replacement]):

place item.

m7a.con4block(pos, group, nodes, mode, color):

connecting blocks, it useful for footpaths.

m7a.get_nodes_around_horizontal(pos, group, mode):

returns nodes and node_map around pos.

m7a.get_node_map(pos, map):

returns nodes by map of offsets.

m7a.set_node_map(pos, map):

placed nodes by map of offsets.

Formspec 🔗

m7a.inventory_formspec(pos, clicker, name, stack_id[, return_string]):

show_formspec node inventory, if return_string is true - returns formspec string.

Register 🔗

m7a.register_inv_node(name, def):

register node with inventory.

m7a.register_multinode(name, multidef):

register muntiple nodes with different suffixes.

m7a.register_multideco(name, multidef):

register muntiple decorations at the same time.

m7a.register_door(name, def):

register door node ("single", "double").

example:

m7a.register_door("mod:door", {
single_description = S("Door"),
double_description = S("Double Door"),

single_inv_image = "door_item.png",
double_inv_image = "double_door_item.png",

tiles = { "door_texture.png" },

groups = { node=1, cracky=1, level=2, door=1 },

pos_type = "side", -- "side" or "center"
types = { "single", "double" },

sounds = mod.sound_metal(),
sound_open = "doors_steel_door_open",
sound_close = "doors_steel_door_close",
});

m7a.register_biome(def):

register biome with ("_shore", "_ocean", "_underground", "_deep_underground").

Table 🔗

m7a.table_merge(tbl, tbl2):

merge two tables.

m7a.table_get_keys(tbl):

returns all keys from tables.

m7a.is_in(check, tbl[, in_keys]):

returns true if string exist in table.

String 🔗

m7a.to_name(str):

returns string without "_" and makes words capitalize.

m7a.split(str, sep):

returns array of splitted string.

m7a.spx(str, sep):

splits string on two variables.