API Cleanup

This commit is contained in:
Jean-Patrick Guerrero 2021-10-19 03:56:37 +02:00
parent 853ddc9d94
commit 8cd04deff4
4 changed files with 14 additions and 27 deletions

32
API.md
View File

@ -55,9 +55,9 @@ Sets the current tab by name. `player` is an `ObjectRef` to the user.
Overrides a tab by name. `def` is the tab definition like seen in `i3.set_tab`.
#### `i3.get_tabs()`
#### `i3.tabs`
Returns the list of registered tabs.
A list of registered tabs.
---
@ -81,28 +81,28 @@ i3.register_craft_type("digging", {
#### Registering a custom crafting recipe (examples)
```Lua
i3.register_craft({
i3.register_craft {
type = "digging",
result = "default:cobble 2",
items = {"default:stone"},
})
}
```
```Lua
i3.register_craft({
i3.register_craft {
result = "default:cobble 16",
items = {
"default:stone, default:stone, default:stone",
"default:stone, , default:stone",
"default:stone, default:stone, default:stone",
}
})
}
```
Recipes can be registered in a Minecraft-like way:
```Lua
i3.register_craft({
i3.register_craft {
grid = {
"X #",
" ## ",
@ -114,13 +114,13 @@ i3.register_craft({
['X'] = "default:glass",
},
result = "default:mese 3",
})
}
```
Multiples recipes can also be registered:
```Lua
i3.register_craft({
i3.register_craft {
{
result = "default:mese",
items = {
@ -138,15 +138,15 @@ i3.register_craft({
"default:mese_crystal, default:mese_crystal",
}
},
})
}
```
Recipes can be registered from a given URL containing a JSON file (HTTP support is required¹):
```Lua
i3.register_craft({
i3.register_craft {
url = "https://raw.githubusercontent.com/minetest-mods/i3/main/tests/test_online_recipe.json"
})
}
```
---
@ -182,10 +182,6 @@ end)
Removes all recipe filters and adds a new one.
#### `i3.remove_recipe_filter(name)`
Removes the recipe filter with the given `name`.
#### `i3.recipe_filters`
A map of recipe filters, indexed by name.
@ -229,10 +225,6 @@ i3.add_search_filter("types", function(item, drawtypes)
end)
```
#### `i3.remove_search_filter(name)`
Removes the search filter with the given `name`.
#### `i3.search_filters`
A map of search filters, indexed by name.

View File

@ -1,4 +1,3 @@
local modpath = core.get_modpath "i3"
local item_compression = core.settings:get_bool("i3_item_compression", true)
local reg_items, translate = core.registered_items, core.get_translated_string

View File

@ -3,6 +3,7 @@ local HUD_TIMER_MAX = 1.5
local set_fs = i3.set_fs
local modpath = core.get_modpath "i3"
local search, table_merge, is_group, extract_groups, item_has_groups, apply_recipe_filters =
unpack(dofile(modpath .. "/etc/common.lua").progressive)

View File

@ -184,8 +184,7 @@ local function get_formspec_version(info)
end
local function outdated(name)
local fs = fmt("size[6.3,1.3]image[0,0;1,1;%s]label[1,0;%s]button_exit[2.6,0.8;1,1;;OK]",
"i3_book.png",
local fs = fmt("size[6.3,1.3]image[0,0;1,1;i3_book.png]label[1,0;%s]button_exit[2.6,0.8;1,1;;OK]",
"Your Minetest client is outdated.\nGet the latest version on minetest.net to play the game.")
core.show_formspec(name, "i3_outdated", fs)
@ -338,10 +337,6 @@ function i3.set_recipe_filter(name, f)
i3.recipe_filters = {[name] = f}
end
function i3.remove_recipe_filter(name)
i3.recipe_filters[name] = nil
end
function i3.add_search_filter(name, f)
if not true_str(name) then
return err "i3.add_search_filter: name missing"