This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MarkPwns1's profile picture

[Beta] Convenience API

Started by MarkPwns1, 05 December 2013 - 08:46 PM
MarkPwns1 #1
Posted 05 December 2013 - 09:46 PM
Convenience API
Normal Lua, only less lines of code!



Functions:
Spoiler



Convenience.ColorPrint(colors.red, "This is some red printed text.") --Prints red text


Convenience.ColorWrite(Colors.blue, "This is some blue written text.") --Writes blue text


Convenience.ClearScreen() --Clears screen and set cursor position to 1,1(Top left).


Convenience.PasswordLock("My password.", "This is my password prompt.") --Displays a password prompt, with the promt text specified, and the password.


Convenience.PositionPrint(4, 5, "This is some text printed at the coordinates 4X and 5Y.")


Convenience.PositionWrite(4, 5, "This is some text written at the coordinates 4X and 5Y.")


Convenience.GiveCredit() --Gimme some credit.


Convenience.CenterPrint("This is some printed text centered on the line it's written on.") --Centers text, but only on the line it's on.


Convenience.CenterWrite("This is some written text centered on the line it's written on.") --Centers text, but only on the line it's on.




Installation
Spoiler


Make sure you have HTTP enabled in the ComputerCraft configuration file, once you do, type the text below into your computer:

pastebin get tBka3kmL Convenience

Then, once you have the API installed, for the API to take effect, type this at the start of your code/program that you plan to make:

os.loadAPI("Convenience") --Or what you saved the filename as.



Screenies! (Pretty outdated, look in "Functions" for up-to-date code.)

Spoiler




OUTPUT:


And after the password prompts clears the screen:




I have just made this earlier today, so it's obviously going to be frequently updated. All I need to do is edit the pastebin file, and BOOM! Instant update.
oeed #2
Posted 06 December 2013 - 05:17 AM
Looks good!

It's nice to see that I'm not the only one who's capitalising the first letter of things. (e.g. ​Drawing.DrawCharactersCenter)
theoriginalbit #3
Posted 06 December 2013 - 05:24 AM
It's nice to see that I'm not the only one who's capitalising the first letter of things. (e.g. ​Drawing.DrawCharactersCenter)
Since when do you like the C# way of doing things, esp since you like Obj-C so much. :P/>
distantcam #4
Posted 06 December 2013 - 06:33 AM
It's nice to see that I'm not the only one who's capitalising the first letter of things. (e.g. ​Drawing.DrawCharactersCenter)
Since when do you like the C# way of doing things, esp since you like Obj-C so much. :P/>

Obviously the awesomeness of C# has won him over.
oeed #5
Posted 06 December 2013 - 07:43 AM
It's nice to see that I'm not the only one who's capitalising the first letter of things. (e.g. ​Drawing.DrawCharactersCenter)
Since when do you like the C# way of doing things, esp since you like Obj-C so much. :P/>

To be honest, I've never touched C#. I didn't realise this was it's convention. I think it just looks nicer when using full stops, which Objective-C doesn't (well, not nearly as much).
MarkPwns1 #6
Posted 06 December 2013 - 05:04 PM
xD, thanks for all the enourmous support, I'm updating this as we speak, and also, I also came from VB.NET and C#, hence the caps. :D/>

Edit: How do you like SetPassword()? I honestly think I'm the only one who included this in any API. :P/>
2nd Edit: Wait, YOU'RE the guy who made PearOS?! YOU'RE FAMOUS!! :D/> I LOVE PearOS! I rub it in my friends' faces whenever I have it installed on a modded survival server! And they're stuck with the inefficient CraftOS. YOU'RE MY IDLE! o.o
Edited on 06 December 2013 - 04:31 PM
Alice #7
Posted 10 December 2013 - 12:21 PM
OffTopic:
YOU'RE MY IDLE! o.o
Grammar nazi; should be IDOL instead of IDLE.
OnTopic: Very nice, but I'm a bit disappointed of the capitals, do you mind if I change it to lowercase when I use it? I'll include credit if you let me.
Also: Very nice idea with the password
theoriginalbit #8
Posted 10 December 2013 - 07:53 PM
Grammar nazi; should be IDOL instead of IDLE.
Maybe oeed does make MarkPwns1 idle… you don't know :P/>
oeed #9
Posted 10 December 2013 - 09:27 PM
2nd Edit: Wait, YOU'RE the guy who made PearOS?! YOU'RE FAMOUS!! :D/> I LOVE PearOS! I rub it in my friends' faces whenever I have it installed on a modded survival server! And they're stuck with the inefficient CraftOS. YOU'RE MY IDLE! o.o

Why thank you :)/> I've got a new OS coming out fairly soon (about another month of solid work), and it blows PearOS out of the water, you an actually do stuff with it :P/>
Edited on 10 December 2013 - 08:27 PM