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

Angel API v2.3 *featuring a smooth line creator*

Started by Reactive Owl, 10 January 2013 - 09:53 PM
Reactive Owl #1
Posted 10 January 2013 - 10:53 PM
Angel API - BETA v2

Functions:


-Utility-

angel.clear() - clears the screen and sets the cursor to 1,1
angel.setPos(x,y) - cursor set position alternative/shortcut
angel.disableTermination() - disables ctrl+t
angel.enableTermination() - enables ctrl+t

-Angel Wing Pixel-

angel.wingPixel(x,y,color)

-Angel Wing Line Creator-

angel.wingLine(x,y,line length,line type, line color)

(I will be adding more line types in later updates)

-Download-
having an issue with dropbox at the moment…

-Change Log-
SpoilerAngelAPI v2.3
[Fixed]
-TOB accidentally changed a vital part of Wing Line

AngelAPI v2.2
-Code Optimized (thanks to TheOriginalBIT)

AngelAPI v2.1
-removed an unnecessary section of code in the Wing Pixel function

AngelAPI v2.0
+Release




-CODE-
Spoiler



--+Angel API v2.3+--

---------------------
--Utility Functions--
---------------------



function wingLogo(x,y)
term.clear()
term.setCursorPos(x,y)
print("          _______        _______            ")
print("         {_____.  .____.  ._____}           ")
print("           {____.   ..   .____}             ")
print("              {____.  .____}                ") 
print("      ___  ,____   ____,   ____,   _,       ") 
print("     ||_|| ||  || ||  __, ||___,  ||        ") 
print("     || || ||  || ||__||  ||___,  ||___,    ")
end

function clear()
term.clear()
term.setCursorPos(1,1)
end

--Slowly prints text to the screen
function slowP(text)
textutils.slowPrint(text)
end

--set cursor shortcut
function setPos(x,y)
term.setCursorPos(x,y)
end

--Funtions to disable and then re-enable program termination(ctrl+t)
function disableTermination()
pulloriginal = os.pullEvent
os.pullEvent = os.pullEventRaw
end

function enableTermination()
if os.pullEvent ~= pulloriginal then
os.pullEvent = pulloriginal
end
end


--[[
--------------
  Angel Wing Pixel v1.1
--------------
Creates a pixel at x,y of the desired color

]]--

function wingPixel(x, y, color)
local colorcheck = term.isColor and term.isColor()
color = color % 16
setPos(x,y)
if colorcheck then
term.setBackgroundColor( 2 ^ ( color - 1 ) )
end
write(" ")
if colorcheck then
term.setBackgroundColor( colors.black )
end
end

--[[
-------------------
  Angel Wing Line Creator v1.0
-------------------
\Line Types/
1 = ---------------------------
2 = ===========================
3 = +-------------------------+

\Math/

first off if you set the x to 1(left edge of screen) the most frames that will fit to the right edge is 50
the math for this function is configured to automatically adjust itself so it will stop at the edge of the
screen, even if you input something crazy like:
angel.wingLine(25,5,60,1) <-this will make a white line type 1 at 25,5 and will stop when it hits the edge of the screen

\Color/

*if you use this on a color terminal you can set a 5th parameter, color!
ex: angel.wingLine(4,8,25,2,4)
the colors are represented by numbers
1  - white
2 - orange
3 - magenta
4 - lightBlue
5 - yellow
6 - lime
7 - pink
8 - gray
9 - lightGray
10 - cyan
11 - purple
12 - blue
13 - brown
14 - green
15 - red
16 - black
*without a 5th parameter it will just default it to white
--]]


--(Xpos,Ypos,line length,line type,line color)
function wingLine(x,y,frames,wLType,color )
local colorcheck = term.isColor()  

local sizeX, sizeY = term.getSize()

--sets a maximum of sizeX - 1 frames
if frames > ( sizeX - 1) then  
frames = sizeX - 1
end

--sets a maximum of frames x
if x > 50 then  
x = sizeX - 1
end

--sets a maximum of 19 y
if y > sizeY then  
y = sizeY
end

--sets max line type number
if wLType > 3 then
wLType = 1
end

--Code for correcting the line
local offset = 0
local xframes = x + frames
local correction = xframes-50

if frames <= 50 and frames > x then
if xframes > 50 then
offset = correction
end
elseif frames <= 50 and frames < x then
if xframes > 50 then
offset = correction
end
end



setPos(x,y)

if colorcheck then
color = 2 ^ ( color - 1 )
end

framecorrection = frames-offset
function draw( char, tWingLine )
term.setTextColor(color)
write( char )
setPos( x + 2, y )
for loadframes = 1, framecorrection do
local a = loadframes + 1

if colorcheck then
		 term.setTextColor(color)
end

local tpos = { term.getCursorPos() }

setPos(tpos[1] - 1,tpos[2])
write(tWingLine[a]..tWingLine[1])
		if colorcheck then
term.setTextColor(1)
		end
end
end
---------------------------------------------------

