0
0
Fork 0
This repository has been archived on 2019-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
glua-mod-inventory/lua/shared.lua

35 lines
1.3 KiB
Lua

hi = {}
include("util.lua")
hi.itemtable = {
default = {
rock = { weight = 2048, desc = "Mein name ist rock", icon = Material("models/wireframe"), name = "Hoffentlich kein mini-rock die sind mir meistens viel zu eng" }
}
}
-- hi prefix chosen because hiragana hi looks like a bag... but please dont blame me it wasn't my idea
function hi.getitem(name) -- i did not write the following 2, go blame someone left of me for any errors
local Litemtable = string.Split(name, ',') -- string.Split is Glua, hurray!
if #Litemtable ~= 2 then return false end
item = hi.itemtable[Litemtable[1]][Litemtable[2]]
--if item then return item else return false end
return item or false
end
function hi.additem(item, itemname)
if not item or not itemname then return false end
local itemstring = string.Split(itemname, ',')
if #itemstring ~= 2 then return false end
if not hi.itemtable[itemstring[1]] then
hi.itemtable[itemstring[1]] = {}
end
if hi.itemtable[itemstring[1]][itemstring[2]] then return false end
if not item["weight"] or hi.util.isint(item["weight"]) and
not item["desc"] or hi.util.isstring(item["weight"]) and
not item["name"] or hi.util.isstring(item["name"]) and
not item["icon"] or hi.util.ismaterial(item["icon"]) then
hi.itemtable[itemstring[1]][itemstring[2]] = item
return true
end
return false
end