diff --git a/fragments.lua b/fragments.lua index 0871bdd..a048c85 100644 --- a/fragments.lua +++ b/fragments.lua @@ -32,39 +32,42 @@ auriinventory.fragments["back"] = [[ ]] function auriinventory.gen_fragment_recipebook(player) - if not player:get_attribute("rbook_page") then player:set_attribute("rbook_page", 0) end - local cheat = player:get_attribute("cheatitems") or false - - local inv_size = 6*10 - local page = tonumber(player:get_attribute("rbook_page")) - if page < 0 then - player:set_attribute("rbook_page",0) - page = 0 - end - if page*inv_size > auriinventory.itemcount then - page = math.floor(auriinventory.itemcount / inv_size) - player:set_attribute("rbook_page",page) - end - local start_index = page * inv_size - - local ind = 1 - local fs = "label[12.6,0;Registered Items (" .. page+1 .. "/" .. math.floor(auriinventory.itemcount/inv_size)+1 .. ")]" - for j = 0, 9 do - for i = 0, 5 do - if auriinventory.items[start_index + ind] then - if cheat then - fs = fs .. "item_image_button[" .. (12.6 + i*0.65) .. "," .. (0.45 + j*0.7) .. ";0.8,0.8;" .. auriinventory.items[start_index + ind] .. ";rbook_item_give_" .. (start_index + ind) .. ";]" - else - fs = fs .. "item_image_button[" .. (12.6 + i*0.65) .. "," .. (0.45 + j*0.7) .. ";0.8,0.8;" .. auriinventory.items[start_index + ind] .. ";rbook_item_recipe_" .. (start_index + ind) .. ";]" - end - end - ind = ind + 1 - end - end - fs = fs .. "image_button[12.6,7.45;0.7,0.8;auriinventory_recipebook_icon_6.png;rbook_firstpage;;false;false;auriinventory_recipebook_icon_7.png]" - fs = fs .. "image_button[13.1,7.45;0.7,0.8;auriinventory_recipebook_icon_0.png;rbook_prevpage;;false;false;auriinventory_recipebook_icon_1.png]" - fs = fs .. "field[13.88,7.99;2.1,0.23;rbook_search;;]" - fs = fs .. "image_button[15.45,7.45;0.7,0.8;auriinventory_recipebook_icon_2.png;rbook_nextpage;;false;false;auriinventory_recipebook_icon_3.png]" - fs = fs .. "image_button[15.95,7.45;0.7,0.8;auriinventory_recipebook_icon_8.png;rbook_lastpage;;false;false;auriinventory_recipebook_icon_9.png]" - return fs + return '[]' end + +-- if not player:get_attribute("rbook_page") then player:set_attribute("rbook_page", 0) end +-- local cheat = player:get_attribute("cheatitems") or false + +-- local inv_size = 6*10 +-- local page = tonumber(player:get_attribute("rbook_page")) +-- if page < 0 then +-- player:set_attribute("rbook_page",0) +-- page = 0 +-- end +-- if page*inv_size > auriinventory.itemcount then +-- page = math.floor(auriinventory.itemcount / inv_size) +-- player:set_attribute("rbook_page",page) +-- end +-- local start_index = page * inv_size + +-- local ind = 1 +-- local fs = "label[12.6,0;Registered Items (" .. page+1 .. "/" .. math.floor(auriinventory.itemcount/inv_size)+1 .. ")]" +-- for j = 0, 9 do +-- for i = 0, 5 do +-- if auriinventory.items[start_index + ind] then +-- if cheat then +-- fs = fs .. "item_image_button[" .. (12.6 + i*0.65) .. "," .. (0.45 + j*0.7) .. ";0.8,0.8;" .. auriinventory.items[start_index + ind] .. ";rbook_item_give_" .. (start_index + ind) .. ";]" +-- else +-- fs = fs .. "item_image_button[" .. (12.6 + i*0.65) .. "," .. (0.45 + j*0.7) .. ";0.8,0.8;" .. auriinventory.items[start_index + ind] .. ";rbook_item_recipe_" .. (start_index + ind) .. ";]" +-- end +-- end +-- ind = ind + 1 +-- end +-- end +-- fs = fs .. "image_button[12.6,7.45;0.7,0.8;auriinventory_recipebook_icon_6.png;rbook_firstpage;;false;false;auriinventory_recipebook_icon_7.png]" +-- fs = fs .. "image_button[13.1,7.45;0.7,0.8;auriinventory_recipebook_icon_0.png;rbook_prevpage;;false;false;auriinventory_recipebook_icon_1.png]" +-- fs = fs .. "field[13.88,7.99;2.1,0.23;rbook_search;;]" +-- fs = fs .. "image_button[15.45,7.45;0.7,0.8;auriinventory_recipebook_icon_2.png;rbook_nextpage;;false;false;auriinventory_recipebook_icon_3.png]" +-- fs = fs .. "image_button[15.95,7.45;0.7,0.8;auriinventory_recipebook_icon_8.png;rbook_lastpage;;false;false;auriinventory_recipebook_icon_9.png]" +-- return fs +-- end diff --git a/init.lua b/init.lua index fd37af2..c1a18b1 100644 --- a/init.lua +++ b/init.lua @@ -108,6 +108,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end + if fields.messages then + local datatable = minetest.explode_textlist_event(fields.messages) + if datatable.type == "CHG" then + player:set_inventory_formspec(auriinventory.gen_formspec_messaging(player, math.ceil(datatable.index / 2))) + return + end + end + if fields.skinlist then local datatable = minetest.explode_textlist_event(fields.skinlist) if datatable.type == "CHG" then diff --git a/inventories/formspec_bags.lua b/inventories/formspec_bags.lua index 408acf2..22c4b5f 100644 --- a/inventories/formspec_bags.lua +++ b/inventories/formspec_bags.lua @@ -4,7 +4,7 @@ function auriinventory.gen_formspec_bags (player) end local fs = [[ - size[15,8;] + size[17,8;] bgcolor[#222222ee;false] listcolors[#ffffff33;#ffffff55;#888888;#33333399;#ffffff] ]] diff --git a/inventories/formspec_messaging.lua b/inventories/formspec_messaging.lua index 660be40..d8e0cb0 100644 --- a/inventories/formspec_messaging.lua +++ b/inventories/formspec_messaging.lua @@ -1,4 +1,4 @@ -function auriinventory.gen_formspec_messaging (player) +function auriinventory.gen_formspec_messaging (player, index) local fs = [[ size[17,8;] bgcolor[#222222ee;false] @@ -10,21 +10,29 @@ function auriinventory.gen_formspec_messaging (player) label[3,0;Messages] ]] - local playerdata = minetest.deserialize(player:get_attribute("messages")) + local playerdata = minetest.deserialize(player:get_attribute("messages") or {}) fs = fs .. "textlist[3,0.5;3,7.5;messages;" - local first = true - for k, v in pairs(playerdata) do - if not first then fs = fs .. "," else first = false end - if not v.read then fs = fs .. "#ff7777● " end - fs = fs .. v.title .. "," .. "#999999From " .. v.from - v.read = true + if playerdata then + local first = true + for k, v in pairs(playerdata) do + if not first then fs = fs .. "," else first = false end + if not v.read then fs = fs .. "#ff7777● " end + fs = fs .. v.title .. "," .. "#999999From " .. v.from + v.read = true + end + end + fs = fs .. "]" + + if index then + fs = fs .. [[ + textlist[6.5,0.5;5.5,7.5;message;]] .. playerdata[index].message .. [[;-1;true] + image_button[11.4,0.4;0.8,0.8;auriinventory_btn_icon_2.png;delmessage_]] .. index .. [[;;true;false;auriinventory_btn_icon_3.png] + ]] end - player:set_attribute("messages", minetest.serialize(playerdata)) - - fs = fs .. "]textlist[6.5,0.5;5.5,7.5;message;hi,yo,hello0;-1;true]" + player:set_attribute("messages", minetest.serialize(playerdata) or {}) fs = auriinventory.append_fragment(fs, "tabs") fs = fs .. auriinventory.gen_fragment_recipebook(player) diff --git a/textures/auriinventory_small_icon.pyxel b/textures/auriinventory_small_icon.pyxel index 22340f6..9c95158 100644 Binary files a/textures/auriinventory_small_icon.pyxel and b/textures/auriinventory_small_icon.pyxel differ diff --git a/textures/auriinventory_small_icon_00.png b/textures/auriinventory_small_icon_00.png new file mode 100644 index 0000000..944692e Binary files /dev/null and b/textures/auriinventory_small_icon_00.png differ diff --git a/textures/auriinventory_small_icon_01.png b/textures/auriinventory_small_icon_01.png new file mode 100644 index 0000000..1e7ec20 Binary files /dev/null and b/textures/auriinventory_small_icon_01.png differ diff --git a/textures/auriinventory_small_icon_02.png b/textures/auriinventory_small_icon_02.png new file mode 100644 index 0000000..48b16be Binary files /dev/null and b/textures/auriinventory_small_icon_02.png differ diff --git a/textures/auriinventory_small_icon_03.png b/textures/auriinventory_small_icon_03.png new file mode 100644 index 0000000..bb7cbf6 Binary files /dev/null and b/textures/auriinventory_small_icon_03.png differ diff --git a/textures/auriinventory_small_icon_04.png b/textures/auriinventory_small_icon_04.png new file mode 100644 index 0000000..c46b73f Binary files /dev/null and b/textures/auriinventory_small_icon_04.png differ diff --git a/textures/auriinventory_small_icon_05.png b/textures/auriinventory_small_icon_05.png new file mode 100644 index 0000000..9d57570 Binary files /dev/null and b/textures/auriinventory_small_icon_05.png differ diff --git a/textures/auriinventory_small_icon_06.png b/textures/auriinventory_small_icon_06.png new file mode 100644 index 0000000..fa099f5 Binary files /dev/null and b/textures/auriinventory_small_icon_06.png differ diff --git a/textures/auriinventory_small_icon_07.png b/textures/auriinventory_small_icon_07.png new file mode 100644 index 0000000..e4907e6 Binary files /dev/null and b/textures/auriinventory_small_icon_07.png differ diff --git a/textures/auriinventory_small_icon_08.png b/textures/auriinventory_small_icon_08.png new file mode 100644 index 0000000..4ece18a Binary files /dev/null and b/textures/auriinventory_small_icon_08.png differ diff --git a/textures/auriinventory_small_icon_09.png b/textures/auriinventory_small_icon_09.png new file mode 100644 index 0000000..030ebeb Binary files /dev/null and b/textures/auriinventory_small_icon_09.png differ diff --git a/textures/auriinventory_small_icon_10.png b/textures/auriinventory_small_icon_10.png new file mode 100644 index 0000000..c8104dd Binary files /dev/null and b/textures/auriinventory_small_icon_10.png differ diff --git a/textures/auriinventory_small_icon_11.png b/textures/auriinventory_small_icon_11.png new file mode 100644 index 0000000..a1c4384 Binary files /dev/null and b/textures/auriinventory_small_icon_11.png differ diff --git a/textures/auriinventory_small_icon_12.png b/textures/auriinventory_small_icon_12.png new file mode 100644 index 0000000..021cb7c Binary files /dev/null and b/textures/auriinventory_small_icon_12.png differ diff --git a/textures/auriinventory_small_icon_13.png b/textures/auriinventory_small_icon_13.png new file mode 100644 index 0000000..fb389b7 Binary files /dev/null and b/textures/auriinventory_small_icon_13.png differ