dbloader = {}function explode(d,p) t={} ll=0 while true do l=string.find(p,d,ll+1,true) -- find the next d in the string if l~=nil then -- if "not not" found then.. table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array. ll=l+1 -- save just after where we found it for searching next time. else table.insert(t, string.sub(p,ll)) -- Save what's left in our array. break -- Break at end, as it should be, according to the lua manual. end end return tendfunction dbloader:New(filename) local o = {} for k,v in pairs(self) do o[k]=v end o.db = {} o.dbname = filenameendfunction dbloader:Save() local buf = "" for k,v in pairs(self.db) do buf = buf .. k .." ".. v.."\n" end _file.Write(self.dbname..".db",buf)endfunction dbloader:GetKV(line) local chk = false local k = "" local v = "" for i=1,#line do local ch = string.sub(line,i,i) if not chk then if ch ~= " " then k = k .. ch else chk = true end else v = v..ch end end return k,vendfunction dbloader:Load() self.db = {} lines = explode("\n",_file.Read(self.dbname..".db") for _,x in pairs(lines) do k,v = self:GetKV(x) self.db[k]=v endendfunction dbloader:Get(key) if not self.db[key] then return end return self.db[key]endfunction dbloader:Set(key,value) self.db[key] = valueend