Add custom operators (Part 1)
This commit is contained in:
parent
b3f1cf255d
commit
34548d8509
|
@ -27,6 +27,7 @@ globals = {
|
||||||
exclude_files = {
|
exclude_files = {
|
||||||
"tests/test_compression.lua",
|
"tests/test_compression.lua",
|
||||||
"tests/test_custom_recipes.lua",
|
"tests/test_custom_recipes.lua",
|
||||||
|
"tests/test_operators.lua",
|
||||||
"tests/test_tabs.lua",
|
"tests/test_tabs.lua",
|
||||||
|
|
||||||
".install",
|
".install",
|
||||||
|
|
41
init.lua
41
init.lua
|
@ -1,4 +1,5 @@
|
||||||
local modpath = core.get_modpath"i3"
|
local modpath = core.get_modpath"i3"
|
||||||
|
dofile(modpath .. "/src/operators.lua")
|
||||||
|
|
||||||
local function lf(path)
|
local function lf(path)
|
||||||
return loadfile(modpath .. path)
|
return loadfile(modpath .. path)
|
||||||
|
@ -51,19 +52,26 @@ i3 = {
|
||||||
sorting_methods = {},
|
sorting_methods = {},
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
api = lf("/src/api.lua"),
|
api = lf"/src/api.lua",
|
||||||
bags = lf("/src/bags.lua"),
|
bags = lf"/src/bags.lua",
|
||||||
caches = lf("/src/caches.lua"),
|
caches = lf"/src/caches.lua",
|
||||||
callbacks = lf("/src/callbacks.lua"),
|
callbacks = lf"/src/callbacks.lua",
|
||||||
common = lf("/src/common.lua"),
|
common = lf"/src/common.lua",
|
||||||
compress = lf("/src/compress.lua"),
|
compress = lf"/src/compress.lua",
|
||||||
detached = lf("/src/detached_inv.lua"),
|
detached = lf"/src/detached_inv.lua",
|
||||||
groups = lf("/src/groups.lua"),
|
groups = lf"/src/groups.lua",
|
||||||
gui = lf("/src/gui.lua"),
|
gui = lf"/src/gui.lua",
|
||||||
hud = lf("/src/hud.lua"),
|
hud = lf"/src/hud.lua",
|
||||||
model_alias = lf("/src/model_aliases.lua"),
|
model_alias = lf"/src/model_aliases.lua",
|
||||||
progressive = lf("/src/progressive.lua"),
|
progressive = lf"/src/progressive.lua",
|
||||||
styles = lf("/src/styles.lua"),
|
styles = lf"/src/styles.lua",
|
||||||
|
|
||||||
|
tests = {
|
||||||
|
tabs = lf"/tests/test_tabs.lua",
|
||||||
|
operators = lf"/tests/test_operators.lua",
|
||||||
|
compression = lf"/tests/test_compression.lua",
|
||||||
|
custom_recipes = lf"/tests/test_custom_recipes.lua",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
progressive_mode = core.settings:get_bool"i3_progressive_mode",
|
progressive_mode = core.settings:get_bool"i3_progressive_mode",
|
||||||
|
@ -229,6 +237,7 @@ if i3.progressive_mode then
|
||||||
i3.files.progressive()
|
i3.files.progressive()
|
||||||
end
|
end
|
||||||
|
|
||||||
--dofile(modpath .. "/tests/test_tabs.lua")
|
--i3.files.tests.tabs()
|
||||||
--dofile(modpath .. "/tests/test_compression.lua")
|
--i3.files.tests.operators()
|
||||||
--dofile(modpath .. "/tests/test_custom_recipes.lua")
|
--i3.files.tests.compression()
|
||||||
|
--i3.files.tests.custom_recipes()
|
||||||
|
|
|
@ -80,7 +80,7 @@ local function init_bags(player)
|
||||||
local stack = list[i]
|
local stack = list[i]
|
||||||
|
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
c = c + 1
|
c++
|
||||||
t[i] = stack:to_string()
|
t[i] = stack:to_string()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -157,7 +157,7 @@ i3.new_tab("inventory", {
|
||||||
local idx = get_sorting_idx(data.sort)
|
local idx = get_sorting_idx(data.sort)
|
||||||
local tot = #i3.sorting_methods
|
local tot = #i3.sorting_methods
|
||||||
|
|
||||||
idx = idx - (fields.prev_sort and 1 or -1)
|
idx -= (fields.prev_sort and 1 or -1)
|
||||||
|
|
||||||
if idx > tot then
|
if idx > tot then
|
||||||
idx = 1
|
idx = 1
|
||||||
|
@ -210,7 +210,7 @@ i3.new_tab("inventory", {
|
||||||
id = id,
|
id = id,
|
||||||
})
|
})
|
||||||
|
|
||||||
data.scrbar_inv = data.scrbar_inv + 1000
|
data.scrbar_inv += 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
return set_fs(player)
|
return set_fs(player)
|
||||||
|
@ -270,7 +270,7 @@ local function select_item(player, data, _f)
|
||||||
for _, v in ipairs(items) do
|
for _, v in ipairs(items) do
|
||||||
if valid_item(reg_items[clean_name(v)]) then
|
if valid_item(reg_items[clean_name(v)]) then
|
||||||
insert(data.alt_items, idx + i, v)
|
insert(data.alt_items, idx + i, v)
|
||||||
i = i + 1
|
i++
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -278,7 +278,7 @@ local function select_item(player, data, _f)
|
||||||
else
|
else
|
||||||
if sub(item, 1, 1) == "_" then
|
if sub(item, 1, 1) == "_" then
|
||||||
item = sub(item, 2)
|
item = sub(item, 2)
|
||||||
elseif sub(item, 1, 6) == "group|" then
|
elseif sub(item, 1, 6) == "group!" then
|
||||||
item = match(item, "([%w:_]+)$")
|
item = match(item, "([%w:_]+)$")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ local function rcp_fields(player, data, fields)
|
||||||
|
|
||||||
elseif fields.prev_page or fields.next_page then
|
elseif fields.prev_page or fields.next_page then
|
||||||
if data.pagemax == 1 then return end
|
if data.pagemax == 1 then return end
|
||||||
data.pagenum = data.pagenum - (fields.prev_page and 1 or -1)
|
data.pagenum -= (fields.prev_page and 1 or -1)
|
||||||
|
|
||||||
if data.pagenum > data.pagemax then
|
if data.pagenum > data.pagemax then
|
||||||
data.pagenum = 1
|
data.pagenum = 1
|
||||||
|
|
|
@ -103,7 +103,7 @@ local function search(data)
|
||||||
temp[item] = true
|
temp[item] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
j = j + 1
|
j++
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -122,7 +122,7 @@ local function search(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
if to_add then
|
if to_add then
|
||||||
c = c + 1
|
c++
|
||||||
filtered_list[c] = item
|
filtered_list[c] = item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -150,7 +150,7 @@ local function table_merge(t1, t2, hash)
|
||||||
local c = #t1
|
local c = #t1
|
||||||
|
|
||||||
for i = 1, #t2 do
|
for i = 1, #t2 do
|
||||||
c = c + 1
|
c++
|
||||||
t1[c] = t2[i]
|
t1[c] = t2[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -176,7 +176,7 @@ local function array_diff(t1, t2)
|
||||||
for i = 1, #t1 do
|
for i = 1, #t1 do
|
||||||
local v = t1[i]
|
local v = t1[i]
|
||||||
if hash[v] then
|
if hash[v] then
|
||||||
c = c + 1
|
c++
|
||||||
diff[c] = v
|
diff[c] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -377,7 +377,7 @@ local function craft_stack(player, data, craft_rcp)
|
||||||
if item == _name and remaining > 0 then
|
if item == _name and remaining > 0 then
|
||||||
local c = min(remaining, _count)
|
local c = min(remaining, _count)
|
||||||
items[item] = c
|
items[item] = c
|
||||||
remaining = remaining - c
|
remaining -= c
|
||||||
end
|
end
|
||||||
|
|
||||||
if remaining == 0 then break end
|
if remaining == 0 then break end
|
||||||
|
@ -398,7 +398,7 @@ local function craft_stack(player, data, craft_rcp)
|
||||||
local c = min(stackmax, leftover)
|
local c = min(stackmax, leftover)
|
||||||
local stack = ItemStack(fmt("%s %s", stackname, c))
|
local stack = ItemStack(fmt("%s %s", stackname, c))
|
||||||
get_stack(player, stack)
|
get_stack(player, stack)
|
||||||
leftover = leftover - stackmax
|
leftover -= stackmax
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ local function safe_teleport(player, pos)
|
||||||
player:add_velocity(vec_mul(vel, -1))
|
player:add_velocity(vec_mul(vel, -1))
|
||||||
|
|
||||||
local p = vec_new(pos)
|
local p = vec_new(pos)
|
||||||
p.y = p.y + 0.25
|
p.y += 0.25
|
||||||
|
|
||||||
player:set_pos(p)
|
player:set_pos(p)
|
||||||
end
|
end
|
||||||
|
@ -486,7 +486,7 @@ local function compress_items(list, start_i)
|
||||||
insert(special, stack)
|
insert(special, stack)
|
||||||
else
|
else
|
||||||
hash[name] = hash[name] or 0
|
hash[name] = hash[name] or 0
|
||||||
hash[name] = hash[name] + count
|
hash[name] += count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -498,7 +498,7 @@ local function compress_items(list, start_i)
|
||||||
|
|
||||||
for _ = 1, iter do
|
for _ = 1, iter do
|
||||||
insert(new_inv, ItemStack(fmt("%s %u", name, min(stackmax, leftover))))
|
insert(new_inv, ItemStack(fmt("%s %u", name, min(stackmax, leftover))))
|
||||||
leftover = leftover - stackmax
|
leftover -= stackmax
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
104
src/gui.lua
104
src/gui.lua
|
@ -132,7 +132,7 @@ end
|
||||||
local function get_inv_slots(fs)
|
local function get_inv_slots(fs)
|
||||||
local inv_x, inv_y, size, spacing = 0.22, 6.9, 1, 0.1
|
local inv_x, inv_y, size, spacing = 0.22, 6.9, 1, 0.1
|
||||||
|
|
||||||
fs("style_type[box;colors=#77777710,#77777710,#777,#777]")
|
fs"style_type[box;colors=#77777710,#77777710,#777,#777]"
|
||||||
|
|
||||||
for i = 0, i3.HOTBAR_LEN - 1 do
|
for i = 0, i3.HOTBAR_LEN - 1 do
|
||||||
fs("box", i * size + inv_x + (i * spacing), inv_y, size, size, "")
|
fs("box", i * size + inv_x + (i * spacing), inv_y, size, size, "")
|
||||||
|
@ -146,7 +146,7 @@ local function get_inv_slots(fs)
|
||||||
i3.HOTBAR_LEN, i3.INV_SIZE / i3.HOTBAR_LEN, i3.HOTBAR_LEN),
|
i3.HOTBAR_LEN, i3.INV_SIZE / i3.HOTBAR_LEN, i3.HOTBAR_LEN),
|
||||||
"style_type[list;size=1;spacing=0.15]")
|
"style_type[list;size=1;spacing=0.15]")
|
||||||
|
|
||||||
fs("listring[current_player;craft]listring[current_player;main]")
|
fs"listring[current_player;craft]listring[current_player;main]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_subtitle(fs, name, y, ctn_len, font_size, sep, label)
|
local function add_subtitle(fs, name, y, ctn_len, font_size, sep, label)
|
||||||
|
@ -212,7 +212,7 @@ local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlo
|
||||||
insert(fs, "style_type[label;font_size=14]")
|
insert(fs, "style_type[label;font_size=14]")
|
||||||
insert(fs, fmt("label", icon_size + 0.55, y + 0.97, fmt("%u / %u", current, target)))
|
insert(fs, fmt("label", icon_size + 0.55, y + 0.97, fmt("%u / %u", current, target)))
|
||||||
|
|
||||||
y = y - 0.14
|
y -= 0.14
|
||||||
end
|
end
|
||||||
|
|
||||||
local end_title = ESC(_title or title)
|
local end_title = ESC(_title or title)
|
||||||
|
@ -270,7 +270,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||||
local y = yextra + 1.35 + (i - (i * 0.3))
|
local y = yextra + 1.35 + (i - (i * 0.3))
|
||||||
local icon_size, yi = 0.35, y + 0.12
|
local icon_size, yi = 0.35, y + 0.12
|
||||||
|
|
||||||
fs("style_type[box;colors=#bababa30,#bababa30,#bababa05,#bababa05]")
|
fs"style_type[box;colors=#bababa30,#bababa30,#bababa05,#bababa05]"
|
||||||
fs("box", 0, y, ctn_len, 0.6, "")
|
fs("box", 0, y, ctn_len, 0.6, "")
|
||||||
|
|
||||||
local waypoint_name, lim = v.name, 18
|
local waypoint_name, lim = v.name, 18
|
||||||
|
@ -279,7 +279,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||||
waypoint_name = snip(waypoint_name, lim)
|
waypoint_name = snip(waypoint_name, lim)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("style_type[label;font_size=17]")
|
fs"style_type[label;font_size=17]"
|
||||||
|
|
||||||
local hex = fmt("%02x", v.color)
|
local hex = fmt("%02x", v.color)
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("style_type[label;font_size=16]")
|
fs"style_type[label;font_size=16]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_container(fs, data, player, yoffset, ctn_len, award_list, awards_unlocked, award_list_nb, bag_size)
|
local function get_container(fs, data, player, yoffset, ctn_len, award_list, awards_unlocked, award_list_nb, bag_size)
|
||||||
|
@ -366,7 +366,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
(half == 1 and i == floor(hearts)) and PNG.heart_half or PNG.heart)
|
(half == 1 and i == floor(hearts)) and PNG.heart_half or PNG.heart)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
yoffset = yoffset - 0.5
|
yoffset -= 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
fs(fmt("list[current_player;craft;%f,%f;3,3;]", 0, yoffset + 1.45))
|
fs(fmt("list[current_player;craft;%f,%f;3,3;]", 0, yoffset + 1.45))
|
||||||
|
@ -418,8 +418,9 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
end
|
end
|
||||||
|
|
||||||
fs(fmt("style_type[list;size=%f;spacing=%f]", size, spacing))
|
fs(fmt("style_type[list;size=%f;spacing=%f]", size, spacing))
|
||||||
fs(fmt("list[detached:i3_bag_content_%s;main;%f,%f;4,%u;]", esc_name, x, yextra + 1.3, bag_size))
|
fs(fmt("list[detached:i3_bag_content_%s;main;%f,%f;4,%u;]",
|
||||||
fs("style_type[list;size=1;spacing=0.15]")
|
esc_name, x, yextra + 1.3, bag_size))
|
||||||
|
fs"style_type[list;size=1;spacing=0.15]"
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif data.subcat == 2 then
|
elseif data.subcat == 2 then
|
||||||
|
@ -429,7 +430,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
fs("label", 3.65, yextra + 1.55, fmt("%s: %s", ES"Level", armor_def.level))
|
fs("label", 3.65, yextra + 1.55, fmt("%s: %s", ES"Level", armor_def.level))
|
||||||
fs("label", 3.65, yextra + 2.05, fmt("%s: %s", ES"Heal", armor_def.heal))
|
fs("label", 3.65, yextra + 2.05, fmt("%s: %s", ES"Heal", armor_def.heal))
|
||||||
else
|
else
|
||||||
not_installed("3d_armor")
|
not_installed "3d_armor"
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif data.subcat == 3 then
|
elseif data.subcat == 3 then
|
||||||
|
@ -451,7 +452,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
fs("label", 0, yextra + 0.85, fmt("%s:", ES"Select a skin"))
|
fs("label", 0, yextra + 0.85, fmt("%s:", ES"Select a skin"))
|
||||||
fs(fmt("dropdown[0,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, id))
|
fs(fmt("dropdown[0,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, id))
|
||||||
else
|
else
|
||||||
not_installed("skinsdb")
|
not_installed "skinsdb"
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif data.subcat == 4 then
|
elseif data.subcat == 4 then
|
||||||
|
@ -459,7 +460,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||||
yextra = yextra + 0.7
|
yextra = yextra + 0.7
|
||||||
get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlocked, award_list_nb)
|
get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlocked, award_list_nb)
|
||||||
else
|
else
|
||||||
not_installed("awards")
|
not_installed "awards"
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif data.subcat == 5 then
|
elseif data.subcat == 5 then
|
||||||
|
@ -469,7 +470,7 @@ end
|
||||||
|
|
||||||
local function show_popup(fs, data)
|
local function show_popup(fs, data)
|
||||||
if data.confirm_trash then
|
if data.confirm_trash then
|
||||||
fs("style_type[box;colors=#999,#999,#808080,#808080]")
|
fs"style_type[box;colors=#999,#999,#808080,#808080]"
|
||||||
|
|
||||||
for _ = 1, 3 do
|
for _ = 1, 3 do
|
||||||
fs("box", 2.97, 10.75, 4.3, 0.5, "")
|
fs("box", 2.97, 10.75, 4.3, 0.5, "")
|
||||||
|
@ -480,7 +481,7 @@ local function show_popup(fs, data)
|
||||||
fs("image_button", 6.27, 10.75, 1, 0.5, "", "confirm_trash_no", "No")
|
fs("image_button", 6.27, 10.75, 1, 0.5, "", "confirm_trash_no", "No")
|
||||||
|
|
||||||
elseif data.show_settings then
|
elseif data.show_settings then
|
||||||
fs("style_type[box;colors=#999,#999,#808080,#808080]")
|
fs"style_type[box;colors=#999,#999,#808080,#808080]"
|
||||||
|
|
||||||
for _ = 1, 3 do
|
for _ = 1, 3 do
|
||||||
fs("box", 2.1, 9.25, 6, 2, "")
|
fs("box", 2.1, 9.25, 6, 2, "")
|
||||||
|
@ -513,7 +514,7 @@ local function show_popup(fs, data)
|
||||||
if data.home then
|
if data.home then
|
||||||
str = data.home:gsub(",", " "):sub(2,-2):gsub("%.%d", ""):gsub(
|
str = data.home:gsub(",", " "):sub(2,-2):gsub("%.%d", ""):gsub(
|
||||||
"(%-?%d+)", function(a)
|
"(%-?%d+)", function(a)
|
||||||
c = c + 1
|
c++
|
||||||
return fmt("<b>%s: <style color=%s font=mono>%s</style></b>",
|
return fmt("<b>%s: <style color=%s font=mono>%s</style></b>",
|
||||||
coords[c], colors.black, a)
|
coords[c], colors.black, a)
|
||||||
end)
|
end)
|
||||||
|
@ -531,7 +532,7 @@ local function show_popup(fs, data)
|
||||||
fs("image_button", 2.2, 10.6, 0.35, 0.35, "", "prev_sort", "")
|
fs("image_button", 2.2, 10.6, 0.35, 0.35, "", "prev_sort", "")
|
||||||
fs("image_button", 7.65, 10.6, 0.35, 0.35, "", "next_sort", "")
|
fs("image_button", 7.65, 10.6, 0.35, 0.35, "", "next_sort", "")
|
||||||
|
|
||||||
fs("style[sort_method;font=bold;font_size=20]")
|
fs"style[sort_method;font=bold;font_size=20]"
|
||||||
fs("button", 2.55, 10.36, 5.1, 0.8, "sort_method", toupper(data.sort))
|
fs("button", 2.55, 10.36, 5.1, 0.8, "sort_method", toupper(data.sort))
|
||||||
|
|
||||||
local idx = get_sorting_idx(data.sort)
|
local idx = get_sorting_idx(data.sort)
|
||||||
|
@ -551,10 +552,10 @@ local function show_popup(fs, data)
|
||||||
fs("box", 5.4, 10.68, 2.4, 0.45, "#707070")
|
fs("box", 5.4, 10.68, 2.4, 0.45, "#707070")
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("style[drop_items;font_size=15;font=mono;textcolor=#dbeeff]")
|
fs("style[drop_items;font_size=15;font=mono;textcolor=#dbeeff]",
|
||||||
fs(fmt("field[5.4,10.68;2.4,0.45;drop_items;Drop items:;%s]",
|
fmt("field[5.4,10.68;2.4,0.45;drop_items;Drop items:;%s]",
|
||||||
ESC(concat(data.drop_items or {}, ","))))
|
ESC(concat(data.drop_items or {}, ","))),
|
||||||
fs("field_close_on_enter[drop_items;false]")
|
"field_close_on_enter[drop_items;false]")
|
||||||
|
|
||||||
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
||||||
ES"Enable this option to compress your inventory"),
|
ES"Enable this option to compress your inventory"),
|
||||||
|
@ -572,7 +573,7 @@ local function show_popup(fs, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_inventory_fs(player, data, fs)
|
local function get_inventory_fs(player, data, fs)
|
||||||
fs("listcolors[#bababa50;#bababa99]")
|
fs"listcolors[#bababa50;#bababa99]"
|
||||||
|
|
||||||
get_inv_slots(fs)
|
get_inv_slots(fs)
|
||||||
|
|
||||||
|
@ -604,14 +605,14 @@ local function get_inventory_fs(player, data, fs)
|
||||||
local bag_size = get_group(ItemStack(data.bag):get_name(), "bag")
|
local bag_size = get_group(ItemStack(data.bag):get_name(), "bag")
|
||||||
|
|
||||||
if data.subcat == 1 and bag_size > 0 then
|
if data.subcat == 1 and bag_size > 0 then
|
||||||
max_val = max_val + min(32, 6 + ((bag_size - 1) * 10))
|
max_val += min(32, 6 + ((bag_size - 1) * 10))
|
||||||
|
|
||||||
elseif i3.modules.armor and data.subcat == 2 then
|
elseif i3.modules.armor and data.subcat == 2 then
|
||||||
if data.scrbar_inv >= max_val then
|
if data.scrbar_inv >= max_val then
|
||||||
data.scrbar_inv = data.scrbar_inv + 10
|
data.scrbar_inv += 10
|
||||||
end
|
end
|
||||||
|
|
||||||
max_val = max_val + 10
|
max_val += 10
|
||||||
|
|
||||||
elseif i3.modules.awards and data.subcat == 4 then
|
elseif i3.modules.awards and data.subcat == 4 then
|
||||||
award_list = awards.get_award_states(data.player_name)
|
award_list = awards.get_award_states(data.player_name)
|
||||||
|
@ -621,18 +622,18 @@ local function get_inventory_fs(player, data, fs)
|
||||||
local award = award_list[i]
|
local award = award_list[i]
|
||||||
|
|
||||||
if award.unlocked then
|
if award.unlocked then
|
||||||
awards_unlocked = awards_unlocked + 1
|
awards_unlocked++
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
max_val = max_val + (award_list_nb * 13)
|
max_val += (award_list_nb * 13)
|
||||||
|
|
||||||
elseif data.subcat == 5 then
|
elseif data.subcat == 5 then
|
||||||
local wp_nb = #data.waypoints
|
local wp_nb = #data.waypoints
|
||||||
|
|
||||||
if wp_nb > 0 then
|
if wp_nb > 0 then
|
||||||
local mul = (wp_nb > 8 and 7) or (wp_nb > 4 and 6) or 5
|
local mul = (wp_nb > 8 and 7) or (wp_nb > 4 and 6) or 5
|
||||||
max_val = max_val + 11 + (wp_nb * mul)
|
max_val += 11 + (wp_nb * mul)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -645,7 +646,7 @@ local function get_inventory_fs(player, data, fs)
|
||||||
|
|
||||||
fs(fmt("scroll_container[3.9,0.2;%f,%f;scrbar_inv;vertical]", ctn_len, ctn_hgt))
|
fs(fmt("scroll_container[3.9,0.2;%f,%f;scrbar_inv;vertical]", ctn_len, ctn_hgt))
|
||||||
get_container(fs, data, player, yoffset, ctn_len, award_list, awards_unlocked, award_list_nb, bag_size)
|
get_container(fs, data, player, yoffset, ctn_len, award_list, awards_unlocked, award_list_nb, bag_size)
|
||||||
fs("scroll_container_end[]")
|
fs"scroll_container_end[]"
|
||||||
|
|
||||||
local btn = {
|
local btn = {
|
||||||
{"trash", ES"Clear inventory"},
|
{"trash", ES"Clear inventory"},
|
||||||
|
@ -733,8 +734,7 @@ local function get_tooltip(item, info, pos)
|
||||||
|
|
||||||
tooltip = add(S("Only drop if using one of these tools: @1", sub(names, 1, -2)))
|
tooltip = add(S("Only drop if using one of these tools: @1", sub(names, 1, -2)))
|
||||||
else
|
else
|
||||||
tooltip = add(S("Only drop if using this tool: @1",
|
tooltip = add(S("Only drop if using this tool: @1", clr("#ff0", get_desc(info.tools[1]))))
|
||||||
clr("#ff0", get_desc(info.tools[1]))))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -794,7 +794,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
|
||||||
local rcp_usg = is_recipe and "rcp" or "usg"
|
local rcp_usg = is_recipe and "rcp" or "usg"
|
||||||
|
|
||||||
fs(fmt("style_type[list;size=%f]", i3.ITEM_BTN_SIZE))
|
fs(fmt("style_type[list;size=%f]", i3.ITEM_BTN_SIZE))
|
||||||
fs("listcolors[#bababa50;#bababa99]")
|
fs"listcolors[#bababa50;#bababa99]"
|
||||||
fs(fmt("list[detached:i3_output_%s_%s;main;%f,%f;1,1;]", rcp_usg, data.player_name, X + 0.11, Y))
|
fs(fmt("list[detached:i3_output_%s_%s;main;%f,%f;1,1;]", rcp_usg, data.player_name, X + 0.11, Y))
|
||||||
fs("button", X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, _name, "")
|
fs("button", X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, _name, "")
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||||
local large_recipe = width > 3 or rows > 3
|
local large_recipe = width > 3 or rows > 3
|
||||||
|
|
||||||
if large_recipe then
|
if large_recipe then
|
||||||
fs("style_type[item_image_button;border=true]")
|
fs"style_type[item_image_button;border=true]"
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, width * rows do
|
for i = 1, width * rows do
|
||||||
|
@ -888,10 +888,10 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||||
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05) + add_y
|
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05) + add_y
|
||||||
else
|
else
|
||||||
X = ceil((i - 1) % width - width)
|
X = ceil((i - 1) % width - width)
|
||||||
X = X + (X * 0.2) + data.inv_width + 3.9
|
X += (X * 0.2) + data.inv_width + 3.9
|
||||||
|
|
||||||
Y = ceil(i / width) - min(2, rows)
|
Y = ceil(i / width) - min(2, rows)
|
||||||
Y = Y + (Y * 0.15) + data.yoffset + 1.4
|
Y += (Y * 0.15) + data.yoffset + 1.4
|
||||||
end
|
end
|
||||||
|
|
||||||
if X > right then
|
if X > right then
|
||||||
|
@ -933,7 +933,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||||
fs("image", X, Y, btn_size, btn_size, PNG.slot)
|
fs("image", X, Y, btn_size, btn_size, PNG.slot)
|
||||||
end
|
end
|
||||||
|
|
||||||
local btn_name = groups and fmt("group|%s|%s", groups[1], name) or name
|
local btn_name = groups and fmt("group!%s!%s", groups[1], name) or name
|
||||||
|
|
||||||
fs("item_image_button", X, Y, btn_size, btn_size,
|
fs("item_image_button", X, Y, btn_size, btn_size,
|
||||||
fmt("%s %u", name, count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)),
|
fmt("%s %u", name, count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)),
|
||||||
|
@ -1091,11 +1091,11 @@ local function get_header(fs, data)
|
||||||
tech_name = snip(tech_name, name_lim)
|
tech_name = snip(tech_name, name_lim)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("style_type[label;font=bold;font_size=20]")
|
fs"style_type[label;font=bold;font_size=20]"
|
||||||
fs("label", X, Y1, desc)
|
fs("label", X, Y1, desc)
|
||||||
fs("style_type[label;font=mono;font_size=16]")
|
fs"style_type[label;font=mono;font_size=16]"
|
||||||
fs("label", X, Y2, clr(colors.blue, tech_name))
|
fs("label", X, Y2, clr(colors.blue, tech_name))
|
||||||
fs("style_type[label;font=normal;font_size=16]")
|
fs"style_type[label;font=normal;font_size=16]"
|
||||||
|
|
||||||
local def = reg_items[data.query_item]
|
local def = reg_items[data.query_item]
|
||||||
local model_alias = model_aliases[data.query_item]
|
local model_alias = model_aliases[data.query_item]
|
||||||
|
@ -1134,12 +1134,12 @@ local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_
|
||||||
fs(fmt("style[scrbar_%s;noclip=true]", name),
|
fs(fmt("style[scrbar_%s;noclip=true]", name),
|
||||||
fmt("scrollbaroptions[min=1;max=%u;smallstep=1]", craft_max))
|
fmt("scrollbaroptions[min=1;max=%u;smallstep=1]", craft_max))
|
||||||
fs("scrollbar", data.inv_width + 8.1, data.yoffset, 3, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs)
|
fs("scrollbar", data.inv_width + 8.1, data.yoffset, 3, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs)
|
||||||
fs("button", data.inv_width + 8.1, data.yoffset + 0.4, 3, 0.7, fmt("craft_%s", name),
|
fs("button", data.inv_width + 8.1, data.yoffset + 0.4, 3, 0.7,
|
||||||
ES("Craft (×@1)", stack_fs))
|
fmt("craft_%s", name), ES("Craft (×@1)", stack_fs))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
||||||
fs("container[0,0.075]")
|
fs"container[0,0.075]"
|
||||||
local rn = panel.rcp and #panel.rcp
|
local rn = panel.rcp and #panel.rcp
|
||||||
|
|
||||||
if rn then
|
if rn then
|
||||||
|
@ -1174,7 +1174,7 @@ local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
||||||
fs("button", data.inv_width + 0.1, data.yoffset + (panel.height / 2) - 0.5, 7.8, 1, "no_rcp", lbl)
|
fs("button", data.inv_width + 0.1, data.yoffset + (panel.height / 2) - 0.5, 7.8, 1, "no_rcp", lbl)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("container_end[]")
|
fs"container_end[]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_items_fs(fs, data, full_height)
|
local function get_items_fs(fs, data, full_height)
|
||||||
|
@ -1230,10 +1230,10 @@ local function get_items_fs(fs, data, full_height)
|
||||||
local name = _compressed and item:sub(2) or item
|
local name = _compressed and item:sub(2) or item
|
||||||
|
|
||||||
local X = i % rows
|
local X = i % rows
|
||||||
X = X - (X * 0.045) + data.inv_width + 0.28
|
X -= (X * 0.045) + data.inv_width + 0.28
|
||||||
|
|
||||||
local Y = round((i % ipp - X) / rows + 1, 0)
|
local Y = round((i % ipp - X) / rows + 1, 0)
|
||||||
Y = Y - (Y * 0.085) + 0.95
|
Y -= (Y * 0.085) + 0.95
|
||||||
|
|
||||||
insert(fs, fmt("item_image_button", X, Y, size, size, name, item, ""))
|
insert(fs, fmt("item_image_button", X, Y, size, size, name, item, ""))
|
||||||
|
|
||||||
|
@ -1241,9 +1241,9 @@ local function get_items_fs(fs, data, full_height)
|
||||||
local expand = data.expand == name
|
local expand = data.expand == name
|
||||||
|
|
||||||
fs(fmt("tooltip[%s;%s]", item, expand and ES"Click to hide" or ES"Click to expand"))
|
fs(fmt("tooltip[%s;%s]", item, expand and ES"Click to hide" or ES"Click to expand"))
|
||||||
fs("style_type[label;font=bold;font_size=20]")
|
fs"style_type[label;font=bold;font_size=20]"
|
||||||
fs("label", X + 0.65, Y + 0.7, expand and "-" or "+")
|
fs("label", X + 0.65, Y + 0.7, expand and "-" or "+")
|
||||||
fs("style_type[label;font=normal;font_size=16]")
|
fs"style_type[label;font=normal;font_size=16]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1258,7 +1258,7 @@ local function get_items_fs(fs, data, full_height)
|
||||||
selected and PNG.tab_small_hover or PNG.tab_small,
|
selected and PNG.tab_small_hover or PNG.tab_small,
|
||||||
PNG.tab_small_hover, selected and "#fff" or "#ddd"))
|
PNG.tab_small_hover, selected and "#fff" or "#ddd"))
|
||||||
|
|
||||||
fs("style_type[image_button:hovered;textcolor=#fff]")
|
fs"style_type[image_button:hovered;textcolor=#fff]"
|
||||||
fs("image_button", (data.inv_width - 0.65) + (i * (tab_len + 0.1)),
|
fs("image_button", (data.inv_width - 0.65) + (i * (tab_len + 0.1)),
|
||||||
full_height, tab_len, tab_hgh, "", fmt("itab_%u", i), title)
|
full_height, tab_len, tab_hgh, "", fmt("itab_%u", i), title)
|
||||||
end
|
end
|
||||||
|
@ -1354,7 +1354,7 @@ local function get_tabs_fs(player, data, fs, full_height)
|
||||||
local X = (data.inv_width / 2) + (c * (tab_len + 0.1)) - ((tab_len + 0.05) * (shift / 2))
|
local X = (data.inv_width / 2) + (c * (tab_len + 0.1)) - ((tab_len + 0.05) * (shift / 2))
|
||||||
local Y = btm and full_height or -tab_hgh
|
local Y = btm and full_height or -tab_hgh
|
||||||
|
|
||||||
fs("style_type[image_button:hovered;textcolor=#fff]")
|
fs"style_type[image_button:hovered;textcolor=#fff]"
|
||||||
fs("image_button", X, Y, tab_len, tab_hgh, "", fmt("tab_%s", def.name), ESC(def.description))
|
fs("image_button", X, Y, tab_len, tab_hgh, "", fmt("tab_%s", def.name), ESC(def.description))
|
||||||
|
|
||||||
if true_str(def.image) then
|
if true_str(def.image) then
|
||||||
|
@ -1364,7 +1364,7 @@ local function get_tabs_fs(player, data, fs, full_height)
|
||||||
Y + 0.05, 0.35, 0.35, fmt("%s^\\[resize:16x16", def.image))
|
Y + 0.05, 0.35, 0.35, fmt("%s^\\[resize:16x16", def.image))
|
||||||
end
|
end
|
||||||
|
|
||||||
c = c + 1
|
c++
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1375,7 +1375,7 @@ local function get_debug_grid(data, fs, full_height)
|
||||||
for x = 0, data.inv_width + 8, spacing do
|
for x = 0, data.inv_width + 8, spacing do
|
||||||
fs("box", x, 0, 0.01, full_height, "#ff0")
|
fs("box", x, 0, 0.01, full_height, "#ff0")
|
||||||
fs("label", x, full_height + 0.1, tostring(i))
|
fs("label", x, full_height + 0.1, tostring(i))
|
||||||
i = i + 1
|
i++
|
||||||
end
|
end
|
||||||
|
|
||||||
i = 61
|
i = 61
|
||||||
|
@ -1383,12 +1383,12 @@ local function get_debug_grid(data, fs, full_height)
|
||||||
for y = 0, full_height, spacing do
|
for y = 0, full_height, spacing do
|
||||||
fs("box", 0, y, data.inv_width + 8, 0.01, "#ff0")
|
fs("box", 0, y, data.inv_width + 8, 0.01, "#ff0")
|
||||||
fs("label", -0.15, y, tostring(i))
|
fs("label", -0.15, y, tostring(i))
|
||||||
i = i - 1
|
i -= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("box", data.inv_width / 2, 0, 0.01, full_height, "#f00")
|
fs("box", data.inv_width / 2, 0, 0.01, full_height, "#f00")
|
||||||
fs("box", 0, full_height / 2, data.inv_width, 0.01, "#f00")
|
fs("box", 0, full_height / 2, data.inv_width, 0.01, "#f00")
|
||||||
fs("style_type[label;font_size=16]")
|
fs"style_type[label;font_size=16]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make_fs(player, data)
|
local function make_fs(player, data)
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
local fmt = string.format
|
||||||
|
local _loadfile = loadfile
|
||||||
|
local var = "[%w%.%[%]_]"
|
||||||
|
|
||||||
|
local operators = {
|
||||||
|
["([%+%-%*%^/&|])="] = function(a, b, c)
|
||||||
|
return fmt("%s = %s %s %s", a, a, b, c)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["+%+"] = function(a, b)
|
||||||
|
return fmt("%s = %s + 1\n%s", a, a, b)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["&"] = function(a, b)
|
||||||
|
return fmt("bit.band(%s, %s)", a, b)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["|"] = function(a, b)
|
||||||
|
return fmt("bit.bor(%s, %s)", a, b)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["<<"] = function(a, b)
|
||||||
|
return fmt("bit.lshift(%s, %s)", a, b)
|
||||||
|
end,
|
||||||
|
|
||||||
|
[">>"] = function(a, b)
|
||||||
|
return fmt("bit.rshift(%s, %s)", a, b)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function compile(data)
|
||||||
|
for op, func in pairs(operators) do
|
||||||
|
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
||||||
|
end
|
||||||
|
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _load(path, line, data)
|
||||||
|
if line then
|
||||||
|
data = data:split"\n"
|
||||||
|
data[line] = data[line]:gsub("(" .. var .. "+)%s?=%s?(" .. var .. "*)", function(_,b) return b end)
|
||||||
|
data = table.concat(data, "\n")
|
||||||
|
else
|
||||||
|
local file = assert(io.open(path, "r"))
|
||||||
|
data = file:read"*a"
|
||||||
|
file:close()
|
||||||
|
data = compile(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
local l, err = loadstring(data)
|
||||||
|
|
||||||
|
if not l then
|
||||||
|
local err_line = tonumber(err:match(":(%d+):"))
|
||||||
|
|
||||||
|
if line ~= err_line then
|
||||||
|
return _load(path, err_line, data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return l, err
|
||||||
|
end
|
||||||
|
|
||||||
|
function loadfile(path)
|
||||||
|
return _load(path) or _loadfile(path)
|
||||||
|
end
|
|
@ -20,9 +20,9 @@ local function get_filtered_items(player, data)
|
||||||
usages = #apply_recipe_filters(usages or {}, player)
|
usages = #apply_recipe_filters(usages or {}, player)
|
||||||
|
|
||||||
if recipes > 0 or usages > 0 then
|
if recipes > 0 or usages > 0 then
|
||||||
c = c + 1
|
c++
|
||||||
items[c] = item
|
items[c] = item
|
||||||
known = known + recipes + usages
|
known += recipes + usages
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ local function progressive_filter(recipes, player)
|
||||||
for i = 1, #recipes do
|
for i = 1, #recipes do
|
||||||
local recipe = recipes[i]
|
local recipe = recipes[i]
|
||||||
if recipe_in_inv(recipe, data.inv_items) then
|
if recipe_in_inv(recipe, data.inv_items) then
|
||||||
c = c + 1
|
c++
|
||||||
filtered[c] = recipe
|
filtered[c] = recipe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -107,7 +107,7 @@ local function get_inv_items(player)
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
local name = stack:get_name()
|
local name = stack:get_name()
|
||||||
if core.registered_items[name] then
|
if core.registered_items[name] then
|
||||||
c = c + 1
|
c++
|
||||||
inv_items[c] = name
|
inv_items[c] = name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
local a, b, c = 0, 0, 0
|
||||||
|
|
||||||
|
b+=1
|
||||||
|
c++; local foo = "bar";
|
||||||
|
print(c-=1)
|
||||||
|
print(c++)
|
||||||
|
local t = {
|
||||||
|
a = a++,
|
||||||
|
b = b++,
|
||||||
|
c = c++,
|
||||||
|
d = a&3,
|
||||||
|
}
|
||||||
|
print(dump(t))
|
||||||
|
|
||||||
|
--c += 1
|
||||||
|
c*=2
|
||||||
|
|
||||||
|
local i = 16
|
||||||
|
i += i<<4
|
||||||
|
print(i) -- 272
|
||||||
|
|
||||||
|
print(a+=2) -- 2
|
||||||
|
print(c++) -- 3
|
||||||
|
print(a-=1) -- -1
|
||||||
|
print(c^=4) -- 16
|
||||||
|
print(a&b) -- 0
|
||||||
|
print(c|=a) -- 2
|
||||||
|
print(1<<8) -- 256
|
Ŝarĝante…
Reference in New Issue