467 posts
Location
Van Diemen's Land
Posted 11 May 2013 - 12:02 AM
QuickTils
v4.1
NOTE: Do not re-post as your own! Please PM me for allowance to change/modify functions and re-post as your own.
What is this API used for?Well, this API is used for many different things. It has an in-built login system that you can easily setup yourself, it has very simple functions to help your GUI look better and many more useful things!
What is the full list of functions?Here they are:
clean(x,y)
cursor(x,y)
color(color)
bColor(color)
skipLine(lines)
cPrint(string)
cWrite(string)
printCentered(string)
writeCentered(string)
existsFile(file)
writeFile(file,string)
pbGet(code,filename)
pbAdd(filename)
loginUser(textCol1,textCol2)
createUser(textCol1,textCol2,charTable)
fetchUserDetails(user,pass)
modifyUser(textCol1,textCol2)
removeUser(textCol1,textCol2)
Why don't you just download it and have a look at what it can do yourself?CHANGELOG
Spoiler
v 4.1:
Bug update for version 4!
- Fixed a few minor bugs
- Fixed pBGet and pBAdd
V 4:
New update!
- Re-wrote pBGet and pBAdd functions (please report any bugs to me)
- Made some minor adjustments
- Added 'svdragster' to the comments section
V 3.7:
New Update!
- Added function bColor (backgroundColor)
- Fixed pBGet function
V 3.62:
Bug fixes for v3.61!
- Fixed even more bugs in the clean function!
V 3.61:
Bug fixes for v3.6!
- Fixes bugs on the clean function
V 3.6:
Updates on the not-so-new in-built login system and the clean function!
- Made a code generator for the account creation (see for yourself)
- You can now set the cursor position when calling the clean function
- Other small changes that I cannot remember
V 3.5:
Updates on the new in-built login system!
- Renamed the function inputUser to loginUser
- Minor changes to the login GUI
- Made the function printCentered more centered
V 3.31:
Updates on the new in-built login system!
- Fixed some minor bugs with the modifyUser function
- Other small glitches and bugsDownloads:
V 4.1:Spoiler
pastebin get Ur9tN2Ct QuickTils V 4:Spoiler
pastebin get sXYiT99P QuickTils V 3.7:Spoiler
pastebin get 1uRnjRMj QuickTils V 3.61:Spoiler
pastebin get EHDvktDw QuickTils V 3.6:Spoiler
pastebin get H5e6vAGt QuickTils V 3.5:Spoiler
pastebin get sbjru7AR QuickTils V 3.31:Spoiler
pastebin get fmPHWSbE QuickTils V 3.3:Spoiler
pastebin get WXjtARrd QuickTils V 3:Spoiler
pastebin get jyws6muJ QuickTils V 2.3:Spoiler
pastebin get hHrAzh56 QuickTils V 2.1:Spoiler
pastebin get fZWu3ux1 QuickTils V 2:Spoiler
pastebin get xJnhyWZj QuickTils Credit where it's dueSpoiler
svdragster - for his help with HTTP functions (give this guy a raise!) Suggestions ListSpoiler
- Encryption/Decryption functions
- Create-a-menu functions
- String Utility functions
- Create-a-button functions
220 posts
Location
Germany
Posted 11 May 2013 - 11:11 AM
For skipLine you could do
function skipLine(lines)
local x, y = term.getCursorPos()
term.setCursorPos(x, y+lines)
end
467 posts
Location
Van Diemen's Land
Posted 12 May 2013 - 06:17 PM
That's a pretty good idea actually…Thanks. Saves time and my fingers.
467 posts
Location
Van Diemen's Land
Posted 12 June 2013 - 06:43 AM
New update! This one fixes some GUI in the login system and fixes the printCentered function (wasn't entirely centered) and also fixed the removeUser function's colors.
Happy coding!
7508 posts
Location
Australia
Posted 12 June 2013 - 06:59 AM
Your centered print/write functions are confusing me a little, why are you picking the max number between the `centered` position and the current cursors y position? o.O
This is how I would be inclined to do the functions:
function writeCentered(text, y) --# allowing the person to set the y position is helpful
local w, h = term.getSize() --# the variables should be localized
local _, cy = term.getCursorPos() --# the variables should be localized
local xPos = math.floor((sw-#text)/2) + (#text % 2 == 0 and 1 or 0) --# calculate the center, and shift it when the text length is even an length as it looks better in the shifted position
term.setCursorPos(xPos, y or cy)
write(text)
end
function printCentered(text, y)
--# why reinvent the wheel, we have a function that does this already, so just pass the string to that one with a new line character appended
writeCentered(text..'\n', y)
end
Also I would suggest in your function `pbGet` instead of returning true, return the existence of the file, the pastebin program does not always succeed. So something like this would be better:
function pbGet(code, filename)
if not fs.exists(filename) then
shell.run("pastebin get "..code.." "..filename)
return fs.exists(filename)
end
return false
end
467 posts
Location
Van Diemen's Land
Posted 15 June 2013 - 06:57 AM
Sorry the updates are coming slow, I havent had much time to work on it lately, with homework and all, but I'll do my best.
@theoriginalbit
The one I use works, and as long as it works and it is useful it can be used as a function. I don't understand why the y variable needs to be defined when you call the writeCentered/printCentered function, as this one works fine. The only problem was that it was 1 character bigger on one of the sides so I had to add a +1 on the x variable. It is also longer doing it the way you have done, and there is no benefit in making it longer apart from defining the y position, which is already done. You can just set the cursor before calling this function as well.
467 posts
Location
Van Diemen's Land
Posted 19 June 2013 - 04:07 AM
Sorry about the bugs in 3.6, I forgot to re-write the API's functions.
220 posts
Location
Germany
Posted 29 June 2013 - 09:48 AM
Another tip, your pastebin codes aren't really safe. Someone could just write a virus and call it pastebin, and the api starts the virus!
If you want to make it safer, use the
pastebin api and the http api :)/>
467 posts
Location
Van Diemen's Land
Posted 30 June 2013 - 12:51 AM
Another tip, your pastebin codes aren't really safe. Someone could just write a virus and call it pastebin, and the api starts the virus!
If you want to make it safer, use the
pastebin api and the http api :)/>
What do you mean exactly?
220 posts
Location
Germany
Posted 30 June 2013 - 06:27 AM
Instead of
shell.run("pastebin post "..file)
Use the Http.post and the
"creating a paste" api.
467 posts
Location
Van Diemen's Land
Posted 01 July 2013 - 03:11 AM
I get you now! I was going to do that soon but I keep forgetting how to do it…
Don't you do something like this?
local variable = http.get("http://www.pastebin.com/"..code)
local variableContent = variable.readAll()
local file = fs.open(<filename>,"w")
file.write(variableContent)
(pBGet function)
220 posts
Location
Germany
Posted 01 July 2013 - 01:02 PM
local variable = http.get("http://pastebin.com/raw.php?i="..code)
467 posts
Location
Van Diemen's Land
Posted 02 July 2013 - 04:16 AM
Ok thanks. So, with the pbAdd function would I use the API? How would you do it?
P.S Any more suggestions? :P/>
220 posts
Location
Germany
Posted 02 July 2013 - 11:48 AM
I could give you the code, but that would be boring :3
You can look inside of the pastebin program on everyone computer at line 21 ;)/>
467 posts
Location
Van Diemen's Land
Posted 02 July 2013 - 06:03 PM
Yeah I did that yesterday (looked at the Pastebin put function) and didn't get much out of it…
Btw I tried my pBGet and it came up with the HTML code…Which is what I don't want.
220 posts
Location
Germany
Posted 03 July 2013 - 01:14 PM
You need the
pastebin.com/raw.php?i=
or it will give you the html stuff.
Alright, for the putting:
You have to make a http.post to the url "
http://pastebin.com/api/api_post.php".
But you have to add some stuff so pastebin will know what to post on pastebin.
The required parameters are
on the website:
Creating A New Paste, [Required Parameters]
Include all the following POST parameters when you request the URL:
1. api_dev_key - which is your unique API Developers Key.
2. api_option - set as 'paste', this will indicate you want to create a new paste.
3. api_paste_code - this is the text that will be written inside your paste.
The parameters in lua:
local parameters = (
"api_dev_key="..key.."&".. -- The key is "0ec2eb25b6166c0c27a394ae118ad829"
"api_option=paste&"..
"api_paste_name="..text -- Text to put on pastebin.
)
Pastebin will respond the link, so if you want to get it, you need to do
local response = http.post(putUrl, parameters)
the parameters also could look like this:
parameters = "api_dev_key="..key.."&".."api_option=paste&api_paste_name="..text
467 posts
Location
Van Diemen's Land
Posted 04 July 2013 - 03:20 AM
Ok..cool. I got some of it but the rest was a bit weird to me…The pBGet function is easy though. :)/> Thanks.
EDIT: Speaking of which, I should go update QuickTils. Expect to see both the pB functions fixed…well, the pBGet one at least :)/>