API Cleanup
This commit is contained in:
parent
853ddc9d94
commit
8cd04deff4
32
API.md
32
API.md
|
@ -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`.
|
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)
|
#### Registering a custom crafting recipe (examples)
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
type = "digging",
|
type = "digging",
|
||||||
result = "default:cobble 2",
|
result = "default:cobble 2",
|
||||||
items = {"default:stone"},
|
items = {"default:stone"},
|
||||||
})
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
result = "default:cobble 16",
|
result = "default:cobble 16",
|
||||||
items = {
|
items = {
|
||||||
"default:stone, default:stone, default:stone",
|
"default:stone, default:stone, default:stone",
|
||||||
"default:stone, , default:stone",
|
"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:
|
Recipes can be registered in a Minecraft-like way:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
|
@ -114,13 +114,13 @@ i3.register_craft({
|
||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Multiples recipes can also be registered:
|
Multiples recipes can also be registered:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
{
|
{
|
||||||
result = "default:mese",
|
result = "default:mese",
|
||||||
items = {
|
items = {
|
||||||
|
@ -138,15 +138,15 @@ i3.register_craft({
|
||||||
"default:mese_crystal, default:mese_crystal",
|
"default:mese_crystal, default:mese_crystal",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Recipes can be registered from a given URL containing a JSON file (HTTP support is required¹):
|
Recipes can be registered from a given URL containing a JSON file (HTTP support is required¹):
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
url = "https://raw.githubusercontent.com/minetest-mods/i3/main/tests/test_online_recipe.json"
|
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.
|
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`
|
#### `i3.recipe_filters`
|
||||||
|
|
||||||
A map of recipe filters, indexed by name.
|
A map of recipe filters, indexed by name.
|
||||||
|
@ -229,10 +225,6 @@ i3.add_search_filter("types", function(item, drawtypes)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.remove_search_filter(name)`
|
|
||||||
|
|
||||||
Removes the search filter with the given `name`.
|
|
||||||
|
|
||||||
#### `i3.search_filters`
|
#### `i3.search_filters`
|
||||||
|
|
||||||
A map of search filters, indexed by name.
|
A map of search filters, indexed by name.
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
local modpath = core.get_modpath "i3"
|
|
||||||
local item_compression = core.settings:get_bool("i3_item_compression", true)
|
local item_compression = core.settings:get_bool("i3_item_compression", true)
|
||||||
local reg_items, translate = core.registered_items, core.get_translated_string
|
local reg_items, translate = core.registered_items, core.get_translated_string
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ local HUD_TIMER_MAX = 1.5
|
||||||
|
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i3.set_fs
|
||||||
local modpath = core.get_modpath "i3"
|
local modpath = core.get_modpath "i3"
|
||||||
|
|
||||||
local search, table_merge, is_group, extract_groups, item_has_groups, apply_recipe_filters =
|
local search, table_merge, is_group, extract_groups, item_has_groups, apply_recipe_filters =
|
||||||
unpack(dofile(modpath .. "/etc/common.lua").progressive)
|
unpack(dofile(modpath .. "/etc/common.lua").progressive)
|
||||||
|
|
||||||
|
|
7
init.lua
7
init.lua
|
@ -184,8 +184,7 @@ local function get_formspec_version(info)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function outdated(name)
|
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]",
|
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]",
|
||||||
"i3_book.png",
|
|
||||||
"Your Minetest client is outdated.\nGet the latest version on minetest.net to play the game.")
|
"Your Minetest client is outdated.\nGet the latest version on minetest.net to play the game.")
|
||||||
|
|
||||||
core.show_formspec(name, "i3_outdated", fs)
|
core.show_formspec(name, "i3_outdated", fs)
|
||||||
|
@ -338,10 +337,6 @@ function i3.set_recipe_filter(name, f)
|
||||||
i3.recipe_filters = {[name] = f}
|
i3.recipe_filters = {[name] = f}
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.remove_recipe_filter(name)
|
|
||||||
i3.recipe_filters[name] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function i3.add_search_filter(name, f)
|
function i3.add_search_filter(name, f)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.add_search_filter: name missing"
|
return err "i3.add_search_filter: name missing"
|
||||||
|
|
Ŝarĝante…
Reference in New Issue