Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creeper9207 Code: database (API)--
- --setValue(database file, key, value)
- --getValue(database file, key)
- function setValue(database, key, value)
- tonumber(key)
- uFile = fs.open(database, "r")
- lFile = uFile.readAll()
- uFile.close()
- local tFile = fs.open(database, "w")
- tDB = textutils.unserialize(lFile)
- table.insert(tDB, key, value)
- tFile.write(textutils.serialize(tDB))
- tFile.flush()
- tFile.close()
- end
- function getValue(tDatabase, tKey)
- tonumber(tKey)
- local tFile = fs.open(tDatabase, "r")
- local tData = tFile.readAll()
- tRealData = textutils.unserialize(tData)
- local value = tRealData[tKey]
- tFile.close()
- return value
- end
Advertisement
Add Comment
Please, Sign In to add comment