--line type 1
if wLType == 1 then
local char = "-"
local wingline = {
"-","-","-","-","-","-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-"
}
draw( char, wingline )
--line type 2
elseif wLType == 2 then
local char = "="
local wingline = {
"=","=","=","=","=","=","=","=","=","=","=","=","=","=","=",
"=","=","=","=","=","=","=","=","=","=","=","=","=","=","=","=","=","=","=","=",
"=","=","=","=","=","=","=","=","=","=","=","=","=","=","=","="
}
draw( char, wingline )
--line type 3
elseif wLType == 3 then  
local char = "+"
local wingline = {
"+","-","-","-","-","-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-"
}
draw( char, wingline )
end
end

superaxander #2
Posted 11 January 2013 - 01:20 AM
Looks cool!
theoriginalbit #3
Posted 11 January 2013 - 02:04 AM
Looks good :)/> can I make one suggestion to your converting 1-16 into a colour….
example from your code:


if color == 1 then
		barColor = tcolor[2]
elseif color == 2 then
		barColor = tcolor[3]
elseif color == 3 then
		barColor = tcolor[4]
elseif color == 4 then
		barColor = tcolor[5]
elseif color == 5 then
		barColor = tcolor[6]
elseif color == 6 then
		barColor = tcolor[7]
elseif color == 7 then
		barColor = tcolor[8]
elseif color == 8 then
		barColor = tcolor[9]
elseif color == 9 then
		barColor = tcolor[10]
elseif color == 10 then
		barColor = tcolor[11]
elseif color == 11 then
		barColor = tcolor[12]
elseif color == 12 then
		barColor = tcolor[13]
elseif color == 13 then
		barColor = tcolor[14]
elseif color == 14 then
		barColor = tcolor[15]
elseif color == 15 then
		barColor = tcolor[16]
else
		barColor = tcolor[1]
end
change it to be this

barColor = 2 ^ ( color - 1 )
colors are just binary bits and can be worked out with 2 ^ n :)/>
Reactive Owl #4
Posted 11 January 2013 - 06:37 AM
Looks good :)/> can I make one suggestion to your converting 1-16 into a colour….

change it to be this

barColor = 2 ^ ( color - 1 )
colors are just binary bits and can be worked out with 2 ^ n :)/>

Yes this is much better thank you,
your input is appreciated.
Eric #5
Posted 11 January 2013 - 09:07 AM
These functions do nothing:

--gives you the cursor x position
function getPosX(posx)
        tpos = {term.getCursorPos()}
        posx = tpos[1]
end
--gives you the cursor y position
function getPosY(posy)
        tpos = {term.getCursorPos()}
        posy = tpos[2]
end

That's not how functions work


Also, what's the point in showing a loading bar when all you do is `sleep` between updates? Why not just load the darn thing immediately?
Reactive Owl #6
Posted 11 January 2013 - 10:34 AM
what's the point in showing a loading bar when all you do is `sleep` between updates? Why not just load the darn thing immediately?

this is for aesthetic reasons….
it's eye candy…nothing more

as for those functions I was just testing those and I posted this at like 4AM so I didn't mean to include those
-deleted-
zekesonxx #7
Posted 11 January 2013 - 10:37 AM
Annoying eye candy.

It's like waiting at a stoplight when you are the only car for two miles.
Reactive Owl #8
Posted 11 January 2013 - 10:39 AM
do you have anything better in mind?….
if you do program it yourself…
if you don't like mine, don't use it…

or make it short like 5 frames or something
edit:
sorry this sounds mean…
I mean this in a nice way..
zekesonxx #9
Posted 11 January 2013 - 12:36 PM
A progress bar is designed to show progress of something, like downloads.

The bar is updated whenever another file finishes. There is no fucking point in having a fake loading bar.
Reactive Owl #10
Posted 11 January 2013 - 12:39 PM
A progress bar is designed to show progress of something, like downloads.

The bar is updated whenever another file finishes. There is no fucking point in having a fake loading bar.

I'm not saying that you don't have a point…
do you have an idea of how to code that??

with that said lets get back to more constructive comments please..
Reactive Owl #11
Posted 11 January 2013 - 05:34 PM
http://www.computerc...go-as-progress/

Shit….
well that just rendered the past couple days useless…
theoriginalbit #12
Posted 11 January 2013 - 05:43 PM
http://www.computerc...go-as-progress/

Shit….
well that just rendered the past couple days useless…

Haha sorry… :)/>

- snip -
do you have an idea of how to code that??

I do :)/> :P/>
Reactive Owl #13
Posted 11 January 2013 - 08:03 PM
-Angel API version 2.0-
+released

Added functions:
angel.wingPixel(x,y,color)

Changed Functions:
angel.loadingBar()
angel.wingLine(x,y,line length,line type,line color)
Reactive Owl #14
Posted 12 January 2013 - 08:51 AM
-Angel API version 2.3-
-code optimized

-notes on next release-
I'm currently working on a window creator
so far I have it making the window properly but its lacking a lot
I don't want to release the next edition without this function
I'm going to estimate three days as the finish date…

thank you