mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 09:00:23 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
815651a32f | |||
b8db525dac | |||
cbf6256593 | |||
893959b5d4 | |||
8a5a14747e | |||
b53959f177 | |||
685b40f318 | |||
e96d279d29 | |||
c87a179cb5 |
4
API.md
4
API.md
@ -42,6 +42,10 @@ Updates the current formspec. `extra_formspec` adds an additional formspec strin
|
||||
|
||||
Deletes a tab by name.
|
||||
|
||||
#### `i3.get_current_tab(player)`
|
||||
|
||||
Returns the current player tab. `player` is an `ObjectRef` to the user.
|
||||
|
||||
#### `i3.set_tab(player[, tabname])`
|
||||
|
||||
Sets the current tab by name. `player` is an `ObjectRef` to the user.
|
||||
|
@ -31,7 +31,7 @@ To enable it: `i3_progressive_mode = true` in `minetest.conf`.*
|
||||
|
||||
#### Recommendations
|
||||
|
||||
To use this mod in the best conditions, it's recommended to follow these recommendations:
|
||||
To use this mod in the best conditions:
|
||||
|
||||
- Use LuaJIT
|
||||
- Use a HiDPI widescreen display
|
||||
|
@ -44,7 +44,7 @@ local to_compress = {
|
||||
["default:mese_post_light"] = {
|
||||
replace = "mese_post_light",
|
||||
by = {
|
||||
"mese_post_light_acacia",
|
||||
"mese_post_light_acacia_wood",
|
||||
"mese_post_light_aspen_wood",
|
||||
"mese_post_light_junglewood",
|
||||
"mese_post_light_pine_wood",
|
||||
|
101
init.lua
101
init.lua
@ -738,7 +738,7 @@ local function drop_table(name, drop)
|
||||
if not empty and (dname ~= name or (dname == name and dcount > 1)) then
|
||||
local rarity = valid_rarity and di.rarity
|
||||
|
||||
i3.register_craft{
|
||||
i3.register_craft {
|
||||
type = rarity and "digging_chance" or "digging",
|
||||
items = {name},
|
||||
output = fmt("%s %u", dname, dcount),
|
||||
@ -762,7 +762,7 @@ local function cache_drops(name, drop)
|
||||
local empty = dstack:is_empty()
|
||||
|
||||
if not empty and dname ~= name then
|
||||
i3.register_craft{
|
||||
i3.register_craft {
|
||||
type = "digging",
|
||||
items = {name},
|
||||
output = drop,
|
||||
@ -1014,16 +1014,13 @@ local function spawn_item(player, stack)
|
||||
core.add_item(look_at, stack)
|
||||
end
|
||||
|
||||
local function get_stack(player, stack, str)
|
||||
local function get_stack(player, stack)
|
||||
local inv = player:get_inventory()
|
||||
local name = player:get_player_name()
|
||||
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
msg(name, S("@1 added in your inventory", str))
|
||||
else
|
||||
spawn_item(player, stack)
|
||||
msg(name, S("@1 spawned", str))
|
||||
end
|
||||
end
|
||||
|
||||
@ -1063,22 +1060,13 @@ local function craft_stack(player, data, craft_rcp)
|
||||
end
|
||||
|
||||
local count = stackcount * scrbar_val
|
||||
local desc = get_desc(stackname)
|
||||
local iter = ceil(count / stackmax)
|
||||
local leftover = count
|
||||
|
||||
for _ = 1, iter do
|
||||
local c = min(stackmax, leftover)
|
||||
local str
|
||||
|
||||
if c > 1 then
|
||||
str = clr("#ff0", fmt("%s x %s", c, desc))
|
||||
else
|
||||
str = clr("#ff0", fmt("%s", desc))
|
||||
end
|
||||
|
||||
local stack = ItemStack(fmt("%s %s", stackname, c))
|
||||
get_stack(player, stack, str)
|
||||
get_stack(player, stack)
|
||||
leftover = leftover - stackmax
|
||||
end
|
||||
end
|
||||
@ -1155,7 +1143,8 @@ local function select_item(player, name, data, _f)
|
||||
local stack = ItemStack(item)
|
||||
local stackmax = stack:get_stack_max()
|
||||
stack = fmt("%s %s", item, stackmax)
|
||||
return get_stack(player, stack, clr("#ff0", fmt("%u x %s", stackmax, get_desc(item))))
|
||||
|
||||
return get_stack(player, stack)
|
||||
end
|
||||
|
||||
if item == data.query_item then return end
|
||||
@ -1389,22 +1378,34 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||
local meta = item:get_meta()
|
||||
local name = item:get_name()
|
||||
local count = item:get_count()
|
||||
|
||||
local X = ceil((i - 1) % width - width)
|
||||
X = X + (X * 0.2) + data.inv_width + 3.9
|
||||
|
||||
local Y = ceil(i / width) - min(2, rows)
|
||||
Y = Y + (Y * 0.15) + data.yoffset + 1.4
|
||||
local X, Y
|
||||
|
||||
if large_recipe then
|
||||
btn_size = (3 / width) * (3 / rows) + 0.3
|
||||
local a, b = 3, 3
|
||||
local add_x, add_y = 0, 0
|
||||
|
||||
if width < 3 then
|
||||
a, b = width * 2, 1
|
||||
add_x = 2
|
||||
elseif rows < 3 then
|
||||
a, b = 1, rows * 2
|
||||
add_y = 1.4
|
||||
end
|
||||
|
||||
btn_size = (a / width) * (b / rows) + 0.3
|
||||
_btn_size = btn_size
|
||||
|
||||
local xi = (i - 1) % width
|
||||
local yi = floor((i - 1) / width)
|
||||
|
||||
X = btn_size * xi + data.inv_width + 0.3 + (xi * 0.05)
|
||||
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05)
|
||||
X = btn_size * xi + data.inv_width + 0.3 + (xi * 0.05) + add_x
|
||||
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05) + add_y
|
||||
else
|
||||
X = ceil((i - 1) % width - width)
|
||||
X = X + (X * 0.2) + data.inv_width + 3.9
|
||||
|
||||
Y = ceil(i / width) - min(2, rows)
|
||||
Y = Y + (Y * 0.15) + data.yoffset + 1.4
|
||||
end
|
||||
|
||||
if X > right then
|
||||
@ -1550,7 +1551,7 @@ local function get_model_fs(fs, data, def, model_alias)
|
||||
_name = fmt("%s^[multiply:%s", v.name, v.color)
|
||||
end
|
||||
elseif v.animation then
|
||||
_name = fmt("%s^[verticalframe:%u:0", v.name, v.animation.aspect_h)
|
||||
_name = fmt("%s^[verticalframe:%u:0", v.name, v.animation.frames_h or v.animation.aspect_h)
|
||||
end
|
||||
|
||||
t[#t + 1] = _name or v.name or v
|
||||
@ -1706,7 +1707,7 @@ local function get_items_fs(fs, data, full_height)
|
||||
data.items = new
|
||||
end
|
||||
|
||||
local items = data.alt_items or data.items
|
||||
local items = data.alt_items or data.items or {}
|
||||
local rows, lines = 8, 12
|
||||
local ipp = rows * lines
|
||||
local size = 0.85
|
||||
@ -2247,6 +2248,13 @@ function i3.remove_tab(tabname)
|
||||
end
|
||||
end
|
||||
|
||||
function i3.get_current_tab(player)
|
||||
local name = player:get_player_name()
|
||||
local data = pdata[name]
|
||||
|
||||
return data.current_tab
|
||||
end
|
||||
|
||||
function i3.set_tab(player, tabname)
|
||||
local name = player:get_player_name()
|
||||
local data = pdata[name]
|
||||
@ -2416,6 +2424,14 @@ local function rcp_fields(player, data, fields)
|
||||
|
||||
elseif fields.craft_rcp or fields.craft_usg then
|
||||
craft_stack(player, data, fields.craft_rcp)
|
||||
|
||||
if fields.craft_rcp then
|
||||
data.export_rcp = nil
|
||||
data.scrbar_rcp = 1
|
||||
else
|
||||
data.export_usg = nil
|
||||
data.scrbar_usg = 1
|
||||
end
|
||||
else
|
||||
select_item(player, name, data, fields)
|
||||
end
|
||||
@ -2745,8 +2761,6 @@ if rawget(_G, "awards") then
|
||||
local player = core.get_player_by_name(name)
|
||||
set_fs(player)
|
||||
end)
|
||||
|
||||
core.register_on_dieplayer(set_fs)
|
||||
end
|
||||
|
||||
core.register_on_chatcommand(function(name)
|
||||
@ -3022,11 +3036,13 @@ core.register_on_dieplayer(function(player)
|
||||
local data = pdata[name]
|
||||
if not data then return end
|
||||
|
||||
if data.bag_size then
|
||||
data.bag_size = nil
|
||||
data.bag:set_list("main", {})
|
||||
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size("main", INV_SIZE)
|
||||
end
|
||||
|
||||
set_fs(player)
|
||||
end)
|
||||
@ -3046,7 +3062,7 @@ local function save_data(player_name)
|
||||
if not META_SAVES[dat] then
|
||||
_pdata[name][dat] = nil
|
||||
|
||||
if player_name then
|
||||
if player_name and pdata[player_name] then
|
||||
pdata[player_name][dat] = nil -- To free up some memory
|
||||
end
|
||||
end
|
||||
@ -3229,6 +3245,7 @@ if progressive_mode then
|
||||
number = 0xffffff,
|
||||
text = "",
|
||||
z_index = 0xDEAD,
|
||||
style = 1,
|
||||
},
|
||||
}
|
||||
end
|
||||
@ -3256,7 +3273,8 @@ if progressive_mode then
|
||||
end
|
||||
|
||||
player:hud_change(data.hud.text, "text",
|
||||
S("@1 new recipe(s) discovered!", data.discovered))
|
||||
fmt("%u new recipe%s unlocked!",
|
||||
data.discovered, data.discovered > 1 and "s" or ""))
|
||||
|
||||
elseif data.show_hud == false then
|
||||
if data.hud_timer >= HUD_TIMER_MAX then
|
||||
@ -3314,19 +3332,17 @@ if progressive_mode then
|
||||
|
||||
poll_new_items()
|
||||
|
||||
if singleplayer then
|
||||
core.register_globalstep(function()
|
||||
local players = core.get_connected_players()
|
||||
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
local name = player:get_player_name()
|
||||
local name = "singleplayer"
|
||||
local player = core.get_player_by_name(name)
|
||||
local data = pdata[name]
|
||||
|
||||
if data and data.show_hud ~= nil and singleplayer then
|
||||
if data and data.show_hud ~= nil then
|
||||
show_hud_success(player, data)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
i3.add_recipe_filter("Default progressive filter", progressive_filter)
|
||||
|
||||
@ -3338,12 +3354,19 @@ if progressive_mode then
|
||||
data.inv_items = data.inv_items or {}
|
||||
data.known_recipes = data.known_recipes or 0
|
||||
|
||||
local oldknown = data.known_recipes
|
||||
local items = get_filtered_items(player, data)
|
||||
data.discovered = data.known_recipes - oldknown
|
||||
|
||||
data.items_raw = items
|
||||
search(data)
|
||||
|
||||
if singleplayer then
|
||||
init_hud(player, data)
|
||||
|
||||
if data.show_hud == nil and data.discovered > 0 then
|
||||
data.show_hud = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -20,6 +20,139 @@ i3.register_craft({
|
||||
items = {"default:copper_ingot 7, default:tin_ingot, default:steel_ingot 2"},
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X",
|
||||
"#",
|
||||
"X",
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X",
|
||||
"#X",
|
||||
"X",
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X#",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X#X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X#XX",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X#XX",
|
||||
"X#X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X#XX",
|
||||
"X#X",
|
||||
"#",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X##XX",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X##X#X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X##X#X",
|
||||
"",
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
})
|
||||
|
||||
i3.register_craft({
|
||||
grid = {
|
||||
"X #",
|
||||
|
Reference in New Issue
Block a user