Compare commits

...

21 Commits
1.5 ... 1.6

Author SHA1 Message Date
d324c5f1e5 Progressive mode: Add a Steam-like HUD success + remove useless API functions 2019-08-30 17:05:03 +02:00
dfa45789e2 Style cleaning 2019-08-29 15:41:32 +02:00
80a0d67f15 Ability to register recipes in MC-like way 2019-08-29 14:56:53 +02:00
22c5c9444e Interpret group value 0 as "not in group".
This fixes instances where items are counted as part of a group by
craftguide but not by the engine.
2019-08-29 14:47:19 +02:00
97676d094e Fix possible crash 2019-06-30 19:42:32 +02:00
ca18ae0e3a Fix nil item crash in get_tooltip() - Fixes #84, regression caused by d950c71db (@pauloue) 2019-06-30 16:37:09 +02:00
e710fcd483 Small optimization 2019-06-23 01:42:12 +02:00
a2e4f20791 Items with no recipes but with usages are shown 2019-06-23 01:25:18 +02:00
22a85f50c1 Sugar 2019-05-08 20:57:45 +02:00
0271f61fc2 Change tooltip format 2019-03-21 17:44:32 +01:00
84756af3a1 Opens the stereotypes to the API 2019-03-21 17:34:20 +01:00
9dc656d5a2 Fix broken assert() 2019-03-21 00:21:11 +01:00
4c0371c5cc Progressive mode: Fix crash on player leaving 2019-03-14 14:11:44 +01:00
b6181ebd7a Minor cleanup 2019-03-13 16:56:35 +01:00
eb7292da7a 2×2 for shapeless recipe w/ <= 4 items 2019-03-13 15:22:45 +01:00
9df355b899 Add more assert checks 2019-03-12 16:54:26 +01:00
a242f6c61c Revert some changes 2019-03-11 03:01:37 +01:00
c9ebd5c069 Cleanup 2019-03-10 16:27:36 +01:00
054a7ab3af Update russian translations 2019-03-07 13:47:41 +01:00
b1a67eb632 Add examples in doc 2019-03-07 13:43:47 +01:00
e0e57b45ea Quick fix 2019-03-04 01:19:13 +01:00
4 changed files with 407 additions and 300 deletions

View File

