Rename fork to i4
Now that the API is actually changing, it seems like a good point to rename the fork.
This commit is contained in:
parent
c211c79169
commit
2b3df66a7d
110
API.md
110
API.md
|
@ -16,15 +16,15 @@
|
||||||
|
|
||||||
### Tabs
|
### Tabs
|
||||||
|
|
||||||
#### `i3.new_tab(name, def)`
|
#### `i4.new_tab(name, def)`
|
||||||
|
|
||||||
- `name` is the tab name.
|
- `name` is the tab name.
|
||||||
- `def` is the tab definition.
|
- `def` is the tab definition.
|
||||||
|
|
||||||
Custom tabs can be added to the `i3` inventory as follow (example):
|
Custom tabs can be added to the `i4` inventory as follow (example):
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.new_tab("stuff", {
|
i4.new_tab("stuff", {
|
||||||
description = "Stuff",
|
description = "Stuff",
|
||||||
image = "image.png", -- Optional, add an image next to the tab description
|
image = "image.png", -- Optional, add an image next to the tab description
|
||||||
slots = true -- Optional, whether the inventory slots are shown or not. Disabled by default.
|
slots = true -- Optional, whether the inventory slots are shown or not. Disabled by default.
|
||||||
|
@ -62,28 +62,28 @@ i3.new_tab("stuff", {
|
||||||
- `data` are the user data.
|
- `data` are the user data.
|
||||||
- `fs` is the formspec table which is callable with a metamethod. Every call adds a new entry.
|
- `fs` is the formspec table which is callable with a metamethod. Every call adds a new entry.
|
||||||
|
|
||||||
#### `i3.set_fs(player)`
|
#### `i4.set_fs(player)`
|
||||||
|
|
||||||
Update the current formspec.
|
Update the current formspec.
|
||||||
|
|
||||||
#### `i3.remove_tab(tabname)`
|
#### `i4.remove_tab(tabname)`
|
||||||
|
|
||||||
Delete a tab by name.
|
Delete a tab by name.
|
||||||
|
|
||||||
#### `i3.get_current_tab(player)`
|
#### `i4.get_current_tab(player)`
|
||||||
|
|
||||||
Return the current player tab. `player` is an `ObjectRef` to the user.
|
Return the current player tab. `player` is an `ObjectRef` to the user.
|
||||||
|
|
||||||
#### `i3.set_tab(player[, tabname])`
|
#### `i4.set_tab(player[, tabname])`
|
||||||
|
|
||||||
Set the current tab by name. `player` is an `ObjectRef` to the user.
|
Set the current tab by name. `player` is an `ObjectRef` to the user.
|
||||||
`tabname` can be omitted to get an empty tab.
|
`tabname` can be omitted to get an empty tab.
|
||||||
|
|
||||||
#### `i3.override_tab(tabname, def)`
|
#### `i4.override_tab(tabname, def)`
|
||||||
|
|
||||||
Override a tab by name. `def` is the tab definition like seen in `i3.set_tab`
|
Override a tab by name. `def` is the tab definition like seen in `i4.set_tab`
|
||||||
|
|
||||||
#### `i3.tabs`
|
#### `i4.tabs`
|
||||||
|
|
||||||
A list of registered tabs.
|
A list of registered tabs.
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ A list of registered tabs.
|
||||||
|
|
||||||
### Footer buttons
|
### Footer buttons
|
||||||
|
|
||||||
`i3.new_footer_button(name, def)`
|
`i4.new_footer_button(name, def)`
|
||||||
|
|
||||||
* `name` is the footer button’s name.
|
* `name` is the footer button’s name.
|
||||||
* `def` is the button defintion.
|
* `def` is the button defintion.
|
||||||
|
@ -99,7 +99,7 @@ A list of registered tabs.
|
||||||
Custom footer buttons can be added beside the trash, sort, and settings buttons. For example:
|
Custom footer buttons can be added beside the trash, sort, and settings buttons. For example:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.new_footer_button("broadcast_msg", {
|
i4.new_footer_button("broadcast_msg", {
|
||||||
description = "Broadcast message",
|
description = "Broadcast message",
|
||||||
image = "speech_icon.png", -- Required, this is the button’s icon.
|
image = "speech_icon.png", -- Required, this is the button’s icon.
|
||||||
|
|
||||||
|
@ -114,14 +114,14 @@ i3.new_footer_button("broadcast_msg", {
|
||||||
|
|
||||||
-- Build the formspec
|
-- Build the formspec
|
||||||
formspec = function(player, data, fs)
|
formspec = function(player, data, fs)
|
||||||
-- Button style nicked from i3 directly.
|
-- Button style nicked from i4 directly.
|
||||||
fs([[
|
fs([[
|
||||||
style[send_msg_button,confirm_trash_no,set_home;noclip=true;font_size=16;
|
style[send_msg_button,confirm_trash_no,set_home;noclip=true;font_size=16;
|
||||||
bgimg=i3_btn9.png;bgimg_hovered=i3_btn9_hovered.png;
|
bgimg=i4_btn9.png;bgimg_hovered=i4_btn9_hovered.png;
|
||||||
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6]
|
bgimg_pressed=i4_btn9_pressed.png;bgimg_middle=4,6]
|
||||||
]])
|
]])
|
||||||
|
|
||||||
fs("image[5,10.65;3,0.5;i3_bg_goto.png]")
|
fs("image[5,10.65;3,0.5;i4_bg_goto.png]")
|
||||||
fs("field[5,10.65;3,0.5;chat_msg_field;;]")
|
fs("field[5,10.65;3,0.5;chat_msg_field;;]")
|
||||||
fs("button[8,10.65;1,0.5;send_msg_button;Send]")
|
fs("button[8,10.65;1,0.5;send_msg_button;Send]")
|
||||||
-- No need to return anything
|
-- No need to return anything
|
||||||
|
@ -137,15 +137,15 @@ i3.new_footer_button("broadcast_msg", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
#### `i3.remove_footer_button(button_name)`
|
#### `i4.remove_footer_button(button_name)`
|
||||||
|
|
||||||
Delete a footer button by name.
|
Delete a footer button by name.
|
||||||
|
|
||||||
#### `i3.override_footer_button(button_name, def)`
|
#### `i4.override_footer_button(button_name, def)`
|
||||||
|
|
||||||
Override a footer button by name. `def` is the button definition like seen in `i3.new_footer_button`
|
Override a footer button by name. `def` is the button definition like seen in `i4.new_footer_button`
|
||||||
|
|
||||||
#### `i3.footer_buttons`
|
#### `i4.footer_buttons`
|
||||||
|
|
||||||
A list of registered footer buttons.
|
A list of registered footer buttons.
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ Examples:
|
||||||
#### Registering a custom crafting type
|
#### Registering a custom crafting type
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft_type("digging", {
|
i4.register_craft_type("digging", {
|
||||||
description = "Digging",
|
description = "Digging",
|
||||||
icon = "default_tool_steelpick.png",
|
icon = "default_tool_steelpick.png",
|
||||||
})
|
})
|
||||||
|
@ -171,7 +171,7 @@ i3.register_craft_type("digging", {
|
||||||
#### Registering a custom crafting recipe
|
#### Registering a custom crafting recipe
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft {
|
i4.register_craft {
|
||||||
type = "digging",
|
type = "digging",
|
||||||
result = "default:cobble 2",
|
result = "default:cobble 2",
|
||||||
items = {"default:stone"},
|
items = {"default:stone"},
|
||||||
|
@ -179,7 +179,7 @@ i3.register_craft {
|
||||||
```
|
```
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft {
|
i4.register_craft {
|
||||||
result = "default:cobble 16",
|
result = "default:cobble 16",
|
||||||
items = {
|
items = {
|
||||||
"default:stone, default:stone, default:stone",
|
"default:stone, default:stone, default:stone",
|
||||||
|
@ -192,7 +192,7 @@ i3.register_craft {
|
||||||
Recipes can be registered in a Minecraft-like way:
|
Recipes can be registered in a Minecraft-like way:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft {
|
i4.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
|
@ -210,7 +210,7 @@ i3.register_craft {
|
||||||
Multiple recipes can also be registered at once:
|
Multiple recipes can also be registered at once:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.register_craft {
|
i4.register_craft {
|
||||||
{
|
{
|
||||||
result = "default:mese",
|
result = "default:mese",
|
||||||
items = {
|
items = {
|
||||||
|
@ -234,8 +234,8 @@ i3.register_craft {
|
||||||
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 {
|
i4.register_craft {
|
||||||
url = "https://raw.githubusercontent.com/minetest-mods/i3/main/tests/test_online_recipe.json"
|
url = "https://raw.githubusercontent.com/minetest-mods/i4/main/tests/test_online_recipe.json"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ i3.register_craft {
|
||||||
Manage the tabs on the right panel of the inventory.
|
Manage the tabs on the right panel of the inventory.
|
||||||
Allow to make a sensible list sorted by specific groups of items.
|
Allow to make a sensible list sorted by specific groups of items.
|
||||||
|
|
||||||
#### `i3.new_minitab(name, def)`
|
#### `i4.new_minitab(name, def)`
|
||||||
|
|
||||||
Add a new minitab (limited to 6).
|
Add a new minitab (limited to 6).
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ Add a new minitab (limited to 6).
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.new_minitab("test", {
|
i4.new_minitab("test", {
|
||||||
description = "Test",
|
description = "Test",
|
||||||
|
|
||||||
-- Whether this tab is visible or not. Optional.
|
-- Whether this tab is visible or not. Optional.
|
||||||
|
@ -276,13 +276,13 @@ i3.new_minitab("test", {
|
||||||
- `data` are the user data.
|
- `data` are the user data.
|
||||||
- `item` is an item name string.
|
- `item` is an item name string.
|
||||||
|
|
||||||
#### `i3.remove_minitab(name)`
|
#### `i4.remove_minitab(name)`
|
||||||
|
|
||||||
Remove a minitab by name.
|
Remove a minitab by name.
|
||||||
|
|
||||||
- `name` is the name of the tab to remove.
|
- `name` is the name of the tab to remove.
|
||||||
|
|
||||||
#### `i3.minitabs`
|
#### `i4.minitabs`
|
||||||
|
|
||||||
A list of registered minitabs.
|
A list of registered minitabs.
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ A list of registered minitabs.
|
||||||
Recipe filters can be used to filter the recipes shown to players. Progressive
|
Recipe filters can be used to filter the recipes shown to players. Progressive
|
||||||
mode is implemented as a recipe filter.
|
mode is implemented as a recipe filter.
|
||||||
|
|
||||||
#### `i3.add_recipe_filter(name, function(recipes, player))`
|
#### `i4.add_recipe_filter(name, function(recipes, player))`
|
||||||
|
|
||||||
Add a recipe filter with the given `name`. The filter function returns the
|
Add a recipe filter with the given `name`. The filter function returns the
|
||||||
recipes to be displayed, given the available recipes and an `ObjectRef` to the
|
recipes to be displayed, given the available recipes and an `ObjectRef` to the
|
||||||
|
@ -303,7 +303,7 @@ user. Each recipe is a table of the form returned by
|
||||||
Example function to hide recipes for items from a mod called "secretstuff":
|
Example function to hide recipes for items from a mod called "secretstuff":
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
i3.add_recipe_filter("Hide secretstuff", function(recipes)
|
i4.add_recipe_filter("Hide secretstuff", function(recipes)
|
||||||
local filtered = {}
|
local filtered = {}
|
||||||
for _, recipe in ipairs(recipes) do
|
for _, recipe in ipairs(recipes) do
|
||||||
if recipe.output:sub(1,12) ~= "secretstuff:" then
|
if recipe.output:sub(1,12) ~= "secretstuff:" then
|
||||||
|
@ -315,11 +315,11 @@ i3.add_recipe_filter("Hide secretstuff", function(recipes)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.set_recipe_filter(name, function(recipe, player))`
|
#### `i4.set_recipe_filter(name, function(recipe, player))`
|
||||||
|
|
||||||
Remove all recipe filters and add a new one.
|
Remove all recipe filters and add a new one.
|
||||||
|
|
||||||
#### `i3.recipe_filters`
|
#### `i4.recipe_filters`
|
||||||
|
|
||||||
A map of recipe filters, indexed by name.
|
A map of recipe filters, indexed by name.
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ 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.
|
||||||
- The `+groups` filter is currently implemented by default.
|
- The `+groups` filter is currently implemented by default.
|
||||||
|
|
||||||
#### `i3.add_search_filter(name, function(item, values))`
|
#### `i4.add_search_filter(name, function(item, values))`
|
||||||
|
|
||||||
Add a search filter.
|
Add a search filter.
|
||||||
The search function must return a boolean value (whether the given item should be listed or not).
|
The search function must return a boolean value (whether the given item should be listed or not).
|
||||||
|
@ -352,7 +352,7 @@ The search function must return a boolean value (whether the given item should b
|
||||||
Example function sorting items by drawtype:
|
Example function sorting items by drawtype:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
i3.add_search_filter("types", function(item, drawtypes)
|
i4.add_search_filter("types", function(item, drawtypes)
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
||||||
for i, dt in ipairs(drawtypes) do
|
for i, dt in ipairs(drawtypes) do
|
||||||
|
@ -365,7 +365,7 @@ i3.add_search_filter("types", function(item, drawtypes)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.search_filters`
|
#### `i4.search_filters`
|
||||||
|
|
||||||
A map of search filters, indexed by name.
|
A map of search filters, indexed by name.
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ A map of search filters, indexed by name.
|
||||||
|
|
||||||
Sorting methods are used to filter the player's main inventory.
|
Sorting methods are used to filter the player's main inventory.
|
||||||
|
|
||||||
#### `i3.add_sorting_method(name, def)`
|
#### `i4.add_sorting_method(name, def)`
|
||||||
|
|
||||||
Add a player inventory sorting method.
|
Add a player inventory sorting method.
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ Add a player inventory sorting method.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.add_sorting_method("test", {
|
i4.add_sorting_method("test", {
|
||||||
description = "Cool sorting method",
|
description = "Cool sorting method",
|
||||||
func = function(list, data)
|
func = function(list, data)
|
||||||
-- `list`: inventory list
|
-- `list`: inventory list
|
||||||
|
@ -400,7 +400,7 @@ i3.add_sorting_method("test", {
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.sorting_methods`
|
#### `i4.sorting_methods`
|
||||||
|
|
||||||
A table containing all sorting methods.
|
A table containing all sorting methods.
|
||||||
|
|
||||||
|
@ -408,9 +408,9 @@ A table containing all sorting methods.
|
||||||
|
|
||||||
### Item list compression
|
### Item list compression
|
||||||
|
|
||||||
`i3` can reduce the item list size by compressing a group of items.
|
`i4` can reduce the item list size by compressing a group of items.
|
||||||
|
|
||||||
#### `i3.compress(item, def)`
|
#### `i4.compress(item, def)`
|
||||||
|
|
||||||
Add a new group of items to compress.
|
Add a new group of items to compress.
|
||||||
|
|
||||||
|
@ -420,14 +420,14 @@ Add a new group of items to compress.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.compress("default:diamondblock", {
|
i4.compress("default:diamondblock", {
|
||||||
replace = "diamond",
|
replace = "diamond",
|
||||||
by = {"bronze", "copper", "gold", "steel", "tin"}
|
by = {"bronze", "copper", "gold", "steel", "tin"}
|
||||||
})
|
})
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.compress_groups`
|
#### `i4.compress_groups`
|
||||||
|
|
||||||
A map of all compressed item groups, indexed by stereotypes.
|
A map of all compressed item groups, indexed by stereotypes.
|
||||||
|
|
||||||
|
@ -435,9 +435,9 @@ A map of all compressed item groups, indexed by stereotypes.
|
||||||
|
|
||||||
### Waypoints
|
### Waypoints
|
||||||
|
|
||||||
`i3` allows you to manage the waypoints of a specific player.
|
`i4` allows you to manage the waypoints of a specific player.
|
||||||
|
|
||||||
#### `i3.add_waypoint(player_name, def)`
|
#### `i4.add_waypoint(player_name, def)`
|
||||||
|
|
||||||
Add a waypoint to specific player.
|
Add a waypoint to specific player.
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ Add a waypoint to specific player.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.add_waypoint("Test", {
|
i4.add_waypoint("Test", {
|
||||||
player = "singleplayer",
|
player = "singleplayer",
|
||||||
pos = {x = 0, y = 2, z = 0},
|
pos = {x = 0, y = 2, z = 0},
|
||||||
color = 0xffff00,
|
color = 0xffff00,
|
||||||
|
@ -455,7 +455,7 @@ i3.add_waypoint("Test", {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.remove_waypoint(player_name, waypoint_name)`
|
#### `i4.remove_waypoint(player_name, waypoint_name)`
|
||||||
|
|
||||||
Remove a waypoint for specific player.
|
Remove a waypoint for specific player.
|
||||||
|
|
||||||
|
@ -465,10 +465,10 @@ Remove a waypoint for specific player.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
i3.remove_waypoint("singleplayer", "Test")
|
i4.remove_waypoint("singleplayer", "Test")
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `i3.get_waypoints(player_name)`
|
#### `i4.get_waypoints(player_name)`
|
||||||
|
|
||||||
Return a table of all waypoints of a specific player.
|
Return a table of all waypoints of a specific player.
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ Return a table of all waypoints of a specific player.
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
#### `i3.hud_notif(name, msg[, img])`
|
#### `i4.hud_notif(name, msg[, img])`
|
||||||
|
|
||||||
Show a Steam-like HUD notification on the bottom-left corner of the screen.
|
Show a Steam-like HUD notification on the bottom-left corner of the screen.
|
||||||
|
|
||||||
|
@ -486,11 +486,11 @@ Show a Steam-like HUD notification on the bottom-left corner of the screen.
|
||||||
- `msg` is the HUD message to show.
|
- `msg` is the HUD message to show.
|
||||||
- `img` (optional) is the HUD image to show (preferably 16x16 px).
|
- `img` (optional) is the HUD image to show (preferably 16x16 px).
|
||||||
|
|
||||||
#### `i3.get_recipes(item)`
|
#### `i4.get_recipes(item)`
|
||||||
|
|
||||||
Return a table of recipes and usages of `item`.
|
Return a table of recipes and usages of `item`.
|
||||||
|
|
||||||
#### `i3.export_url`
|
#### `i4.export_url`
|
||||||
|
|
||||||
If set, the mod will export all the cached recipes and usages in a JSON format
|
If set, the mod will export all the cached recipes and usages in a JSON format
|
||||||
to the given URL (HTTP support is required¹).
|
to the given URL (HTTP support is required¹).
|
||||||
|
@ -502,4 +502,4 @@ given a number between 1 and 4.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**[1]** Add `i3` to the `secure.http_mods` or `secure.trusted_mods` setting in `minetest.conf`.
|
**[1]** Add `i4` to the `secure.http_mods` or `secure.trusted_mods` setting in `minetest.conf`.
|
||||||
|
|
20
README.md
20
README.md
|
@ -1,11 +1,9 @@
|
||||||
![logo](https://user-images.githubusercontent.com/7883281/145490041-d91d6bd6-a654-438d-b208-4d5736845ab7.png)
|
![i4 logo](res/i4_logo_scaled.png)
|
||||||
|
|
||||||
[![GitHub Release](https://img.shields.io/github/release/minetest-mods/i3.svg?style=flat)]() ![workflow](https://github.com/minetest-mods/i3/actions/workflows/luacheck.yml/badge.svg) [![ContentDB](https://content.minetest.net/packages/jp/i3/shields/downloads/)](https://content.minetest.net/packages/jp/i3/) [![PayPal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/jpg84240)
|
#### **`i4`** is an inventory mod for Minetest.
|
||||||
|
|
||||||
#### **`i3`** is a next-generation inventory for Minetest.
|
|
||||||
|
|
||||||
This mod features a modern, powerful inventory menu with a good user experience.
|
This mod features a modern, powerful inventory menu with a good user experience.
|
||||||
**`i3`** provides a rich [**API**](https://github.com/minetest-mods/i3/blob/master/API.md) for mod developers who want to extend it.
|
**`i4`** provides a rich [**API**](API.md) for mod developers who want to extend it.
|
||||||
|
|
||||||
This mod requires **Minetest 5.6+**
|
This mod requires **Minetest 5.6+**
|
||||||
|
|
||||||
|
@ -23,7 +21,7 @@ This mod requires **Minetest 5.6+**
|
||||||
- Home
|
- Home
|
||||||
|
|
||||||
**¹** *This mode is a Terraria-like system that shows recipes you can craft from items you ever had in your inventory.
|
**¹** *This mode is a Terraria-like system that shows recipes you can craft from items you ever had in your inventory.
|
||||||
To enable it: `i3_progressive_mode = true` in `minetest.conf`.*
|
To enable it: `i4_progressive_mode = true` in `minetest.conf`.*
|
||||||
|
|
||||||
#### This mod officially supports the following mods:
|
#### This mod officially supports the following mods:
|
||||||
- [**`3d_armor`**](https://content.minetest.net/packages/stu/3d_armor/)
|
- [**`3d_armor`**](https://content.minetest.net/packages/stu/3d_armor/)
|
||||||
|
@ -46,15 +44,13 @@ You can also use the font size slider in the inventory, settings window.
|
||||||
|
|
||||||
#### Notes
|
#### Notes
|
||||||
|
|
||||||
`i3` uses a larger inventory than the usual inventories in Minetest games.
|
`i4` uses a larger inventory than the usual inventories in Minetest games.
|
||||||
Thus, most chests will be unadapted to this inventory size.
|
Thus, most chests will be unadapted to this inventory size.
|
||||||
The `i3` inventory is 9 slots wide by default, such as Minecraft.
|
The `i4` inventory is 9 slots wide by default, such as Minecraft.
|
||||||
|
|
||||||
Report bugs on the [**Bug Tracker**](https://github.com/minetest-mods/i3/issues).
|
Report bugs on the [**Bug Tracker**](https:///notabug.org/jadedctrl/i4).
|
||||||
|
|
||||||
**Video review on YouTube:** https://www.youtube.com/watch?v=Xd14BCdEZ3o
|
![Preview](res/screenshot.png)
|
||||||
|
|
||||||
![Preview](https://user-images.githubusercontent.com/7883281/185755315-23c2fffa-203d-4115-9dc3-576c92615733.png)
|
|
||||||
|
|
||||||
#### License
|
#### License
|
||||||
|
|
||||||
|
|
41
init.lua
41
init.lua
|
@ -1,16 +1,4 @@
|
||||||
print[[
|
local modpath = core.get_modpath"i4"
|
||||||
|
|
||||||
Powered by
|
|
||||||
|
|
||||||
██╗██████╗
|
|
||||||
██║╚════██╗
|
|
||||||
██║ █████╔╝
|
|
||||||
██║ ╚═══██╗
|
|
||||||
██║██████╔╝
|
|
||||||
╚═╝╚═════╝
|
|
||||||
]]
|
|
||||||
|
|
||||||
local modpath = core.get_modpath"i3"
|
|
||||||
local http = core.request_http_api()
|
local http = core.request_http_api()
|
||||||
local storage = core.get_mod_storage()
|
local storage = core.get_mod_storage()
|
||||||
local _loadfile = dofile(modpath .. "/src/preprocessor.lua")
|
local _loadfile = dofile(modpath .. "/src/preprocessor.lua")
|
||||||
|
@ -19,9 +7,10 @@ local function lf(path)
|
||||||
return assert(_loadfile(modpath .. path))
|
return assert(_loadfile(modpath .. path))
|
||||||
end
|
end
|
||||||
|
|
||||||
i3 = {
|
i4 = {
|
||||||
version = 1162,
|
version = 1162,
|
||||||
data = core.deserialize(storage:get_string"data") or {},
|
data = core.deserialize(storage:get_string"data") or {},
|
||||||
|
imported = storage:get_int"imported_from_i3",
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
debug_mode = false,
|
debug_mode = false,
|
||||||
|
@ -37,7 +26,7 @@ i3 = {
|
||||||
hud_timer_max = 3,
|
hud_timer_max = 3,
|
||||||
|
|
||||||
damage_enabled = core.settings:get_bool"enable_damage",
|
damage_enabled = core.settings:get_bool"enable_damage",
|
||||||
progressive_mode = core.settings:get_bool"i3_progressive_mode",
|
progressive_mode = core.settings:get_bool"i4_progressive_mode" or core.settings:get_bool"i3_progressive_mode",
|
||||||
},
|
},
|
||||||
|
|
||||||
categories = {
|
categories = {
|
||||||
|
@ -110,19 +99,21 @@ i3 = {
|
||||||
sorting_methods = {},
|
sorting_methods = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.files.common()
|
i3 = i4
|
||||||
i3.files.api(http)
|
|
||||||
i3.files.compress()
|
|
||||||
i3.files.detached()
|
|
||||||
i3.files.fields()
|
|
||||||
i3.files.groups()
|
|
||||||
i3.files.callbacks(http, storage)
|
|
||||||
|
|
||||||
if i3.settings.progressive_mode then
|
i4.files.common()
|
||||||
i3.files.progressive()
|
i4.files.api(http)
|
||||||
|
i4.files.compress()
|
||||||
|
i4.files.detached()
|
||||||
|
i4.files.fields()
|
||||||
|
i4.files.groups()
|
||||||
|
i4.files.callbacks(http, storage)
|
||||||
|
|
||||||
|
if i4.settings.progressive_mode then
|
||||||
|
i4.files.progressive()
|
||||||
end
|
end
|
||||||
|
|
||||||
if i3.settings.debug_mode then
|
if i4.settings.debug_mode then
|
||||||
lf("/tests/test_tabs.lua")()
|
lf("/tests/test_tabs.lua")()
|
||||||
lf("/tests/test_waypoints.lua")()
|
lf("/tests/test_waypoints.lua")()
|
||||||
-- lf("/tests/test_operators.lua")()
|
-- lf("/tests/test_operators.lua")()
|
||||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,4 +1,4 @@
|
||||||
name = i3
|
name = i4
|
||||||
description = Next-generation inventory
|
description = Next-generation inventory
|
||||||
optional_depends = 3d_armor, skinsdb, awards
|
optional_depends = 3d_armor, skinsdb, awards
|
||||||
min_minetest_version = 5.6
|
min_minetest_version = 5.6
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 371 B |
Binary file not shown.
After Width: | Height: | Size: 248 B |
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
|
@ -1,2 +1,2 @@
|
||||||
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
||||||
i3_progressive_mode (Learn crafting recipes progressively) bool false
|
i4_progressive_mode (Learn crafting recipes progressively) bool false
|
||||||
|
|
272
src/api.lua
272
src/api.lua
|
@ -1,6 +1,6 @@
|
||||||
local http = ...
|
local http = ...
|
||||||
local make_fs, get_inventory_fs, confirm_trash_footer_fs, settings_footer_fs = i3.files.gui()
|
local make_fs, get_inventory_fs, confirm_trash_footer_fs, settings_footer_fs = i4.files.gui()
|
||||||
local home_footer_fields, confirm_trash_footer_fields, settings_footer_fields = i3.files.fields()
|
local home_footer_fields, confirm_trash_footer_fields, settings_footer_fields = i4.files.fields()
|
||||||
|
|
||||||
IMPORT("sorter", "sort_inventory", "play_sound")
|
IMPORT("sorter", "sort_inventory", "play_sound")
|
||||||
IMPORT("sort", "concat", "copy", "insert", "remove")
|
IMPORT("sort", "concat", "copy", "insert", "remove")
|
||||||
|
@ -8,19 +8,19 @@ IMPORT("get_player_by_name", "add_hud_waypoint", "init_hud_notif")
|
||||||
IMPORT("gmatch", "split", "S", "err", "fmt", "reg_items", "pos_to_str")
|
IMPORT("gmatch", "split", "S", "err", "fmt", "reg_items", "pos_to_str")
|
||||||
IMPORT("true_str", "true_table", "is_str", "is_func", "is_table", "clean_name")
|
IMPORT("true_str", "true_table", "is_str", "is_func", "is_table", "clean_name")
|
||||||
|
|
||||||
function i3.register_craft_type(name, def)
|
function i4.register_craft_type(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.register_craft_type: name missing"
|
return err "i4.register_craft_type: name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.register_craft_type: definition missing"
|
return err "i4.register_craft_type: definition missing"
|
||||||
elseif not is_str(def.description) then
|
elseif not is_str(def.description) then
|
||||||
def.description = ""
|
def.description = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.craft_types[name] = def
|
i4.craft_types[name] = def
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.register_craft(def)
|
function i4.register_craft(def)
|
||||||
local width, c = 0, 0
|
local width, c = 0, 0
|
||||||
|
|
||||||
if http and true_str(def.url) then
|
if http and true_str(def.url) then
|
||||||
|
@ -28,7 +28,7 @@ function i3.register_craft(def)
|
||||||
if result.succeeded then
|
if result.succeeded then
|
||||||
local t = core.parse_json(result.data)
|
local t = core.parse_json(result.data)
|
||||||
if is_table(t) then
|
if is_table(t) then
|
||||||
return i3.register_craft(t)
|
return i4.register_craft(t)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -37,12 +37,12 @@ function i3.register_craft(def)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not true_table(def) then
|
if not true_table(def) then
|
||||||
return err "i3.register_craft: craft definition missing"
|
return err "i4.register_craft: craft definition missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
if #def > 1 then
|
if #def > 1 then
|
||||||
for _, v in pairs(def) do
|
for _, v in pairs(def) do
|
||||||
i3.register_craft(v)
|
i4.register_craft(v)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ function i3.register_craft(def)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not true_str(def.output) and not def.url then
|
if not true_str(def.output) and not def.url then
|
||||||
return err "i3.register_craft: output missing"
|
return err "i4.register_craft: output missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
if not is_table(def.items) then
|
if not is_table(def.items) then
|
||||||
|
@ -112,63 +112,63 @@ function i3.register_craft(def)
|
||||||
end
|
end
|
||||||
|
|
||||||
local item = ItemStack(def.output):get_name()
|
local item = ItemStack(def.output):get_name()
|
||||||
i3.recipes_cache[item] = i3.recipes_cache[item] or {}
|
i4.recipes_cache[item] = i4.recipes_cache[item] or {}
|
||||||
|
|
||||||
def.custom = true
|
def.custom = true
|
||||||
def.width = width
|
def.width = width
|
||||||
|
|
||||||
insert(i3.recipes_cache[item], def)
|
insert(i4.recipes_cache[item], def)
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.add_recipe_filter(name, f)
|
function i4.add_recipe_filter(name, f)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.add_recipe_filter: name missing"
|
return err "i4.add_recipe_filter: name missing"
|
||||||
elseif not is_func(f) then
|
elseif not is_func(f) then
|
||||||
return err "i3.add_recipe_filter: function missing"
|
return err "i4.add_recipe_filter: function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.recipe_filters[name] = f
|
i4.recipe_filters[name] = f
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.set_recipe_filter(name, f)
|
function i4.set_recipe_filter(name, f)
|
||||||
if not is_str(name) then
|
if not is_str(name) then
|
||||||
return err "i3.set_recipe_filter: name missing"
|
return err "i4.set_recipe_filter: name missing"
|
||||||
elseif not is_func(f) then
|
elseif not is_func(f) then
|
||||||
return err "i3.set_recipe_filter: function missing"
|
return err "i4.set_recipe_filter: function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.recipe_filters = {[name] = f}
|
i4.recipe_filters = {[name] = f}
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.add_search_filter(name, f)
|
function i4.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 "i4.add_search_filter: name missing"
|
||||||
elseif not is_func(f) then
|
elseif not is_func(f) then
|
||||||
return err "i3.add_search_filter: function missing"
|
return err "i4.add_search_filter: function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.search_filters[name] = f
|
i4.search_filters[name] = f
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.get_recipes(item)
|
function i4.get_recipes(item)
|
||||||
item = core.registered_aliases[item] or item
|
item = core.registered_aliases[item] or item
|
||||||
local recipes = i3.recipes_cache[item]
|
local recipes = i4.recipes_cache[item]
|
||||||
local usages = i3.usages_cache[item]
|
local usages = i4.usages_cache[item]
|
||||||
|
|
||||||
return {recipes = recipes, usages = usages}
|
return {recipes = recipes, usages = usages}
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.set_fs(player)
|
function i4.set_fs(player)
|
||||||
if not player or player.is_fake_player then return end
|
if not player or player.is_fake_player then return end
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
if data.auto_sorting then
|
if data.auto_sorting then
|
||||||
sort_inventory(player, data)
|
sort_inventory(player, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, tab in ipairs(i3.tabs) do
|
for i, tab in ipairs(i4.tabs) do
|
||||||
if data.tab == i and tab.access and not tab.access(player, data) then
|
if data.tab == i and tab.access and not tab.access(player, data) then
|
||||||
data.tab = 1
|
data.tab = 1
|
||||||
break
|
break
|
||||||
|
@ -179,137 +179,137 @@ function i3.set_fs(player)
|
||||||
player:set_inventory_formspec(fs)
|
player:set_inventory_formspec(fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.new_tab(name, def)
|
function i4.new_tab(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.new_tab: tab name missing"
|
return err "i4.new_tab: tab name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.new_tab: tab definition missing"
|
return err "i4.new_tab: tab definition missing"
|
||||||
elseif not true_str(def.description) then
|
elseif not true_str(def.description) then
|
||||||
return err "i3.new_tab: description missing"
|
return err "i4.new_tab: description missing"
|
||||||
elseif #i3.tabs == 6 then
|
elseif #i4.tabs == 6 then
|
||||||
return err(fmt("i3.new_tab: cannot add '%s' tab. Limit reached (6).", def.name))
|
return err(fmt("i4.new_tab: cannot add '%s' tab. Limit reached (6).", def.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
def.name = name
|
def.name = name
|
||||||
insert(i3.tabs, def)
|
insert(i4.tabs, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.new_tab("inventory", {
|
i4.new_tab("inventory", {
|
||||||
description = S"Inventory",
|
description = S"Inventory",
|
||||||
formspec = get_inventory_fs,
|
formspec = get_inventory_fs,
|
||||||
slots = true,
|
slots = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
function i3.remove_tab(name)
|
function i4.remove_tab(name)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.remove_tab: tab name missing"
|
return err "i4.remove_tab: tab name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = #i3.tabs, 2, -1 do
|
for i = #i4.tabs, 2, -1 do
|
||||||
local def = i3.tabs[i]
|
local def = i4.tabs[i]
|
||||||
if def and name == def.name then
|
if def and name == def.name then
|
||||||
remove(i3.tabs, i)
|
remove(i4.tabs, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.get_current_tab(player)
|
function i4.get_current_tab(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
return data.tab
|
return data.tab
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.set_tab(player, tabname)
|
function i4.set_tab(player, tabname)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
if not tabname or tabname == "" then
|
if not tabname or tabname == "" then
|
||||||
data.tab = 0
|
data.tab = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, tab in ipairs(i3.tabs) do
|
for i, tab in ipairs(i4.tabs) do
|
||||||
if tab.name == tabname then
|
if tab.name == tabname then
|
||||||
data.tab = i
|
data.tab = i
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
err(fmt("i3.set_tab: tab name '%s' does not exist", tabname))
|
err(fmt("i4.set_tab: tab name '%s' does not exist", tabname))
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.override_tab(name, newdef)
|
function i4.override_tab(name, newdef)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.override_tab: tab name missing"
|
return err "i4.override_tab: tab name missing"
|
||||||
elseif not true_table(newdef) then
|
elseif not true_table(newdef) then
|
||||||
return err "i3.override_tab: tab definition missing"
|
return err "i4.override_tab: tab definition missing"
|
||||||
elseif not true_str(newdef.description) then
|
elseif not true_str(newdef.description) then
|
||||||
return err "i3.override_tab: description missing"
|
return err "i4.override_tab: description missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
newdef.name = name
|
newdef.name = name
|
||||||
|
|
||||||
for i, def in ipairs(i3.tabs) do
|
for i, def in ipairs(i4.tabs) do
|
||||||
if def.name == name then
|
if def.name == name then
|
||||||
i3.tabs[i] = newdef
|
i4.tabs[i] = newdef
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.new_footer_button(name, def)
|
function i4.new_footer_button(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.new_footer_button: button name missing"
|
return err "i4.new_footer_button: button name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.new_footer_button: button definition missing"
|
return err "i4.new_footer_button: button definition missing"
|
||||||
elseif not true_str(def.description) then
|
elseif not true_str(def.description) then
|
||||||
return err "i3.new_footer_button: description missing"
|
return err "i4.new_footer_button: description missing"
|
||||||
elseif not def.image then
|
elseif not def.image then
|
||||||
return err "i3.new_footer_button: image missing"
|
return err "i4.new_footer_button: image missing"
|
||||||
elseif #i3.footer_buttons == 16 then
|
elseif #i4.footer_buttons == 16 then
|
||||||
return err(fmt("i3.new_footer_button: cannot add '%s' button. Limit reached (16).", def.name))
|
return err(fmt("i4.new_footer_button: cannot add '%s' button. Limit reached (16).", def.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
def.name = name
|
def.name = name
|
||||||
insert(i3.footer_buttons, def)
|
insert(i4.footer_buttons, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.remove_footer_button(name)
|
function i4.remove_footer_button(name)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.remove_footer_button: tab name missing"
|
return err "i4.remove_footer_button: tab name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = #i3.footer_buttons, 2, -1 do
|
for i = #i4.footer_buttons, 2, -1 do
|
||||||
local def = i3.footer_buttons[i]
|
local def = i4.footer_buttons[i]
|
||||||
if def and name == def.name then
|
if def and name == def.name then
|
||||||
remove(i3.footer_buttons, i)
|
remove(i4.footer_buttons, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.override_footer_button(name, newdef)
|
function i4.override_footer_button(name, newdef)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.override_footer_button: button name missing"
|
return err "i4.override_footer_button: button name missing"
|
||||||
elseif not true_table(newdef) then
|
elseif not true_table(newdef) then
|
||||||
return err "i3.override_footer_button: button definition missing"
|
return err "i4.override_footer_button: button definition missing"
|
||||||
elseif not true_str(newdef.description) then
|
elseif not true_str(newdef.description) then
|
||||||
return err "i3.override_footer_button: description missing"
|
return err "i4.override_footer_button: description missing"
|
||||||
elseif not true_str(newdef.image) then
|
elseif not true_str(newdef.image) then
|
||||||
return err "i3.override_footer_button: image missing"
|
return err "i4.override_footer_button: image missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
newdef.name = name
|
newdef.name = name
|
||||||
|
|
||||||
for i, def in ipairs(i3.footer_buttons) do
|
for i, def in ipairs(i4.footer_buttons) do
|
||||||
if def.name == name then
|
if def.name == name then
|
||||||
i3.footer_buttons[i] = newdef
|
i4.footer_buttons[i] = newdef
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.new_footer_button("trash", {
|
i4.new_footer_button("trash", {
|
||||||
description = S"Clear inventory",
|
description = S"Clear inventory",
|
||||||
image = "i3_trash.png",
|
image = "i3_trash.png",
|
||||||
formspec = confirm_trash_footer_fs,
|
formspec = confirm_trash_footer_fs,
|
||||||
|
@ -317,7 +317,7 @@ i3.new_footer_button("trash", {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
i3.new_footer_button("sort", {
|
i4.new_footer_button("sort", {
|
||||||
description = S"Sort inventory",
|
description = S"Sort inventory",
|
||||||
image = "i3_sort.png",
|
image = "i3_sort.png",
|
||||||
fields = function(player, data, fields)
|
fields = function(player, data, fields)
|
||||||
|
@ -327,30 +327,30 @@ i3.new_footer_button("sort", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.new_footer_button("settings", {
|
i4.new_footer_button("settings", {
|
||||||
description = S"Settings",
|
description = S"Settings",
|
||||||
image = "i3_settings.png",
|
image = "i3_settings.png",
|
||||||
formspec = settings_footer_fs,
|
formspec = settings_footer_fs,
|
||||||
fields = settings_footer_fields,
|
fields = settings_footer_fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.new_footer_button("home", {
|
i4.new_footer_button("home", {
|
||||||
description = S"Go home",
|
description = S"Go home",
|
||||||
image = "i3_home.png",
|
image = "i3_home.png",
|
||||||
fields = home_footer_fields,
|
fields = home_footer_fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.register_craft_type("digging", {
|
i4.register_craft_type("digging", {
|
||||||
description = S"Digging",
|
description = S"Digging",
|
||||||
icon = "i3_steelpick.png",
|
icon = "i3_steelpick.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.register_craft_type("digging_chance", {
|
i4.register_craft_type("digging_chance", {
|
||||||
description = S"Digging (by chance)",
|
description = S"Digging (by chance)",
|
||||||
icon = "i3_mesepick.png",
|
icon = "i3_mesepick.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.add_search_filter("groups", function(item, groups)
|
i4.add_search_filter("groups", function(item, groups)
|
||||||
local def = reg_items[item]
|
local def = reg_items[item]
|
||||||
local has_groups = true
|
local has_groups = true
|
||||||
|
|
||||||
|
@ -364,42 +364,42 @@ i3.add_search_filter("groups", function(item, groups)
|
||||||
return has_groups
|
return has_groups
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function i3.compress(item, def)
|
function i4.compress(item, def)
|
||||||
if not true_str(item) then
|
if not true_str(item) then
|
||||||
return err "i3.compress: item name missing"
|
return err "i4.compress: item name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.compress: replace definition missing"
|
return err "i4.compress: replace definition missing"
|
||||||
elseif not true_str(def.replace) then
|
elseif not true_str(def.replace) then
|
||||||
return err "i3.compress: replace string missing"
|
return err "i4.compress: replace string missing"
|
||||||
elseif not is_table(def.by) then
|
elseif not is_table(def.by) then
|
||||||
return err "i3.compress: replace substrings missing"
|
return err "i4.compress: replace substrings missing"
|
||||||
elseif i3.compressed[item] then
|
elseif i4.compressed[item] then
|
||||||
return err(fmt("i3.compress: item '%s' is already compressed", item))
|
return err(fmt("i4.compress: item '%s' is already compressed", item))
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = {}
|
local t = {}
|
||||||
i3.compress_groups[item] = i3.compress_groups[item] or {}
|
i4.compress_groups[item] = i4.compress_groups[item] or {}
|
||||||
|
|
||||||
for _, str in ipairs(def.by) do
|
for _, str in ipairs(def.by) do
|
||||||
local it = item:gsub(def.replace, str)
|
local it = item:gsub(def.replace, str)
|
||||||
|
|
||||||
insert(t, it)
|
insert(t, it)
|
||||||
insert(i3.compress_groups[item], it)
|
insert(i4.compress_groups[item], it)
|
||||||
|
|
||||||
i3.compressed[it] = true
|
i4.compressed[it] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.hud_notif(name, msg, img)
|
function i4.hud_notif(name, msg, img)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.hud_notif: player name missing"
|
return err "i4.hud_notif: player name missing"
|
||||||
elseif not true_str(msg) then
|
elseif not true_str(msg) then
|
||||||
return err "i3.hud_notif: message missing"
|
return err "i4.hud_notif: message missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then
|
if not data then
|
||||||
return err "i3.hud_notif: no player data initialized"
|
return err "i4.hud_notif: no player data initialized"
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = get_player_by_name(name)
|
local player = get_player_by_name(name)
|
||||||
|
@ -429,20 +429,20 @@ function i3.hud_notif(name, msg, img)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.add_sorting_method(name, def)
|
function i4.add_sorting_method(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.add_sorting_method: name missing"
|
return err "i4.add_sorting_method: name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.add_sorting_method: definition missing"
|
return err "i4.add_sorting_method: definition missing"
|
||||||
elseif not is_func(def.func) then
|
elseif not is_func(def.func) then
|
||||||
return err "i3.add_sorting_method: function missing"
|
return err "i4.add_sorting_method: function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
def.name = name
|
def.name = name
|
||||||
insert(i3.sorting_methods, def)
|
insert(i4.sorting_methods, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.add_sorting_method("alphabetical", {
|
i4.add_sorting_method("alphabetical", {
|
||||||
description = S"Sort items by name (A-Z)",
|
description = S"Sort items by name (A-Z)",
|
||||||
func = function(list, data)
|
func = function(list, data)
|
||||||
sorter(list, data, 1)
|
sorter(list, data, 1)
|
||||||
|
@ -450,7 +450,7 @@ i3.add_sorting_method("alphabetical", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.add_sorting_method("numerical", {
|
i4.add_sorting_method("numerical", {
|
||||||
description = S"Sort items by number of items per stack",
|
description = S"Sort items by number of items per stack",
|
||||||
func = function(list, data)
|
func = function(list, data)
|
||||||
sorter(list, data, 2)
|
sorter(list, data, 2)
|
||||||
|
@ -458,18 +458,18 @@ i3.add_sorting_method("numerical", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
function i3.add_waypoint(name, def)
|
function i4.add_waypoint(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.add_waypoint: name missing"
|
return err "i4.add_waypoint: name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.add_waypoint: definition missing"
|
return err "i4.add_waypoint: definition missing"
|
||||||
elseif not true_str(def.player) then
|
elseif not true_str(def.player) then
|
||||||
return err "i3.add_waypoint: player name missing"
|
return err "i4.add_waypoint: player name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = i3.data[def.player]
|
local data = i4.data[def.player]
|
||||||
if not data then
|
if not data then
|
||||||
return err "i3.add_waypoint: no player data initialized"
|
return err "i4.add_waypoint: no player data initialized"
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = get_player_by_name(def.player)
|
local player = get_player_by_name(def.player)
|
||||||
|
@ -487,19 +487,19 @@ function i3.add_waypoint(name, def)
|
||||||
data.scrbar_inv += 1000
|
data.scrbar_inv += 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.set_fs(player)
|
i4.set_fs(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.remove_waypoint(player_name, name)
|
function i4.remove_waypoint(player_name, name)
|
||||||
if not true_str(player_name) then
|
if not true_str(player_name) then
|
||||||
return err "i3.remove_waypoint: player name missing"
|
return err "i4.remove_waypoint: player name missing"
|
||||||
elseif not true_str(name) then
|
elseif not true_str(name) then
|
||||||
return err "i3.remove_waypoint: waypoint name missing"
|
return err "i4.remove_waypoint: waypoint name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = i3.data[player_name]
|
local data = i4.data[player_name]
|
||||||
if not data then
|
if not data then
|
||||||
return err "i3.remove_waypoint: no player data initialized"
|
return err "i4.remove_waypoint: no player data initialized"
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = get_player_by_name(player_name)
|
local player = get_player_by_name(player_name)
|
||||||
|
@ -515,49 +515,49 @@ function i3.remove_waypoint(player_name, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.set_fs(player)
|
i4.set_fs(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.get_waypoints(player_name)
|
function i4.get_waypoints(player_name)
|
||||||
if not true_str(player_name) then
|
if not true_str(player_name) then
|
||||||
return err "i3.get_waypoints: player name missing"
|
return err "i4.get_waypoints: player name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = i3.data[player_name]
|
local data = i4.data[player_name]
|
||||||
if not data then
|
if not data then
|
||||||
return err "i3.get_waypoints: no player data initialized"
|
return err "i4.get_waypoints: no player data initialized"
|
||||||
end
|
end
|
||||||
|
|
||||||
return data.waypoints
|
return data.waypoints
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.new_minitab(name, def)
|
function i4.new_minitab(name, def)
|
||||||
if #i3.minitabs == 6 then
|
if #i4.minitabs == 6 then
|
||||||
return err "i3.new_minitab: limit reached (6)"
|
return err "i4.new_minitab: limit reached (6)"
|
||||||
elseif not true_str(name) then
|
elseif not true_str(name) then
|
||||||
return err "i3.new_minitab: name missing"
|
return err "i4.new_minitab: name missing"
|
||||||
elseif not true_table(def) then
|
elseif not true_table(def) then
|
||||||
return err "i3.new_minitab: definition missing"
|
return err "i4.new_minitab: definition missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
def.name = name
|
def.name = name
|
||||||
insert(i3.minitabs, def)
|
insert(i4.minitabs, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.remove_minitab(name)
|
function i4.remove_minitab(name)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err "i3.remove_minitab: name missing"
|
return err "i4.remove_minitab: name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = #i3.minitabs, 2, -1 do
|
for i = #i4.minitabs, 2, -1 do
|
||||||
local v = i3.minitabs[i]
|
local v = i4.minitabs[i]
|
||||||
if v and v.name == name then
|
if v and v.name == name then
|
||||||
remove(i3.minitabs, i)
|
remove(i4.minitabs, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.new_minitab("all", {
|
i4.new_minitab("all", {
|
||||||
description = "All",
|
description = "All",
|
||||||
|
|
||||||
sorter = function()
|
sorter = function()
|
||||||
|
@ -565,7 +565,7 @@ i3.new_minitab("all", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.new_minitab("nodes", {
|
i4.new_minitab("nodes", {
|
||||||
description = "Nodes",
|
description = "Nodes",
|
||||||
|
|
||||||
sorter = function(item)
|
sorter = function(item)
|
||||||
|
@ -573,7 +573,7 @@ i3.new_minitab("nodes", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.new_minitab("items", {
|
i4.new_minitab("items", {
|
||||||
description = "Items",
|
description = "Items",
|
||||||
|
|
||||||
sorter = function(item)
|
sorter = function(item)
|
||||||
|
|
15
src/bags.lua
15
src/bags.lua
|
@ -1,4 +1,4 @@
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i4.set_fs
|
||||||
|
|
||||||
IMPORT("get_bag_description", "ItemStack")
|
IMPORT("get_bag_description", "ItemStack")
|
||||||
IMPORT("S", "ES", "fmt", "msg", "slz", "dslz")
|
IMPORT("S", "ES", "fmt", "msg", "slz", "dslz")
|
||||||
|
@ -16,7 +16,7 @@ end
|
||||||
|
|
||||||
local function init_bags(player)
|
local function init_bags(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
local bag = create_inventory(fmt("i3_bag_%s", name), {
|
local bag = create_inventory(fmt("i3_bag_%s", name), {
|
||||||
allow_put = function(inv, _, _, stack)
|
allow_put = function(inv, _, _, stack)
|
||||||
|
@ -142,22 +142,22 @@ local bag_recipes = {
|
||||||
},
|
},
|
||||||
medium = {
|
medium = {
|
||||||
rcp = {
|
rcp = {
|
||||||
{"farming:string", "i3:bag_small", "farming:string"},
|
{"farming:string", "i4:bag_small", "farming:string"},
|
||||||
{"farming:string", "i3:bag_small", "farming:string"},
|
{"farming:string", "i4:bag_small", "farming:string"},
|
||||||
},
|
},
|
||||||
size = 3,
|
size = 3,
|
||||||
},
|
},
|
||||||
large = {
|
large = {
|
||||||
rcp = {
|
rcp = {
|
||||||
{"farming:string", "i3:bag_medium", "farming:string"},
|
{"farming:string", "i4:bag_medium", "farming:string"},
|
||||||
{"farming:string", "i3:bag_medium", "farming:string"},
|
{"farming:string", "i4:bag_medium", "farming:string"},
|
||||||
},
|
},
|
||||||
size = 4,
|
size = 4,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for size, item in pairs(bag_recipes) do
|
for size, item in pairs(bag_recipes) do
|
||||||
local bagname = fmt("i3:bag_%s", size)
|
local bagname = fmt("i4:bag_%s", size)
|
||||||
|
|
||||||
core.register_craftitem(bagname, {
|
core.register_craftitem(bagname, {
|
||||||
description = fmt("%s Backpack", size:gsub("^%l", string.upper)),
|
description = fmt("%s Backpack", size:gsub("^%l", string.upper)),
|
||||||
|
@ -165,6 +165,7 @@ for size, item in pairs(bag_recipes) do
|
||||||
groups = {bag = item.size},
|
groups = {bag = item.size},
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
})
|
})
|
||||||
|
minetest.register_alias_force(fmt("i3:bag_%s", size), bagname)
|
||||||
|
|
||||||
core.register_craft{output = bagname, recipe = item.rcp}
|
core.register_craft{output = bagname, recipe = item.rcp}
|
||||||
core.register_craft{type = "fuel", recipe = bagname, burntime = 3}
|
core.register_craft{type = "fuel", recipe = bagname, burntime = 3}
|
||||||
|
|
|
@ -13,7 +13,7 @@ end
|
||||||
local function cache_fuel(item)
|
local function cache_fuel(item)
|
||||||
local burntime = get_burntime(item)
|
local burntime = get_burntime(item)
|
||||||
if burntime > 0 then
|
if burntime > 0 then
|
||||||
i3.fuel_cache[item] = {
|
i4.fuel_cache[item] = {
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
items = {item},
|
items = {item},
|
||||||
burntime = burntime,
|
burntime = burntime,
|
||||||
|
@ -23,15 +23,15 @@ local function cache_fuel(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cache_groups(group, groups)
|
local function cache_groups(group, groups)
|
||||||
i3.groups[group] = {}
|
i4.groups[group] = {}
|
||||||
i3.groups[group].groups = groups
|
i4.groups[group].groups = groups
|
||||||
i3.groups[group].items = groups_to_items(groups)
|
i4.groups[group].items = groups_to_items(groups)
|
||||||
|
|
||||||
if #groups == 1 then
|
if #groups == 1 then
|
||||||
i3.groups[group].stereotype = get_group_stereotype(groups[1])
|
i4.groups[group].stereotype = get_group_stereotype(groups[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
local items = i3.groups[group].items
|
local items = i4.groups[group].items
|
||||||
if #items <= 1 then return end
|
if #items <= 1 then return end
|
||||||
|
|
||||||
local px, lim, c = 64, 10, 0
|
local px, lim, c = 64, 10, 0
|
||||||
|
@ -56,15 +56,15 @@ local function cache_groups(group, groups)
|
||||||
|
|
||||||
if c > 1 then
|
if c > 1 then
|
||||||
sprite = sprite:gsub("WxH", px .. "x" .. px * c)
|
sprite = sprite:gsub("WxH", px .. "x" .. px * c)
|
||||||
i3.groups[group].sprite = sprite
|
i4.groups[group].sprite = sprite
|
||||||
i3.groups[group].count = c
|
i4.groups[group].count = c
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_item_usages(item, recipe, added)
|
local function get_item_usages(item, recipe, added)
|
||||||
if is_group(item) then
|
if is_group(item) then
|
||||||
local group = item:sub(7)
|
local group = item:sub(7)
|
||||||
local group_cache = i3.groups[group]
|
local group_cache = i4.groups[group]
|
||||||
local groups = group_cache and group_cache.groups or extract_groups(item)
|
local groups = group_cache and group_cache.groups or extract_groups(item)
|
||||||
|
|
||||||
if not group_cache then
|
if not group_cache then
|
||||||
|
@ -76,15 +76,15 @@ local function get_item_usages(item, recipe, added)
|
||||||
local usage = copy(recipe)
|
local usage = copy(recipe)
|
||||||
table_replace(usage.items, item, name)
|
table_replace(usage.items, item, name)
|
||||||
|
|
||||||
i3.usages_cache[name] = i3.usages_cache[name] or {}
|
i4.usages_cache[name] = i4.usages_cache[name] or {}
|
||||||
insert(i3.usages_cache[name], 1, usage)
|
insert(i4.usages_cache[name], 1, usage)
|
||||||
|
|
||||||
added[name] = true
|
added[name] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif valid_item(reg_items[item]) then
|
elseif valid_item(reg_items[item]) then
|
||||||
i3.usages_cache[item] = i3.usages_cache[item] or {}
|
i4.usages_cache[item] = i4.usages_cache[item] or {}
|
||||||
insert(i3.usages_cache[item], 1, recipe)
|
insert(i4.usages_cache[item], 1, recipe)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,14 +102,14 @@ local function get_usages(recipe)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cache_usages(item)
|
local function cache_usages(item)
|
||||||
local recipes = i3.recipes_cache[item] or {}
|
local recipes = i4.recipes_cache[item] or {}
|
||||||
|
|
||||||
for i = 1, #recipes do
|
for i = 1, #recipes do
|
||||||
get_usages(recipes[i])
|
get_usages(recipes[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
if i3.fuel_cache[item] then
|
if i4.fuel_cache[item] then
|
||||||
i3.usages_cache[item] = table_merge(i3.usages_cache[item] or {}, {i3.fuel_cache[item]})
|
i4.usages_cache[item] = table_merge(i4.usages_cache[item] or {}, {i4.fuel_cache[item]})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ local function drop_table(name, drop)
|
||||||
if not empty and (dname ~= name or (dname == name and dcount > 1)) then
|
if not empty and (dname ~= name or (dname == name and dcount > 1)) then
|
||||||
local rarity = valid_rarity and di.rarity
|
local rarity = valid_rarity and di.rarity
|
||||||
|
|
||||||
i3.register_craft {
|
i4.register_craft {
|
||||||
type = rarity and "digging_chance" or "digging",
|
type = rarity and "digging_chance" or "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
output = fmt("%s %u", dname, dcount),
|
output = fmt("%s %u", dname, dcount),
|
||||||
|
@ -157,7 +157,7 @@ local function cache_drops(name, drop)
|
||||||
local empty = dstack:is_empty()
|
local empty = dstack:is_empty()
|
||||||
|
|
||||||
if not empty and dname ~= name then
|
if not empty and dname ~= name then
|
||||||
i3.register_craft {
|
i4.register_craft {
|
||||||
type = "digging",
|
type = "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
output = drop,
|
output = drop,
|
||||||
|
@ -188,7 +188,7 @@ local function cache_recipes(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
if recipes then
|
if recipes then
|
||||||
i3.recipes_cache[item] = table_merge(recipes, i3.recipes_cache[item] or {})
|
i4.recipes_cache[item] = table_merge(recipes, i4.recipes_cache[item] or {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ core.register_craft = function(def)
|
||||||
old_register_craft(def)
|
old_register_craft(def)
|
||||||
|
|
||||||
if def.type == "toolrepair" then
|
if def.type == "toolrepair" then
|
||||||
i3.toolrepair = def.additional_wear * -100
|
i4.toolrepair = def.additional_wear * -100
|
||||||
end
|
end
|
||||||
|
|
||||||
local output = def.output or (true_str(def.recipe) and def.recipe) or nil
|
local output = def.output or (true_str(def.recipe) and def.recipe) or nil
|
||||||
|
@ -244,20 +244,20 @@ end
|
||||||
local function resolve_aliases(hash)
|
local function resolve_aliases(hash)
|
||||||
for oldname, newname in pairs(reg_aliases) do
|
for oldname, newname in pairs(reg_aliases) do
|
||||||
cache_recipes(oldname)
|
cache_recipes(oldname)
|
||||||
local recipes = i3.recipes_cache[oldname]
|
local recipes = i4.recipes_cache[oldname]
|
||||||
|
|
||||||
if recipes then
|
if recipes then
|
||||||
if not i3.recipes_cache[newname] then
|
if not i4.recipes_cache[newname] then
|
||||||
i3.recipes_cache[newname] = {}
|
i4.recipes_cache[newname] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local similar
|
local similar
|
||||||
|
|
||||||
for i = 1, #i3.recipes_cache[oldname] do
|
for i = 1, #i4.recipes_cache[oldname] do
|
||||||
local rcp_old = i3.recipes_cache[oldname][i]
|
local rcp_old = i4.recipes_cache[oldname][i]
|
||||||
|
|
||||||
for j = 1, #i3.recipes_cache[newname] do
|
for j = 1, #i4.recipes_cache[newname] do
|
||||||
local rcp_new = copy(i3.recipes_cache[newname][j])
|
local rcp_new = copy(i4.recipes_cache[newname][j])
|
||||||
rcp_new.output = oldname
|
rcp_new.output = oldname
|
||||||
|
|
||||||
if table_eq(rcp_old, rcp_new) then
|
if table_eq(rcp_old, rcp_new) then
|
||||||
|
@ -267,13 +267,13 @@ local function resolve_aliases(hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not similar then
|
if not similar then
|
||||||
insert(i3.recipes_cache[newname], rcp_old)
|
insert(i4.recipes_cache[newname], rcp_old)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if newname ~= "" and i3.recipes_cache[oldname] and reg_items[newname] and not hash[newname] then
|
if newname ~= "" and i4.recipes_cache[oldname] and reg_items[newname] and not hash[newname] then
|
||||||
insert(i3.init_items, newname)
|
insert(i4.init_items, newname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -294,21 +294,21 @@ local function init_recipes()
|
||||||
for name in pairs(_preselect) do
|
for name in pairs(_preselect) do
|
||||||
cache_usages(name)
|
cache_usages(name)
|
||||||
|
|
||||||
insert(i3.init_items, name)
|
insert(i4.init_items, name)
|
||||||
_select[name] = true
|
_select[name] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve_aliases(_select)
|
resolve_aliases(_select)
|
||||||
sort(i3.init_items)
|
sort(i4.init_items)
|
||||||
|
|
||||||
if http and true_str(i3.export_url) then
|
if http and true_str(i4.export_url) then
|
||||||
local post_data = {
|
local post_data = {
|
||||||
recipes = i3.recipes_cache,
|
recipes = i4.recipes_cache,
|
||||||
usages = i3.usages_cache,
|
usages = i4.usages_cache,
|
||||||
}
|
}
|
||||||
|
|
||||||
http.fetch_async {
|
http.fetch_async {
|
||||||
url = i3.export_url,
|
url = i4.export_url,
|
||||||
post_data = core.write_json(post_data),
|
post_data = core.write_json(post_data),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -321,12 +321,12 @@ local function init_cubes()
|
||||||
local tiles = def.tiles or def.tile_images
|
local tiles = def.tiles or def.tile_images
|
||||||
|
|
||||||
if is_cube(def.drawtype) then
|
if is_cube(def.drawtype) then
|
||||||
i3.cubes[id] = get_cube(tiles)
|
i4.cubes[id] = get_cube(tiles)
|
||||||
elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then
|
elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then
|
||||||
local texture = true_str(def.inventory_image) and def.inventory_image or tiles[1]
|
local texture = true_str(def.inventory_image) and def.inventory_image or tiles[1]
|
||||||
|
|
||||||
if texture then
|
if texture then
|
||||||
i3.plants[id] = texture
|
i4.plants[id] = texture
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
local http, storage = ...
|
local http, storage = ...
|
||||||
local init_bags = i3.files.bags()
|
local init_bags = i4.files.bags()
|
||||||
local fill_caches = i3.files.caches(http)
|
local fill_caches = i4.files.caches(http)
|
||||||
local init_hud = i3.files.hud()
|
local init_hud = i4.files.hud()
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i4.set_fs
|
||||||
|
|
||||||
IMPORT("slz", "min", "insert", "copy", "ItemStack")
|
IMPORT("slz", "min", "insert", "copy", "ItemStack")
|
||||||
IMPORT("spawn_item", "reset_data", "get_detached_inv", "play_sound", "update_inv_size")
|
IMPORT("spawn_item", "reset_data", "get_detached_inv", "play_sound", "update_inv_size")
|
||||||
|
|
||||||
core.register_on_player_hpchange(function(player, hpchange)
|
core.register_on_player_hpchange(function(player, hpchange)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
local hp_max = player:get_properties().hp_max
|
local hp_max = player:get_properties().hp_max
|
||||||
|
@ -20,10 +20,10 @@ end)
|
||||||
|
|
||||||
core.register_on_dieplayer(function(player)
|
core.register_on_dieplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
if i3.settings.drop_bag_on_die then
|
if i4.settings.drop_bag_on_die then
|
||||||
local bagstack = ItemStack(data.bag)
|
local bagstack = ItemStack(data.bag)
|
||||||
spawn_item(player, bagstack)
|
spawn_item(player, bagstack)
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ end)
|
||||||
|
|
||||||
core.register_on_priv_grant(function(name, _, priv)
|
core.register_on_priv_grant(function(name, _, priv)
|
||||||
if priv == "creative" or priv == "all" then
|
if priv == "creative" or priv == "all" then
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
reset_data(data)
|
reset_data(data)
|
||||||
data.favs = {}
|
data.favs = {}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ core.register_on_player_inventory_action(function(player, _, _, info)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if core.global_exists"armor" then
|
if core.global_exists"armor" then
|
||||||
i3.modules.armor = true
|
i4.modules.armor = true
|
||||||
|
|
||||||
local group_indexes = {
|
local group_indexes = {
|
||||||
{"armor_head", "i3_heavy_helmet"},
|
{"armor_head", "i3_heavy_helmet"},
|
||||||
|
@ -84,7 +84,7 @@ if core.global_exists"armor" then
|
||||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||||
local def = stack:get_definition()
|
local def = stack:get_definition()
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
for i, v in ipairs(group_indexes) do
|
for i, v in ipairs(group_indexes) do
|
||||||
local group, sound = unpack(v)
|
local group, sound = unpack(v)
|
||||||
|
@ -128,7 +128,7 @@ if core.global_exists"armor" then
|
||||||
core.register_on_player_inventory_action(function(player, action, _, info)
|
core.register_on_player_inventory_action(function(player, action, _, info)
|
||||||
if action ~= "take" then return end
|
if action ~= "take" then return end
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
if data.armor_disallow then
|
if data.armor_disallow then
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
@ -144,11 +144,11 @@ if core.global_exists"armor" then
|
||||||
end
|
end
|
||||||
|
|
||||||
if core.global_exists"skins" then
|
if core.global_exists"skins" then
|
||||||
i3.modules.skins = true
|
i4.modules.skins = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if core.global_exists"awards" then
|
if core.global_exists"awards" then
|
||||||
i3.modules.awards = true
|
i4.modules.awards = true
|
||||||
|
|
||||||
core.register_on_craft(function(_, player)
|
core.register_on_craft(function(_, player)
|
||||||
set_fs(player)
|
set_fs(player)
|
||||||
|
@ -193,17 +193,17 @@ local function get_formspec_version(info)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function outdated(name)
|
local function outdated(name)
|
||||||
core.show_formspec(name, "i3_outdated",
|
core.show_formspec(name, "i4_outdated",
|
||||||
("size[6.5,1.3]image[0,0;1,1;i3_book.png]label[1,0;%s]button_exit[2.6,0.8;1,1;;OK]"):format(
|
("size[6.5,1.3]image[0,0;1,1;i3_book.png]label[1,0;%s]button_exit[2.6,0.8;1,1;;OK]"):format(
|
||||||
"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."))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init_data(player, info)
|
local function init_data(player, info)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
i3.data[name] = i3.data[name] or {}
|
i4.data[name] = i4.data[name] or {}
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
for k, v in pairs(i3.default_data) do
|
for k, v in pairs(i4.default_data) do
|
||||||
local val = data[k]
|
local val = data[k]
|
||||||
if val == nil then
|
if val == nil then
|
||||||
val = v
|
val = v
|
||||||
|
@ -216,8 +216,8 @@ local function init_data(player, info)
|
||||||
data.filter = ""
|
data.filter = ""
|
||||||
data.pagenum = 1
|
data.pagenum = 1
|
||||||
data.skin_pagenum = 1
|
data.skin_pagenum = 1
|
||||||
data.items = i3.init_items
|
data.items = i4.init_items
|
||||||
data.items_raw = i3.init_items
|
data.items_raw = i4.init_items
|
||||||
data.favs = {}
|
data.favs = {}
|
||||||
data.show_setting = "home"
|
data.show_setting = "home"
|
||||||
data.crafting_counts = {}
|
data.crafting_counts = {}
|
||||||
|
@ -234,28 +234,31 @@ local function init_data(player, info)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function save_data(player_name)
|
local function save_data(player_name)
|
||||||
local _data = copy(i3.data)
|
local _data = copy(i4.data)
|
||||||
|
|
||||||
for name, v in pairs(_data) do
|
for name, v in pairs(_data) do
|
||||||
for dat in pairs(v) do
|
for dat in pairs(v) do
|
||||||
if not i3.saves[dat] then
|
if not i4.saves[dat] then
|
||||||
_data[name][dat] = nil
|
_data[name][dat] = nil
|
||||||
|
|
||||||
if player_name and i3.data[player_name] then
|
if player_name and i4.data[player_name] then
|
||||||
i3.data[player_name][dat] = nil -- To free up some memory
|
i4.data[player_name][dat] = nil -- To free up some memory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
storage:set_string("data", slz(_data))
|
storage:set_string("data", slz(_data))
|
||||||
|
if i4.imported then
|
||||||
|
storage:set_int("imported_from_i3", 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
insert(core.registered_on_joinplayers, 1, function(player)
|
insert(core.registered_on_joinplayers, 1, function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local info = core.get_player_information and core.get_player_information(name)
|
local info = core.get_player_information and core.get_player_information(name)
|
||||||
|
|
||||||
if not info or get_formspec_version(info) < i3.settings.min_fs_version then
|
if not info or get_formspec_version(info) < i4.settings.min_fs_version then
|
||||||
return outdated(name)
|
return outdated(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -273,7 +276,7 @@ core.register_on_shutdown(save_data)
|
||||||
|
|
||||||
local function routine()
|
local function routine()
|
||||||
save_data()
|
save_data()
|
||||||
core.after(i3.settings.save_interval, routine)
|
core.after(i4.settings.save_interval, routine)
|
||||||
end
|
end
|
||||||
|
|
||||||
core.after(i3.settings.save_interval, routine)
|
core.after(i4.settings.save_interval, routine)
|
||||||
|
|
|
@ -27,7 +27,7 @@ function core.is_creative_enabled(name)
|
||||||
return core.check_player_privs(name, {creative = true}) or old_is_creative_enabled(name)
|
return core.check_player_privs(name, {creative = true}) or old_is_creative_enabled(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local S = core.get_translator"i3"
|
local S = core.get_translator"i4"
|
||||||
local ES = function(...) return core.formspec_escape(S(...)) end
|
local ES = function(...) return core.formspec_escape(S(...)) end
|
||||||
|
|
||||||
local function is_num(x)
|
local function is_num(x)
|
||||||
|
@ -60,7 +60,7 @@ local function reset_compression(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function msg(name, str)
|
local function msg(name, str)
|
||||||
local prefix = "[i3]"
|
local prefix = "[i4]"
|
||||||
return core.chat_send_player(name, fmt("%s %s", core.colorize("#ff0", prefix), str))
|
return core.chat_send_player(name, fmt("%s %s", core.colorize("#ff0", prefix), str))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,14 +100,14 @@ local function search(data)
|
||||||
|
|
||||||
local filter = data.filter
|
local filter = data.filter
|
||||||
local opt = "^(.-)%+([%w_]+)=([%w_,]+)"
|
local opt = "^(.-)%+([%w_]+)=([%w_,]+)"
|
||||||
local search_filter = next(i3.search_filters) and match(filter, opt)
|
local search_filter = next(i4.search_filters) and match(filter, opt)
|
||||||
local filters = {}
|
local filters = {}
|
||||||
|
|
||||||
if search_filter then
|
if search_filter then
|
||||||
search_filter = search_filter:trim()
|
search_filter = search_filter:trim()
|
||||||
|
|
||||||
for filter_name, values in gmatch(filter, sub(opt, 6)) do
|
for filter_name, values in gmatch(filter, sub(opt, 6)) do
|
||||||
if i3.search_filters[filter_name] then
|
if i4.search_filters[filter_name] then
|
||||||
values = split(values, ",")
|
values = split(values, ",")
|
||||||
filters[filter_name] = values
|
filters[filter_name] = values
|
||||||
end
|
end
|
||||||
|
@ -126,7 +126,7 @@ local function search(data)
|
||||||
if search_filter then
|
if search_filter then
|
||||||
for filter_name, values in pairs(filters) do
|
for filter_name, values in pairs(filters) do
|
||||||
if values then
|
if values then
|
||||||
local func = i3.search_filters[filter_name]
|
local func = i4.search_filters[filter_name]
|
||||||
to_add = (j > 1 and temp[item] or j == 1) and
|
to_add = (j > 1 and temp[item] or j == 1) and
|
||||||
func(item, values) and (search_filter == "" or
|
func(item, values) and (search_filter == "" or
|
||||||
find(search_in, search_filter, 1, true))
|
find(search_in, search_filter, 1, true))
|
||||||
|
@ -268,7 +268,7 @@ local function valid_item(def)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_group_stereotype(group)
|
local function get_group_stereotype(group)
|
||||||
local stereotype = i3.group_stereotypes[group]
|
local stereotype = i4.group_stereotypes[group]
|
||||||
local def = reg_items[stereotype]
|
local def = reg_items[stereotype]
|
||||||
|
|
||||||
if valid_item(def) then
|
if valid_item(def) then
|
||||||
|
@ -320,7 +320,7 @@ local function get_cube(tiles)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function apply_recipe_filters(recipes, player)
|
local function apply_recipe_filters(recipes, player)
|
||||||
for _, filter in pairs(i3.recipe_filters) do
|
for _, filter in pairs(i4.recipe_filters) do
|
||||||
recipes = filter(recipes, player)
|
recipes = filter(recipes, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ local function apply_recipe_filters(recipes, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function recipe_filter_set()
|
local function recipe_filter_set()
|
||||||
return next(i3.recipe_filters)
|
return next(i4.recipe_filters)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function compression_active(data)
|
local function compression_active(data)
|
||||||
|
@ -336,7 +336,7 @@ local function compression_active(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function compressible(item, data)
|
local function compressible(item, data)
|
||||||
return compression_active(data) and i3.compress_groups[item]
|
return compression_active(data) and i4.compress_groups[item]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_fav(data)
|
local function is_fav(data)
|
||||||
|
@ -360,7 +360,7 @@ local function sort_by_category(data)
|
||||||
|
|
||||||
for i = 1, #items do
|
for i = 1, #items do
|
||||||
local item = items[i]
|
local item = items[i]
|
||||||
local tab = i3.minitabs[data.itab]
|
local tab = i4.minitabs[data.itab]
|
||||||
local to_add = tab.sorter(item, data)
|
local to_add = tab.sorter(item, data)
|
||||||
|
|
||||||
if to_add then
|
if to_add then
|
||||||
|
@ -382,8 +382,8 @@ end
|
||||||
|
|
||||||
local function get_recipes(player, item)
|
local function get_recipes(player, item)
|
||||||
item = core.registered_aliases[item] or item
|
item = core.registered_aliases[item] or item
|
||||||
local recipes = i3.recipes_cache[item]
|
local recipes = i4.recipes_cache[item]
|
||||||
local usages = i3.usages_cache[item]
|
local usages = i4.usages_cache[item]
|
||||||
|
|
||||||
if recipes then
|
if recipes then
|
||||||
recipes = apply_recipe_filters(recipes, player)
|
recipes = apply_recipe_filters(recipes, player)
|
||||||
|
@ -410,7 +410,7 @@ end
|
||||||
|
|
||||||
local function get_group_items(name)
|
local function get_group_items(name)
|
||||||
local groups = extract_groups(name)
|
local groups = extract_groups(name)
|
||||||
return i3.groups[name:sub(7)].items or groups_to_items(groups)
|
return i4.groups[name:sub(7)].items or groups_to_items(groups)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function craft_stack(player, data, craft_rcp)
|
local function craft_stack(player, data, craft_rcp)
|
||||||
|
@ -579,7 +579,7 @@ local function sort_inventory(player, data)
|
||||||
|
|
||||||
list = data.inv_compress and compress_items(list, start_i) or pre_sorting(list, start_i)
|
list = data.inv_compress and compress_items(list, start_i) or pre_sorting(list, start_i)
|
||||||
|
|
||||||
local new_inv = i3.sorting_methods[data.sort].func(list, data)
|
local new_inv = i4.sorting_methods[data.sort].func(list, data)
|
||||||
if not new_inv then return end
|
if not new_inv then return end
|
||||||
|
|
||||||
if not data.ignore_hotbar then
|
if not data.ignore_hotbar then
|
||||||
|
@ -830,7 +830,7 @@ local _ = {
|
||||||
vec_round = vector.round,
|
vec_round = vector.round,
|
||||||
}
|
}
|
||||||
|
|
||||||
function i3.get(...)
|
function i4.get(...)
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
||||||
for i, var in ipairs{...} do
|
for i, var in ipairs{...} do
|
||||||
|
|
|
@ -310,4 +310,4 @@ for _, v2 in ipairs(v) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.compress_groups, i3.compressed = compressed, _compressed
|
i4.compress_groups, i4.compressed = compressed, _compressed
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i4.set_fs
|
||||||
IMPORT("play_sound", "create_inventory")
|
IMPORT("play_sound", "create_inventory")
|
||||||
|
|
||||||
local trash = create_inventory("i3_trash", {
|
local trash = create_inventory("i3_trash", {
|
||||||
|
@ -10,7 +10,7 @@ local trash = create_inventory("i3_trash", {
|
||||||
inv:set_list(listname, {})
|
inv:set_list(listname, {})
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
data.armor_allow = nil
|
data.armor_allow = nil
|
||||||
|
|
||||||
play_sound(name, "i3_trash", 1.0)
|
play_sound(name, "i3_trash", 1.0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i4.set_fs
|
||||||
|
|
||||||
IMPORT("min", "max", "vec_round")
|
IMPORT("min", "max", "vec_round")
|
||||||
IMPORT("reg_items", "reg_aliases")
|
IMPORT("reg_items", "reg_aliases")
|
||||||
|
@ -20,7 +20,7 @@ local function inv_fields(player, data, fields)
|
||||||
data.font_size = tonumber(fields.sb_font_size:match"-?%d+$")
|
data.font_size = tonumber(fields.sb_font_size:match"-?%d+$")
|
||||||
end
|
end
|
||||||
|
|
||||||
local footer = data.footer_button and i3.footer_buttons[data.footer_button]
|
local footer = data.footer_button and i4.footer_buttons[data.footer_button]
|
||||||
if footer and footer.fields then
|
if footer and footer.fields then
|
||||||
if not footer.fields(player, data, fields) then
|
if not footer.fields(player, data, fields) then
|
||||||
data.footer_button = nil
|
data.footer_button = nil
|
||||||
|
@ -29,7 +29,7 @@ local function inv_fields(player, data, fields)
|
||||||
|
|
||||||
for field in pairs(fields) do
|
for field in pairs(fields) do
|
||||||
if sub(field, 1, 4) == "btn_" then
|
if sub(field, 1, 4) == "btn_" then
|
||||||
data.subcat = indexof(i3.categories, sub(field, 5))
|
data.subcat = indexof(i4.categories, sub(field, 5))
|
||||||
break
|
break
|
||||||
|
|
||||||
elseif sub(field, 1, 3) == "cb_" then
|
elseif sub(field, 1, 3) == "cb_" then
|
||||||
|
@ -117,7 +117,7 @@ local function inv_fields(player, data, fields)
|
||||||
data.bag_rename = true
|
data.bag_rename = true
|
||||||
|
|
||||||
elseif fields.confirm_rename then
|
elseif fields.confirm_rename then
|
||||||
local bag = get_detached_inv("bag", name)
|
local bag = get_detached_inv("i3:bag", name)
|
||||||
local bagstack = bag:get_stack("main", 1)
|
local bagstack = bag:get_stack("main", 1)
|
||||||
local meta = bagstack:get_meta()
|
local meta = bagstack:get_meta()
|
||||||
local desc = translate(data.lang_code, bagstack:get_description())
|
local desc = translate(data.lang_code, bagstack:get_description())
|
||||||
|
@ -136,7 +136,7 @@ local function inv_fields(player, data, fields)
|
||||||
data.bag_rename = nil
|
data.bag_rename = nil
|
||||||
|
|
||||||
elseif fields.waypoint_add then
|
elseif fields.waypoint_add then
|
||||||
local max_waypoints = i3.settings.max_waypoints
|
local max_waypoints = i4.settings.max_waypoints
|
||||||
|
|
||||||
if #data.waypoints >= max_waypoints then
|
if #data.waypoints >= max_waypoints then
|
||||||
play_sound(name, "i3_cannot", 0.8)
|
play_sound(name, "i3_cannot", 0.8)
|
||||||
|
@ -211,8 +211,8 @@ local function select_item(player, data, fields)
|
||||||
data.alt_items = copy(data.items)
|
data.alt_items = copy(data.items)
|
||||||
data.expand = item
|
data.expand = item
|
||||||
|
|
||||||
if i3.compress_groups[item] then
|
if i4.compress_groups[item] then
|
||||||
local items = copy(i3.compress_groups[item])
|
local items = copy(i4.compress_groups[item])
|
||||||
insert(items, fmt("_%s", item))
|
insert(items, fmt("_%s", item))
|
||||||
|
|
||||||
sort(items, function(a, b)
|
sort(items, function(a, b)
|
||||||
|
@ -347,7 +347,7 @@ local function rcp_fields(player, data, fields)
|
||||||
elseif fields.fav then
|
elseif fields.fav then
|
||||||
local fav = is_fav(data)
|
local fav = is_fav(data)
|
||||||
|
|
||||||
if #data.favs < i3.settings.max_favs and not fav then
|
if #data.favs < i4.settings.max_favs and not fav then
|
||||||
insert(data.favs, data.query_item)
|
insert(data.favs, data.query_item)
|
||||||
elseif fav then
|
elseif fav then
|
||||||
remove(data.favs, fav)
|
remove(data.favs, fav)
|
||||||
|
@ -398,7 +398,7 @@ local function home_footer_fields(player, data, fields)
|
||||||
else
|
else
|
||||||
msg(name, S"Welcome back home!")
|
msg(name, S"Welcome back home!")
|
||||||
end
|
end
|
||||||
-- Otherwise, use i3’s home.
|
-- Otherwise, use i4’s home.
|
||||||
elseif not data.home then
|
elseif not data.home then
|
||||||
msg(name, "No home set")
|
msg(name, "No home set")
|
||||||
elseif name then
|
elseif name then
|
||||||
|
@ -424,11 +424,12 @@ end
|
||||||
|
|
||||||
-- Fields input-handler for the settings footer-dialogue.
|
-- Fields input-handler for the settings footer-dialogue.
|
||||||
local function settings_footer_fields(player, data, fields)
|
local function settings_footer_fields(player, data, fields)
|
||||||
|
local name = player:get_player_name()
|
||||||
if fields.set_home and not check_privs(name, {home = true}) then
|
if fields.set_home and not check_privs(name, {home = true}) then
|
||||||
return msg(name, "'home' privilege missing")
|
return msg(name, "'home' privilege missing")
|
||||||
elseif fields.set_home then
|
elseif fields.set_home then
|
||||||
if sethome then
|
if sethome then
|
||||||
sethome.set(player:get_player_name(), player:get_pos())
|
sethome.set(name, player:get_pos())
|
||||||
else
|
else
|
||||||
data.home = pos_to_str(player:get_pos(), 1)
|
data.home = pos_to_str(player:get_pos(), 1)
|
||||||
end
|
end
|
||||||
|
@ -439,7 +440,7 @@ end
|
||||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
if formname == "i3_outdated" then
|
if formname == "i4_outdated" then
|
||||||
return false, core.kick_player(name, S"Your Minetest client needs updating (www.minetest.net)")
|
return false, core.kick_player(name, S"Your Minetest client needs updating (www.minetest.net)")
|
||||||
elseif formname ~= "" then
|
elseif formname ~= "" then
|
||||||
return false
|
return false
|
||||||
|
@ -453,7 +454,7 @@ core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print(dump(fields))
|
-- print(dump(fields))
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
local sb_inv = fields.scrbar_inv
|
local sb_inv = fields.scrbar_inv
|
||||||
|
@ -465,7 +466,7 @@ core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
for f in pairs(fields) do
|
for f in pairs(fields) do
|
||||||
if sub(f, 1, 4) == "tab_" then
|
if sub(f, 1, 4) == "tab_" then
|
||||||
local tabname = sub(f, 5)
|
local tabname = sub(f, 5)
|
||||||
i3.set_tab(player, tabname)
|
i4.set_tab(player, tabname)
|
||||||
break
|
break
|
||||||
elseif sub(f, 1, 5) == "itab_" then
|
elseif sub(f, 1, 5) == "itab_" then
|
||||||
data.pagenum = 1
|
data.pagenum = 1
|
||||||
|
@ -474,7 +475,7 @@ core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
break
|
break
|
||||||
elseif sub(f, 1, 7) == "footer_" then
|
elseif sub(f, 1, 7) == "footer_" then
|
||||||
local footer_name = sub(f, 8)
|
local footer_name = sub(f, 8)
|
||||||
for i, footer in ipairs(i3.footer_buttons) do
|
for i, footer in ipairs(i4.footer_buttons) do
|
||||||
if footer.name == footer_name then
|
if footer.name == footer_name then
|
||||||
data.footer_button = i
|
data.footer_button = i
|
||||||
break
|
break
|
||||||
|
@ -485,7 +486,7 @@ core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
rcp_fields(player, data, fields)
|
rcp_fields(player, data, fields)
|
||||||
|
|
||||||
local tab = i3.tabs[data.tab]
|
local tab = i4.tabs[data.tab]
|
||||||
if tab then
|
if tab then
|
||||||
if tab.slots then
|
if tab.slots then
|
||||||
inv_fields(player, data, fields)
|
inv_fields(player, data, fields)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
IMPORT("S")
|
IMPORT("S")
|
||||||
|
|
||||||
i3.group_stereotypes = {
|
i4.group_stereotypes = {
|
||||||
dye = "dye:white",
|
dye = "dye:white",
|
||||||
wool = "wool:white",
|
wool = "wool:white",
|
||||||
wood = "default:wood",
|
wood = "default:wood",
|
||||||
|
@ -18,7 +18,7 @@ i3.group_stereotypes = {
|
||||||
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.group_names = {
|
i4.group_names = {
|
||||||
dye = S"Any dye",
|
dye = S"Any dye",
|
||||||
coal = S"Any coal",
|
coal = S"Any coal",
|
||||||
sand = S"Any sand",
|
sand = S"Any sand",
|
||||||
|
|
84
src/gui.lua
84
src/gui.lua
|
@ -1,8 +1,8 @@
|
||||||
local damage_enabled = i3.settings.damage_enabled
|
local damage_enabled = i4.settings.damage_enabled
|
||||||
local debug_mode = i3.settings.debug_mode
|
local debug_mode = i4.settings.debug_mode
|
||||||
|
|
||||||
local model_aliases = i3.files.model_alias()
|
local model_aliases = i4.files.model_alias()
|
||||||
local PNG, styles, fs_elements, colors = i3.files.styles()
|
local PNG, styles, fs_elements, colors = i4.files.styles()
|
||||||
|
|
||||||
local sprintf = string.format
|
local sprintf = string.format
|
||||||
local VoxelArea, VoxelManip = VoxelArea, VoxelManip
|
local VoxelArea, VoxelManip = VoxelArea, VoxelManip
|
||||||
|
@ -29,7 +29,7 @@ end
|
||||||
|
|
||||||
local function repairable(tool)
|
local function repairable(tool)
|
||||||
local def = reg_tools[tool]
|
local def = reg_tools[tool]
|
||||||
return i3.toolrepair and def and def.groups and def.groups.disable_repair ~= 1
|
return i4.toolrepair and def and def.groups and def.groups.disable_repair ~= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local function weird_desc(str)
|
local function weird_desc(str)
|
||||||
|
@ -96,7 +96,7 @@ local function get_stack_max(inv, data, is_recipe, rcp)
|
||||||
local def = reg_items[item]
|
local def = reg_items[item]
|
||||||
|
|
||||||
if def then
|
if def then
|
||||||
local group_cache = i3.groups[name:sub(7)]
|
local group_cache = i4.groups[name:sub(7)]
|
||||||
local groups = group_cache and group_cache.groups or extract_groups(name)
|
local groups = group_cache and group_cache.groups or extract_groups(name)
|
||||||
|
|
||||||
if item_has_groups(def.groups, groups) then
|
if item_has_groups(def.groups, groups) then
|
||||||
|
@ -229,8 +229,8 @@ local function get_isometric_view(fs, pos, X, Y, t, cubes, depth, high)
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
for idx in area:iterp(pos1, pos2) do
|
for idx in area:iterp(pos1, pos2) do
|
||||||
local cube = i3.cubes[data[idx]]
|
local cube = i4.cubes[data[idx]]
|
||||||
local plant = i3.plants[data[idx]]
|
local plant = i4.plants[data[idx]]
|
||||||
local img = cube or plant
|
local img = cube or plant
|
||||||
|
|
||||||
if img then
|
if img then
|
||||||
|
@ -526,7 +526,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
|
|
||||||
local yextra = .2
|
local yextra = .2
|
||||||
|
|
||||||
for i, title in ipairs(i3.categories) do
|
for i, title in ipairs(i4.categories) do
|
||||||
local btn_name = fmt("btn_%s", title)
|
local btn_name = fmt("btn_%s", title)
|
||||||
fs("style[btn_%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]", title,
|
fs("style[btn_%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]", title,
|
||||||
data.subcat == i and PNG[fmt("%s_hover", title)] or PNG[title],
|
data.subcat == i and PNG[fmt("%s_hover", title)] or PNG[title],
|
||||||
|
@ -548,7 +548,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
get_crafting_tab_fs(fs, data, player, esc_name, yextra, ctn_len)
|
get_crafting_tab_fs(fs, data, player, esc_name, yextra, ctn_len)
|
||||||
|
|
||||||
elseif data.subcat == 2 then
|
elseif data.subcat == 2 then
|
||||||
if not i3.modules.armor then
|
if not i4.modules.armor then
|
||||||
return not_installed "3d_armor"
|
return not_installed "3d_armor"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
get_bag_fs(fs, data, bag_size, yextra)
|
get_bag_fs(fs, data, bag_size, yextra)
|
||||||
|
|
||||||
elseif data.subcat == 4 then
|
elseif data.subcat == 4 then
|
||||||
if not i3.modules.skins then
|
if not i4.modules.skins then
|
||||||
return not_installed "skinsdb"
|
return not_installed "skinsdb"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ local function settings_footer_fs(player, data, fs)
|
||||||
|
|
||||||
local home = data.home
|
local home = data.home
|
||||||
if sethome then
|
if sethome then
|
||||||
-- i3 stores home coordinates with one decimal of precision, as the blow fmt() statement
|
-- i4 stores home coordinates with one decimal of precision, as the blow fmt() statement
|
||||||
-- assumes. So we need to trim sethome’s coordinates to one decimal, likewise.
|
-- assumes. So we need to trim sethome’s coordinates to one decimal, likewise.
|
||||||
local home_pos = sethome.get(player:get_player_name())
|
local home_pos = sethome.get(player:get_player_name())
|
||||||
home = string.format("(%.1f,%.1f,%.1f)", home_pos.x, home_pos.y, home_pos.z)
|
home = string.format("(%.1f,%.1f,%.1f)", home_pos.x, home_pos.y, home_pos.z)
|
||||||
|
@ -665,7 +665,7 @@ local function settings_footer_fs(player, data, fs)
|
||||||
|
|
||||||
local methods = {}
|
local methods = {}
|
||||||
|
|
||||||
for _, v in ipairs(i3.sorting_methods) do
|
for _, v in ipairs(i4.sorting_methods) do
|
||||||
local name = toupper(v.name)
|
local name = toupper(v.name)
|
||||||
insert(methods, name)
|
insert(methods, name)
|
||||||
end
|
end
|
||||||
|
@ -673,7 +673,7 @@ local function settings_footer_fs(player, data, fs)
|
||||||
label(5.3, 10.4, ES"Sorting method:")
|
label(5.3, 10.4, ES"Sorting method:")
|
||||||
fs("dropdown[%f,%f;2.6,0.5;dd_sorting_method;%s;%u;true]", 5.3, 10.6, concat(methods, ","), data.sort)
|
fs("dropdown[%f,%f;2.6,0.5;dd_sorting_method;%s;%u;true]", 5.3, 10.6, concat(methods, ","), data.sort)
|
||||||
|
|
||||||
local desc = i3.sorting_methods[data.sort].description
|
local desc = i4.sorting_methods[data.sort].description
|
||||||
if desc then
|
if desc then
|
||||||
tooltip(5.3, 10.6, 2.4, 0.5, ESC(desc))
|
tooltip(5.3, 10.6, 2.4, 0.5, ESC(desc))
|
||||||
end
|
end
|
||||||
|
@ -694,8 +694,8 @@ end
|
||||||
-- Get the inventory-footer’s formspec.
|
-- Get the inventory-footer’s formspec.
|
||||||
local function get_footer(fs, data, player)
|
local function get_footer(fs, data, player)
|
||||||
-- Render individual footer buttons.
|
-- Render individual footer buttons.
|
||||||
local starting_x = 3.43 - (.3 * (#i3.footer_buttons - 4)) -- Center the icons
|
local starting_x = 3.43 - (.3 * (#i4.footer_buttons - 4)) -- Center the icons
|
||||||
for i, btn in ipairs(i3.footer_buttons) do
|
for i, btn in ipairs(i4.footer_buttons) do
|
||||||
local btn_name = "footer_" .. btn.name
|
local btn_name = "footer_" .. btn.name
|
||||||
fs("style[%s;fgimg=%s;fgimg_hovered=%s^\\[brighten^\\[colorize:#fff:100;content_offset=0]",
|
fs("style[%s;fgimg=%s;fgimg_hovered=%s^\\[brighten^\\[colorize:#fff:100;content_offset=0]",
|
||||||
btn_name, btn.image, btn.image)
|
btn_name, btn.image, btn.image)
|
||||||
|
@ -704,7 +704,7 @@ local function get_footer(fs, data, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Render the current-selected button’s formspec, if one is active.
|
-- Render the current-selected button’s formspec, if one is active.
|
||||||
footer = i3.footer_buttons[data.footer_button]
|
footer = i4.footer_buttons[data.footer_button]
|
||||||
if footer then
|
if footer then
|
||||||
if footer.formspec then
|
if footer.formspec then
|
||||||
footer.formspec(player, data, fs)
|
footer.formspec(player, data, fs)
|
||||||
|
@ -748,7 +748,7 @@ local function get_inventory_fs(player, data, fs)
|
||||||
|
|
||||||
if props.mesh ~= "" then
|
if props.mesh ~= "" then
|
||||||
local anim = player:get_local_animation()
|
local anim = player:get_local_animation()
|
||||||
local armor_skin = i3.modules.armor or i3.modules.skins
|
local armor_skin = i4.modules.armor or i4.modules.skins
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
||||||
for _, v in ipairs(props.textures) do
|
for _, v in ipairs(props.textures) do
|
||||||
|
@ -774,7 +774,7 @@ local function get_inventory_fs(player, data, fs)
|
||||||
if data.subcat == 3 and bag_size > 0 then
|
if data.subcat == 3 and bag_size > 0 then
|
||||||
max_val += min(0, ((bag_size - 1) * 10))
|
max_val += min(0, ((bag_size - 1) * 10))
|
||||||
|
|
||||||
elseif i3.modules.skins and data.subcat == 4 then
|
elseif i4.modules.skins and data.subcat == 4 then
|
||||||
local spp = 24
|
local spp = 24
|
||||||
local _skins = skins.get_skinlist_for_player(data.player_name)
|
local _skins = skins.get_skinlist_for_player(data.player_name)
|
||||||
local nb = #_skins
|
local nb = #_skins
|
||||||
|
@ -782,7 +782,7 @@ local function get_inventory_fs(player, data, fs)
|
||||||
|
|
||||||
max_val += ceil(num / 3.5) * (nb > spp and 34 or 31)
|
max_val += ceil(num / 3.5) * (nb > spp and 34 or 31)
|
||||||
|
|
||||||
elseif i3.modules.awards and data.subcat == 6 then
|
elseif i4.modules.awards and data.subcat == 6 then
|
||||||
award_list = awards.get_award_states(data.player_name)
|
award_list = awards.get_award_states(data.player_name)
|
||||||
award_list_nb = #award_list
|
award_list_nb = #award_list
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ local function get_tooltip(item, info, lang_code)
|
||||||
|
|
||||||
if info.groups then
|
if info.groups then
|
||||||
sort(info.groups)
|
sort(info.groups)
|
||||||
tooltip = i3.group_names[concat(info.groups, ",")]
|
tooltip = i4.group_names[concat(info.groups, ",")]
|
||||||
|
|
||||||
if not tooltip then
|
if not tooltip then
|
||||||
local groupstr = {}
|
local groupstr = {}
|
||||||
|
@ -862,7 +862,7 @@ local function get_tooltip(item, info, lang_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
if info.repair then
|
if info.repair then
|
||||||
tooltip = add(S("Repairable by step of @1", clr("#ff0", i3.toolrepair .. "%")))
|
tooltip = add(S("Repairable by step of @1", clr("#ff0", i4.toolrepair .. "%")))
|
||||||
end
|
end
|
||||||
|
|
||||||
if info.rarity then
|
if info.rarity then
|
||||||
|
@ -906,7 +906,7 @@ local function get_true_count(data, count, is_recipe, is_usage)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, right, btn_size, btn_size2)
|
local function get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, right, btn_size, btn_size2)
|
||||||
local custom_recipe = i3.craft_types[rcp.type]
|
local custom_recipe = i4.craft_types[rcp.type]
|
||||||
local cooking = rcp.type == "cooking"
|
local cooking = rcp.type == "cooking"
|
||||||
local fuel = rcp.type == "fuel"
|
local fuel = rcp.type == "fuel"
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, righ
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local BTN_SIZE = i3.settings.item_btn_size
|
local BTN_SIZE = i4.settings.item_btn_size
|
||||||
local arrow_X = right + 0.2 + (btn_size2 or BTN_SIZE)
|
local arrow_X = right + 0.2 + (btn_size2 or BTN_SIZE)
|
||||||
local X = arrow_X + 1.2
|
local X = arrow_X + 1.2
|
||||||
local Y = data.yoffset + 1.4
|
local Y = data.yoffset + 1.4
|
||||||
|
@ -978,7 +978,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, righ
|
||||||
local unknown = not def or nil
|
local unknown = not def or nil
|
||||||
local desc = def and def.description
|
local desc = def and def.description
|
||||||
local weird = name ~= "" and desc and weird_desc(desc) or nil
|
local weird = name ~= "" and desc and weird_desc(desc) or nil
|
||||||
local burntime = i3.fuel_cache[name] and i3.fuel_cache[name].burntime
|
local burntime = i4.fuel_cache[name] and i4.fuel_cache[name].burntime
|
||||||
|
|
||||||
local short_desc = meta:get_string"short_description"
|
local short_desc = meta:get_string"short_description"
|
||||||
local long_desc = meta:get_string"description"
|
local long_desc = meta:get_string"description"
|
||||||
|
@ -1002,7 +1002,7 @@ end
|
||||||
local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
||||||
local width = rcp.width or 1
|
local width = rcp.width or 1
|
||||||
local right = 0
|
local right = 0
|
||||||
local btn_size, _btn_size = i3.settings.item_btn_size
|
local btn_size, _btn_size = i4.settings.item_btn_size
|
||||||
local cooktime, shapeless
|
local cooktime, shapeless
|
||||||
|
|
||||||
if rcp.type == "cooking" then
|
if rcp.type == "cooking" then
|
||||||
|
@ -1061,7 +1061,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
||||||
end
|
end
|
||||||
|
|
||||||
local groups
|
local groups
|
||||||
local group_cache = i3.groups[name:sub(7)]
|
local group_cache = i4.groups[name:sub(7)]
|
||||||
|
|
||||||
if is_group(name) then
|
if is_group(name) then
|
||||||
groups = group_cache and group_cache.groups or extract_groups(name)
|
groups = group_cache and group_cache.groups or extract_groups(name)
|
||||||
|
@ -1132,7 +1132,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
||||||
unknown = not groups and unknown or nil
|
unknown = not groups and unknown or nil
|
||||||
local desc = def and def.description
|
local desc = def and def.description
|
||||||
local weird = name ~= "" and desc and weird_desc(desc) or nil
|
local weird = name ~= "" and desc and weird_desc(desc) or nil
|
||||||
local burntime = i3.fuel_cache[name] and i3.fuel_cache[name].burntime
|
local burntime = i4.fuel_cache[name] and i4.fuel_cache[name].burntime
|
||||||
|
|
||||||
local short_desc = meta:get_string"short_description"
|
local short_desc = meta:get_string"short_description"
|
||||||
local long_desc = meta:get_string"description"
|
local long_desc = meta:get_string"description"
|
||||||
|
@ -1162,7 +1162,7 @@ local function get_rcp_lbl(fs, data, panel, rn, is_recipe, is_usage)
|
||||||
local rcp = is_recipe and panel.rcp[data.rnum] or panel.rcp[data.unum]
|
local rcp = is_recipe and panel.rcp[data.rnum] or panel.rcp[data.unum]
|
||||||
|
|
||||||
if rcp.custom then
|
if rcp.custom then
|
||||||
local craft_type = i3.craft_types[rcp.type]
|
local craft_type = i4.craft_types[rcp.type]
|
||||||
if craft_type then
|
if craft_type then
|
||||||
local desc = craft_type.description
|
local desc = craft_type.description
|
||||||
hypertext(data.inv_width + 4.8, data.yoffset + 0.12, 3, 1, "custom_rcp",
|
hypertext(data.inv_width + 4.8, data.yoffset + 0.12, 3, 1, "custom_rcp",
|
||||||
|
@ -1245,7 +1245,7 @@ end
|
||||||
local function get_header(fs, data)
|
local function get_header(fs, data)
|
||||||
local fav = is_fav(data)
|
local fav = is_fav(data)
|
||||||
local nfavs = #data.favs
|
local nfavs = #data.favs
|
||||||
local max_favs = i3.settings.max_favs
|
local max_favs = i4.settings.max_favs
|
||||||
local star_x, star_y, size = data.inv_width + 0.3, data.yoffset + 0.2, 0.4
|
local star_x, star_y, size = data.inv_width + 0.3, data.yoffset + 0.2, 0.4
|
||||||
|
|
||||||
if nfavs < max_favs or (nfavs == max_favs and fav) then
|
if nfavs < max_favs or (nfavs == max_favs and fav) then
|
||||||
|
@ -1374,7 +1374,7 @@ local function get_rcp_extra(fs, data, player, panel, is_recipe, is_usage)
|
||||||
|
|
||||||
for item, count in pairs(missing) do
|
for item, count in pairs(missing) do
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
local name = is_group(item) and (i3.group_names[item:sub(7)] or item) or
|
local name = is_group(item) and (i4.group_names[item:sub(7)] or item) or
|
||||||
get_desc(item, data.lang_code)
|
get_desc(item, data.lang_code)
|
||||||
str = fmt("%s\n%s %s", str, clr("#ff0", count .. '×'), name)
|
str = fmt("%s\n%s %s", str, clr("#ff0", count .. '×'), name)
|
||||||
end
|
end
|
||||||
|
@ -1399,7 +1399,7 @@ local function hide_items(player, data)
|
||||||
|
|
||||||
for i = 1, #data.items do
|
for i = 1, #data.items do
|
||||||
local item = data.items[i]
|
local item = data.items[i]
|
||||||
if not i3.compressed[item] then
|
if not i4.compressed[item] then
|
||||||
insert(new, item)
|
insert(new, item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1446,7 +1446,7 @@ local function get_header_items_fs(fs, data)
|
||||||
local cat = {{"all", "all items"}}
|
local cat = {{"all", "all items"}}
|
||||||
|
|
||||||
if not recipe_filter_set() then
|
if not recipe_filter_set() then
|
||||||
for _, v in ipairs(i3.minitabs) do
|
for _, v in ipairs(i4.minitabs) do
|
||||||
if v.name == "nodes" then
|
if v.name == "nodes" then
|
||||||
insert(cat, {"node", "nodes only"})
|
insert(cat, {"node", "nodes only"})
|
||||||
end
|
end
|
||||||
|
@ -1519,7 +1519,7 @@ end
|
||||||
local function get_minitabs(fs, data, player, full_height)
|
local function get_minitabs(fs, data, player, full_height)
|
||||||
local minitabs = {}
|
local minitabs = {}
|
||||||
|
|
||||||
for i, v in ipairs(i3.minitabs) do
|
for i, v in ipairs(i4.minitabs) do
|
||||||
local access = v.access
|
local access = v.access
|
||||||
if access == nil or access(player, data) then
|
if access == nil or access(player, data) then
|
||||||
minitabs[i] = v.description
|
minitabs[i] = v.description
|
||||||
|
@ -1567,7 +1567,7 @@ local function get_items_fs(fs, data, player, full_height)
|
||||||
local lbl = ES"No item to show"
|
local lbl = ES"No item to show"
|
||||||
local icon, width, offset = PNG.no_result, 4, 2
|
local icon, width, offset = PNG.no_result, 4, 2
|
||||||
|
|
||||||
if recipe_filter_set() and #i3.init_items > 0 and data.filter == "" then
|
if recipe_filter_set() and #i4.init_items > 0 and data.filter == "" then
|
||||||
lbl = ES"Collect items to reveal more recipes" -- Progressive mode, etc.
|
lbl = ES"Collect items to reveal more recipes" -- Progressive mode, etc.
|
||||||
icon, width, offset = PNG.find_more, 2.5, 2.75
|
icon, width, offset = PNG.find_more, 2.5, 2.75
|
||||||
end
|
end
|
||||||
|
@ -1627,7 +1627,7 @@ local function get_items_fs(fs, data, player, full_height)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_favs(fs, data)
|
local function get_favs(fs, data)
|
||||||
local btn_size = i3.settings.item_btn_size
|
local btn_size = i4.settings.item_btn_size
|
||||||
label(data.inv_width + 0.4, data.yoffset + 0.4, ES"Bookmarks")
|
label(data.inv_width + 0.4, data.yoffset + 0.4, ES"Bookmarks")
|
||||||
|
|
||||||
for i, item in ipairs(data.favs) do
|
for i, item in ipairs(data.favs) do
|
||||||
|
@ -1665,9 +1665,9 @@ end
|
||||||
|
|
||||||
local function get_tabs_fs(fs, player, data, full_height)
|
local function get_tabs_fs(fs, player, data, full_height)
|
||||||
local tab_len, tab_hgh, c, over = 3, 0.5, 0
|
local tab_len, tab_hgh, c, over = 3, 0.5, 0
|
||||||
local _tabs = copy(i3.tabs)
|
local _tabs = copy(i4.tabs)
|
||||||
|
|
||||||
for i, def in ipairs(i3.tabs) do
|
for i, def in ipairs(i4.tabs) do
|
||||||
if def.access and not def.access(player, data) then
|
if def.access and not def.access(player, data) then
|
||||||
remove(_tabs, i)
|
remove(_tabs, i)
|
||||||
end
|
end
|
||||||
|
@ -1768,13 +1768,13 @@ local function make_fs(player, data)
|
||||||
local full_height = 12
|
local full_height = 12
|
||||||
|
|
||||||
fs("formspec_version[%u]size[%f,%f]no_prepend[]bgcolor[#0000]",
|
fs("formspec_version[%u]size[%f,%f]no_prepend[]bgcolor[#0000]",
|
||||||
i3.settings.min_fs_version, data.inv_width + 8, full_height)
|
i4.settings.min_fs_version, data.inv_width + 8, full_height)
|
||||||
|
|
||||||
fs(styles)
|
fs(styles)
|
||||||
|
|
||||||
bg9(0, 0, data.inv_width, full_height, PNG.bg_full)
|
bg9(0, 0, data.inv_width, full_height, PNG.bg_full)
|
||||||
|
|
||||||
local tab = i3.tabs[data.tab]
|
local tab = i4.tabs[data.tab]
|
||||||
|
|
||||||
if tab then
|
if tab then
|
||||||
if tab.formspec then
|
if tab.formspec then
|
||||||
|
@ -1796,9 +1796,9 @@ local function make_fs(player, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local visible_tabs = #i3.tabs
|
local visible_tabs = #i4.tabs
|
||||||
|
|
||||||
for _, def in ipairs(i3.tabs) do
|
for _, def in ipairs(i4.tabs) do
|
||||||
if def.access and not def.access(player, data) then
|
if def.access and not def.access(player, data) then
|
||||||
visible_tabs -= 1
|
visible_tabs -= 1
|
||||||
end
|
end
|
||||||
|
|
16
src/hud.lua
16
src/hud.lua
|
@ -3,12 +3,12 @@ IMPORT("get_connected_players", "add_hud_waypoint")
|
||||||
|
|
||||||
local function init_hud(player)
|
local function init_hud(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
local wdesc_y = -90
|
local wdesc_y = -90
|
||||||
|
|
||||||
if core.global_exists"hb" then
|
if core.global_exists"hb" then
|
||||||
wdesc_y -= ceil(hb.hudbars_count / 2) * 5
|
wdesc_y -= ceil(hb.hudbars_count / 2) * 5
|
||||||
elseif not i3.settings.damage_enabled then
|
elseif not i4.settings.damage_enabled then
|
||||||
wdesc_y += 15
|
wdesc_y += 15
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ local function show_hud(player, data, notif, idx, dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
if notif.show then
|
if notif.show then
|
||||||
local speed = i3.settings.hud_speed * (100 * get_progress(offset.y, notif.max.y)) * dt
|
local speed = i4.settings.hud_speed * (100 * get_progress(offset.y, notif.max.y)) * dt
|
||||||
|
|
||||||
for _, def in pairs(notif.elems) do
|
for _, def in pairs(notif.elems) do
|
||||||
local hud_info = player:hud_get(def)
|
local hud_info = player:hud_get(def)
|
||||||
|
@ -59,8 +59,8 @@ local function show_hud(player, data, notif, idx, dt)
|
||||||
y = hud_info.offset.y - (speed * max(1, (#data.hud.notifs - idx + 1) / 1.45))
|
y = hud_info.offset.y - (speed * max(1, (#data.hud.notifs - idx + 1) / 1.45))
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
elseif notif.show == false and notif.hud_timer >= i3.settings.hud_timer_max then
|
elseif notif.show == false and notif.hud_timer >= i4.settings.hud_timer_max then
|
||||||
local speed = (i3.settings.hud_speed * 2.6) * (100 * get_progress(offset.x, notif.max.x)) * dt
|
local speed = (i4.settings.hud_speed * 2.6) * (100 * get_progress(offset.x, notif.max.x)) * dt
|
||||||
|
|
||||||
for _, def in pairs(notif.elems) do
|
for _, def in pairs(notif.elems) do
|
||||||
local hud_info = player:hud_get(def)
|
local hud_info = player:hud_get(def)
|
||||||
|
@ -85,7 +85,7 @@ core.register_globalstep(function(dt)
|
||||||
for i = 1, players[0] do
|
for i = 1, players[0] do
|
||||||
local player = players[i]
|
local player = players[i]
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
for idx, notif in ipairs(data.hud.notifs) do
|
for idx, notif in ipairs(data.hud.notifs) do
|
||||||
|
@ -107,7 +107,7 @@ core.register_globalstep(function(dt)
|
||||||
local wieldidx = player:get_wield_index()
|
local wieldidx = player:get_wield_index()
|
||||||
|
|
||||||
if wieldidx == data.old_wieldidx then
|
if wieldidx == data.old_wieldidx then
|
||||||
if data.timer >= i3.settings.wielditem_fade_after and has_text then
|
if data.timer >= i4.settings.wielditem_fade_after and has_text then
|
||||||
player:hud_change(data.hud.wielditem, "text", "")
|
player:hud_change(data.hud.wielditem, "text", "")
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
@ -130,7 +130,7 @@ end)
|
||||||
|
|
||||||
local function init_waypoints(player)
|
local function init_waypoints(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
data.waypoints = data.waypoints or {}
|
data.waypoints = data.waypoints or {}
|
||||||
|
|
||||||
for _, v in ipairs(data.waypoints) do
|
for _, v in ipairs(data.waypoints) do
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
local fmt, split = string.format, string.split
|
local fmt, split = string.format, string.split
|
||||||
local var = "[%w%.%[%]\"\'_]"
|
local var = "[%w%.%[%]\"\'_]"
|
||||||
local modpath = core.get_modpath"i3"
|
local modpath = core.get_modpath"i4"
|
||||||
local _,_, fs_elements = dofile(modpath .. "/src/styles.lua")
|
local _,_, fs_elements = dofile(modpath .. "/src/styles.lua")
|
||||||
|
|
||||||
local operators = {
|
local operators = {
|
||||||
|
@ -42,7 +42,7 @@ local operators = {
|
||||||
|
|
||||||
local function compile(data)
|
local function compile(data)
|
||||||
data = data:gsub("IMPORT%((.-)%)", function(a)
|
data = data:gsub("IMPORT%((.-)%)", function(a)
|
||||||
return "local " .. a:gsub("\"", "") .. " = i3.get(" .. a .. ")"
|
return "local " .. a:gsub("\"", "") .. " = i4.get(" .. a .. ")"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
data = data:gsub("([%w_]+)%(", function(a)
|
data = data:gsub("([%w_]+)%(", function(a)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
local set_fs = i3.set_fs
|
local set_fs = i4.set_fs
|
||||||
local hud_notif = i3.hud_notif
|
local hud_notif = i4.hud_notif
|
||||||
local POLL_FREQ = 0.25
|
local POLL_FREQ = 0.25
|
||||||
|
|
||||||
IMPORT("reg_items", "reg_nodes", "fmt", "table_merge", "array_diff")
|
IMPORT("reg_items", "reg_nodes", "fmt", "table_merge", "array_diff")
|
||||||
IMPORT("is_group", "extract_groups", "item_has_groups", "apply_recipe_filters", "sort_by_category")
|
IMPORT("is_group", "extract_groups", "item_has_groups", "apply_recipe_filters", "sort_by_category")
|
||||||
|
|
||||||
i3.remove_minitab"nodes"
|
i4.remove_minitab"nodes"
|
||||||
i3.remove_minitab"items"
|
i4.remove_minitab"items"
|
||||||
|
|
||||||
i3.new_minitab("unlocked", {
|
i4.new_minitab("unlocked", {
|
||||||
description = "Unlocked",
|
description = "Unlocked",
|
||||||
|
|
||||||
sorter = function(item, data)
|
sorter = function(item, data)
|
||||||
|
@ -19,10 +19,10 @@ i3.new_minitab("unlocked", {
|
||||||
local function get_filtered_items(player, data)
|
local function get_filtered_items(player, data)
|
||||||
local items, known = {}, 0
|
local items, known = {}, 0
|
||||||
|
|
||||||
for i = 1, #i3.init_items do
|
for i = 1, #i4.init_items do
|
||||||
local item = i3.init_items[i]
|
local item = i4.init_items[i]
|
||||||
local recipes = i3.recipes_cache[item]
|
local recipes = i4.recipes_cache[item]
|
||||||
local usages = i3.usages_cache[item]
|
local usages = i4.usages_cache[item]
|
||||||
|
|
||||||
recipes = #apply_recipe_filters(recipes or {}, player)
|
recipes = #apply_recipe_filters(recipes or {}, player)
|
||||||
usages = #apply_recipe_filters(usages or {}, player)
|
usages = #apply_recipe_filters(usages or {}, player)
|
||||||
|
@ -43,7 +43,7 @@ local function item_in_inv(item, inv_items)
|
||||||
|
|
||||||
if is_group(item) then
|
if is_group(item) then
|
||||||
local groupname = item:sub(7)
|
local groupname = item:sub(7)
|
||||||
local group_cache = i3.groups[groupname]
|
local group_cache = i4.groups[groupname]
|
||||||
local groups = group_cache and group_cache.groups or extract_groups(item)
|
local groups = group_cache and group_cache.groups or extract_groups(item)
|
||||||
|
|
||||||
for i = 1, inv_items_size do
|
for i = 1, inv_items_size do
|
||||||
|
@ -78,7 +78,7 @@ local function progressive_filter(recipes, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
|
|
||||||
if #data.inv_items == 0 then
|
if #data.inv_items == 0 then
|
||||||
return {}
|
return {}
|
||||||
|
@ -148,7 +148,7 @@ local function poll_new_items(player, data, join)
|
||||||
|
|
||||||
if reg_nodes[last_discovered] then
|
if reg_nodes[last_discovered] then
|
||||||
local id = core.get_content_id(last_discovered)
|
local id = core.get_content_id(last_discovered)
|
||||||
img = i3.cubes[id] or img
|
img = i4.cubes[id] or img
|
||||||
end
|
end
|
||||||
|
|
||||||
hud_notif(data.player_name, msg, img)
|
hud_notif(data.player_name, msg, img)
|
||||||
|
@ -163,11 +163,11 @@ local function poll_new_items(player, data, join)
|
||||||
core.after(POLL_FREQ, poll_new_items, player, data)
|
core.after(POLL_FREQ, poll_new_items, player, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.add_recipe_filter("Default progressive filter", progressive_filter)
|
i4.add_recipe_filter("Default progressive filter", progressive_filter)
|
||||||
|
|
||||||
core.register_on_joinplayer(function(player)
|
core.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = i3.data[name]
|
local data = i4.data[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
data.inv_items = data.inv_items or {}
|
data.inv_items = data.inv_items or {}
|
||||||
|
|
|
@ -25,7 +25,7 @@ local PNG = {
|
||||||
book = "i3_book.png",
|
book = "i3_book.png",
|
||||||
sign = "i3_sign.png",
|
sign = "i3_sign.png",
|
||||||
cancel = "i3_cancel.png",
|
cancel = "i3_cancel.png",
|
||||||
crafting = "i3_crafting.png",
|
crafting = "i4_crafting.png",
|
||||||
slot = "i3_slot.png^\\[resize:128x128",
|
slot = "i3_slot.png^\\[resize:128x128",
|
||||||
pagenum_hover = "i3_slot.png^\\[resize:128x128^\\[opacity:130",
|
pagenum_hover = "i3_slot.png^\\[resize:128x128^\\[opacity:130",
|
||||||
tab = "i3_tab.png",
|
tab = "i3_tab.png",
|
||||||
|
@ -59,7 +59,7 @@ local PNG = {
|
||||||
|
|
||||||
cancel_hover = "i3_cancel.png^\\[brighten",
|
cancel_hover = "i3_cancel.png^\\[brighten",
|
||||||
search_hover = "i3_search.png^\\[brighten",
|
search_hover = "i3_search.png^\\[brighten",
|
||||||
crafting_hover = "i3_crafting.png^\\[brighten",
|
crafting_hover = "i4_crafting.png^\\[brighten",
|
||||||
trash_hover = "i3_trash.png^\\[brighten^\\[colorize:#f00:100",
|
trash_hover = "i3_trash.png^\\[brighten^\\[colorize:#f00:100",
|
||||||
compress_hover = "i3_compress.png^\\[brighten",
|
compress_hover = "i3_compress.png^\\[brighten",
|
||||||
sort_hover = "i3_sort.png^\\[brighten",
|
sort_hover = "i3_sort.png^\\[brighten",
|
||||||
|
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
Ŝarĝante…
Reference in New Issue