Compare commits
5 Commits
e252db0a53
...
1c75c451d0
Author | SHA1 | Date |
---|---|---|
Gerold55 | 1c75c451d0 | |
Aurailus | a2b9f1a287 | |
Aurailus | 08aa1a75bc | |
Aurailus | 29279acf6a | |
Aurailus | 6eb4dde2e0 |
|
@ -0,0 +1,5 @@
|
|||
*Finally, an Inventory Mod that Doesn't Suck!*
|
||||
|
||||
AuriInventory is the final inventory mod. Clean. Simple. Expandable. Yours. It has built in support for homes, bags, and messaging, and it integrates with the AuriSkins mod for skin support. It also features a recipe book and creative menu on the right hand side.
|
||||
|
||||
(Images coming soon)
|
|
@ -0,0 +1,14 @@
|
|||
# AuriInventory
|
||||
|
||||
*Finally, an Inventory Mod that Doesn't Suck!*
|
||||
|
||||
AuriInventory is the final inventory mod. Clean. Simple. Expandable. Yours. It has built in support for homes, bags, and messaging, and it integrates with the AuriSkins mod for skin support. It also features a recipe book and creative menu on the right hand side.
|
||||
|
||||
If you're interested, check out the API.md (NYI) document for how to make your own add-on for the mod.
|
||||
|
||||
Todo:
|
||||
- Toggle between cheat and recipe mode
|
||||
- Teleport button in homes menu
|
||||
- Search bar
|
||||
- Messaging
|
||||
- API.lua
|
|
@ -33,7 +33,8 @@ 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 cheat = player:get_attribute("cheatitems") or false
|
||||
local cheat = true
|
||||
|
||||
local inv_size = 6*10
|
||||
local page = tonumber(player:get_attribute("rbook_page"))
|
||||
|
|
8
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
|
||||
|
|
|
@ -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]
|
||||
]]
|
||||
|
|
|
@ -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)
|
||||
|
|
After Width: | Height: | Size: 252 KiB |
105
recipebook.lua
|
@ -1,30 +1,62 @@
|
|||
local function spairs(t, order)
|
||||
-- collect the keys
|
||||
local keys = {}
|
||||
for k in pairs(t) do keys[#keys+1] = k end
|
||||
--[[
|
||||
Ordered table iterator, allow to iterate on the natural order of the keys of a
|
||||
table.
|
||||
|
||||
-- if order function given, sort by it by passing the table and keys a, b,
|
||||
-- otherwise just sort the keys
|
||||
if order then
|
||||
table.sort(keys, function(a,b) return order(t, a, b) end)
|
||||
else
|
||||
table.sort(keys)
|
||||
end
|
||||
Example:
|
||||
]]
|
||||
|
||||
-- return the iterator function
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
if keys[i] then
|
||||
return keys[i], t[keys[i]]
|
||||
local function __genOrderedIndex( t )
|
||||
local orderedIndex = {}
|
||||
for key in pairs(t) do
|
||||
table.insert( orderedIndex, key )
|
||||
end
|
||||
end
|
||||
table.sort( orderedIndex )
|
||||
return orderedIndex
|
||||
end
|
||||
|
||||
local function orderedNext(t, state)
|
||||
-- Equivalent of the next function, but returns the keys in the alphabetic
|
||||
-- order. We use a temporary ordered key table that is stored in the
|
||||
-- table being iterated.
|
||||
|
||||
local key = nil
|
||||
--print("orderedNext: state = "..tostring(state) )
|
||||
if state == nil then
|
||||
-- the first time, generate the index
|
||||
t.__orderedIndex = __genOrderedIndex( t )
|
||||
key = t.__orderedIndex[1]
|
||||
else
|
||||
-- fetch the next value
|
||||
for i = 1,table.getn(t.__orderedIndex) do
|
||||
if t.__orderedIndex[i] == state then
|
||||
key = t.__orderedIndex[i+1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if key then
|
||||
return key, t[key]
|
||||
end
|
||||
|
||||
-- no more value to return, cleanup
|
||||
t.__orderedIndex = nil
|
||||
return
|
||||
end
|
||||
|
||||
local function orderedPairs(t)
|
||||
-- Equivalent of the pairs() function on tables. Allows to iterate
|
||||
-- in order
|
||||
return orderedNext, t, nil
|
||||
end
|
||||
|
||||
--[[
|
||||
Register recipebook items
|
||||
iterate through all items and return an ordered list
|
||||
]]
|
||||
|
||||
function auriinventory.load_recipebook_and_reload()
|
||||
local titems = {}
|
||||
--Get item list oboi
|
||||
for key, val in pairs(minetest.registered_items) do
|
||||
for key, val in orderedPairs(minetest.registered_items) do
|
||||
if key and key ~= "" and key ~= nil then
|
||||
if not val.groups.not_in_creative_inventory then
|
||||
table.insert(titems, key)
|
||||
|
@ -32,39 +64,8 @@ function auriinventory.load_recipebook_and_reload()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
for x, y in spairs(titems, function(t, a, b)
|
||||
return string.byte(string.sub(t[b], string.find(t[b], ":", 1)+1, string.find(t[b], ":", 1)+1))
|
||||
< string.byte(string.sub(t[a], string.find(t[a], ":", 1)+1, string.find(t[a], ":", 1)+1),1)
|
||||
end) do
|
||||
table.insert(auriinventory.items, y)
|
||||
end
|
||||
|
||||
titems = auriinventory.items
|
||||
auriinventory.items = {}
|
||||
|
||||
for x, y in spairs(titems, function(t, a, b)
|
||||
local ind = 1
|
||||
while true do
|
||||
local sA = string.sub(t[a], 1, string.find(t[a], ":", 1) - 1)
|
||||
local sB = string.sub(t[b], 1, string.find(t[b], ":", 1) - 1)
|
||||
|
||||
if not string.byte(sA, ind) then return true end
|
||||
if not string.byte(sB, ind) then return false end
|
||||
|
||||
if ind >= math.max(string.len(sA),string.len(sB)) then return nil end
|
||||
|
||||
if string.byte(sB,ind) > string.byte(sA,ind) then
|
||||
return true
|
||||
elseif string.byte(sB,ind) < string.byte(sA,ind) then
|
||||
return false
|
||||
end
|
||||
|
||||
ind = ind + 1
|
||||
end
|
||||
end) do
|
||||
table.insert(auriinventory.items, y)
|
||||
end
|
||||
auriinventory.items = titems;
|
||||
|
||||
print("Auriinventory Initialized with " .. auriinventory.itemcount .. " items.")
|
||||
|
||||
|
|
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 108 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 107 B |
After Width: | Height: | Size: 112 B |
After Width: | Height: | Size: 116 B |
After Width: | Height: | Size: 121 B |
After Width: | Height: | Size: 112 B |
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 113 B |
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 108 B |
After Width: | Height: | Size: 106 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 112 B |