@ -2,6 +2,7 @@ unused_args = false
allow_defined_top = true allow_defined_top = true
read_globals = { read_globals = {
"core",
"minetest", "minetest",
"default", "default",
"sfinv", "sfinv",

81
API.md
View File

@ -11,17 +11,35 @@ craftguide.register_craft_type("digging", {
}) })
``` ```
#### Registering a custom crafting recipe (example) #### Registering a custom crafting recipe (examples)
```Lua ```Lua
craftguide.register_craft({ craftguide.register_craft({
type = "digging", type = "digging",
width = 1, width = 1,
output = "default:cobble 2", result = "default:cobble 2",
items = {"default:stone"}, items = {"default:stone"},
}) })
``` ```
Recipes can also be registered in a Minecraft-like way:
```Lua
craftguide.register_craft({
grid = {
"X #",
" ## ",
"X#X#",
"X X",
},
key = {
['#'] = "default:wood",
['X'] = "default:glass",
},
result = "default:mese 3",
})
```
--- ---
### Recipe filters ### Recipe filters
@ -70,10 +88,15 @@ Returns a map of recipe filters, indexed by name.
Search filters are used to perform specific searches inside the search field. Search filters are used to perform specific searches inside the search field.
They can be used like so: `<optional name>+<filter name>=<value1>,<value2>,<...>` They can be used like so: `<optional name>+<filter name>=<value1>,<value2>,<...>`
Examples:
- `+groups=cracky,crumbly`: search for groups `cracky` and `crumbly` in all items.
- `sand+groups=falling_node`: search for group `falling_node` for items which contain `sand` in their names.
Notes: Notes:
- If `optional name` is omitted, the search filter will apply to all items, without pre-filtering. - If `optional name` is omitted, the search filter will apply to all items, without pre-filtering.
- Filters can be combined. - Filters can be combined.
- The `+groups=` filter is currently implemented by default. - The `groups` filter is currently implemented by default.
#### `craftguide.add_search_filter(name, function(item, values))` #### `craftguide.add_search_filter(name, function(item, values))`
@ -114,49 +137,6 @@ Returns a map of search filters, indexed by name.
--- ---
### Custom formspec elements
#### `craftguide.add_formspec_element(name, def)`
Adds a formspec element to the current formspec.
Supported types: `box`, `label`, `image`, `button`, `tooltip`, `item_image`, `image_button`, `item_image_button`
Example:
```lua
craftguide.add_formspec_element("export", {
type = "button",
element = function(data)
-- Should return a table of parameters according to the formspec element type.
-- Note: for all buttons, the 'name' parameter *must not* be specified!
if data.recipes then
return {
data.iX - 3.7, -- X
sfinv_only and 7.9 or 8, -- Y
1.6, -- W
1, -- H
ESC(S("Export")) -- label
}
end
end,
-- Optional.
action = function(player, data)
-- When the button is pressed.
print("Exported!")
end
})
```
#### `craftguide.remove_formspec_element(name)`
Removes the formspec element with the given name.
#### `craftguide.get_formspec_elements()`
Returns a map of formspec elements, indexed by name.
---
### Miscellaneous ### Miscellaneous
#### `craftguide.show(player_name, item, show_usages)` #### `craftguide.show(player_name, item, show_usages)`
@ -166,3 +146,12 @@ Opens the Crafting Guide with the current filter applied.
* `player_name`: string param. * `player_name`: string param.
* `item`: optional, string param. If set, this item is pre-selected. If the item does not exist or has no recipe, use the player's previous selection. By default, player's previous selection is used * `item`: optional, string param. If set, this item is pre-selected. If the item does not exist or has no recipe, use the player's previous selection. By default, player's previous selection is used
* `show_usages`: optional, boolean param. If true, show item usages. * `show_usages`: optional, boolean param. If true, show item usages.
#### `craftguide.group_stereotypes`
This is the table indexing the item groups by stereotypes.
You can add a stereotype like so:
```Lua
craftguide.group_stereotypes.radioactive = "mod:item"
```

609
init.lua

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
Craft Guide=книга рецептов крафта Craft Guide=книга рецептов крафта
Crafting Guide=книга рецептов крафта Crafting Guide=книга рецептов крафта
Crafting Guide Sign= Crafting Guide Sign=Знак с книгой рецептов
Search=Поиск Search=Поиск
Reset=Сброс Reset=Сброс
Previous page=Предыдущая страница Previous page=Предыдущая страница
@ -13,13 +13,13 @@ Burning time: @1=Время горения: @1
Cooking time: @1=Время преготовления: @1 Cooking time: @1=Время преготовления: @1
Any item belonging to the group(s): @1=Любой элемент из группы: @1 Any item belonging to the group(s): @1=Любой элемент из группы: @1
Recipe is too big to be displayed (@1x@2)=Рецепт слишком большой для показа (@1x@2) Recipe is too big to be displayed (@1x@2)=Рецепт слишком большой для показа (@1x@2)
Shapeless= Shapeless=Бесформенный
Cooking= Cooking=Приготовление
Increase window size=Увеличить окно Increase window size=Увеличить окно
Decrease window size=Уменьшить окно Decrease window size=Уменьшить окно
No item to show=Нет элемента для показа No item to show=Нет элемента для показа
Collect items to reveal more recipes= Collect items to reveal more recipes=Собирайте предметы, чтобы раскрыть больше рецептов
Show recipe(s) of the pointed node= Show recipe(s) of the pointed node=Показать рецепт(ы) выбранной ноды
No node pointed= No node pointed=Не указана нода
You don't know a recipe for this node= You don't know a recipe for this node=Вы не знаете рецепт для этой ноды
No recipe for this node= No recipe for this node=Нет рецептов для этой ноды