- ComputerCraft | Programmable Computers for Minecraft
- → UnethicalClown's Content
UnethicalClown's Content
There have been 3 items by UnethicalClown (Search limited from 10-February 22)
#136077 Database Api
Posted by
UnethicalClown
on 26 July 2013 - 07:51 AM
in
APIs and Utilities
I realize how stupid this API is ATM but I am still working on it so ideas is what I need also it might take a while to release this is like the prototype or alpha version as well as being kinda just for people who don't know how to work with tables
#135452 Database Api
Posted by
UnethicalClown
on 23 July 2013 - 11:07 PM
in
APIs and Utilities
Parmacoy, on 23 July 2013 - 05:34 PM, said:
Still lacking alot of features from the quick read i had, but keep it up, from my experience, the less interaction someone has to do with computercraft, the better. Why not focus on getting functionality like mysql, eg
SELECT * FROM test WHERE foo = '$bar'
that means SELECT ALL FROM <table/tables> WHERE <Field> = variable
im sure if you added in advanced search functionality / sorting, it would be a very good program, nice work so far
SELECT * FROM test WHERE foo = '$bar'
that means SELECT ALL FROM <table/tables> WHERE <Field> = variable
im sure if you added in advanced search functionality / sorting, it would be a very good program, nice work so far
thanks man you have given me quite a few Ideas indeed
#135390 Database Api
Posted by
UnethicalClown
on 23 July 2013 - 03:04 PM
in
APIs and Utilities
DataBase api
Created by UnethicalClown and MKlegoman357
This API contains some basic functions for creating a database and is very useful if you are not familiar with making a database in computercraft. I will be updating this. Please tell me if you want something added or if something does not work correctly. For now all you need is a working knowledge of tables.Functions:
Spoiler
- dbCheck(name):
checks if the database or (name) exists.
-dbLoad(name)
Loads all data from the data Base.
-dbWrite(name,tbl)
Writes a table to the database.
-dbCreate(dbName)
Creates a database named (name).
-dbNewAccount(dbName,name,pass)
a function designed specially to make accounts for a login or server it will save the name and pass to the database as well as each person having his/her own ID.
- dbCheck(name):
checks if the database or (name) exists.
-dbLoad(name)
Loads all data from the data Base.
-dbWrite(name,tbl)
Writes a table to the database.
-dbCreate(dbName)
Creates a database named (name).
-dbNewAccount(dbName,name,pass)
a function designed specially to make accounts for a login or server it will save the name and pass to the database as well as each person having his/her own ID.
Examples:
Spoiler
eg.
if dbCheck("users") == true then
dbNewAccount("users","Andrew","Andy555")
else
dbCreate("users")
dbNewAccount("users","Andrew","Andy555")
end
this code has now made a data base that contains an acount as it is the first to be added its ID is 1 its name is Andrew and its pass is Andy555 to access this data use the followingaccounts = dbLoad("users")
now you can use then dataeg.
print(accounts[1][1]) print(accounts[1][2])this will output the name and then the password
I hope you guys find this useful =D
Pastebin link: http://pastebin.com/6MnHjV9g
Spoiler
--Created by UnethicalClown and MKlegoman357
function dbCheck(name)
if fs.exists(name) == true then
return true
else
return false
end
end
function dbLoad(name)
local temp = fs.open(name,"r")
local tmp = temp.readAll()
temp.close()
return textutils.unserialize(tmp)
end
function dbWrite(name,tbl)
local temp = fs.open(name,"w")
temp.write(textutils.serialize(tbl))
temp.close()
end
function dbCreate(dbName)
local temp = fs.open(dbName,"w")
temp.close()
end
function dbNewAccount(dbName,name,pass)
accounts = dbLoad(dbName)
if accounts == nil then
accounts = {
{
name,
pass
}
}
else
local num = #accounts+1
accounts[num] = {
{
name,
pass
}
}
end
dbWrite(dbName,accounts)
end
- ComputerCraft | Programmable Computers for Minecraft
- → UnethicalClown's Content


