Jump to content




Fill Api


16 replies to this topic

#1 NOTUSEDPLEASEDELETE

  • Members
  • 70 posts

Posted 24 August 2013 - 06:23 PM

Here's a new API I nmade:
The Fill API.
It adds a single function which is fillScreen(colour). It fills your screen with a color.
Features:
  • Works with any screen size.
  • Automatically alerts you when you have a normal computer.
Download:
http://pastebin.com/U3Lb4NQN
Or type into your computer:
pastebin get U3Lb4NQN fillapi

Example code:
http://pastebin.com/5ujDCYNs
Or type into the computer:
pastebin get 5ujDCYNs test
Ctrl+T to quit for bottom one.

Changelog:
v1.1:
  • Shrunk code.
To-do:
  • Add fillLine(color).


#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 24 August 2013 - 06:49 PM

Easier way:
local function fillScreen(color)
  term.setBackgroundColor(color)
  term.clear()
end


#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 24 August 2013 - 08:31 PM

So let's get this straight.. You made an API for just filling the screen with a color?
And you can just do as MysticT said above..

#4 jay5476

  • Members
  • 289 posts

Posted 24 August 2013 - 10:20 PM

also your code isnt even efficent for what it does mysticT's is the best way
but this is a more efficent your way
function fill(c) -- c = color
  if term.isColor() then
  w,h = term.getSize()
  term.setBackgroundColor(c)
 for y = 1, h do
   for x = 1, w do
	  term.setCursorPos(x,y)
	  write(" ")
   end
    end
  else
    error("Not An Advanced Computer/Turtle/Monitor", 0)
  end
end


#5 NOTUSEDPLEASEDELETE

  • Members
  • 70 posts

Posted 27 August 2013 - 03:20 PM

View PostMysticT, on 24 August 2013 - 06:49 PM, said:

Easier way:
local function fillScreen(color)
  term.setBackgroundColor(color)
  term.clear()
end

Thanks! Will be in next release!

#6 NOTUSEDPLEASEDELETE

  • Members
  • 70 posts

Posted 27 August 2013 - 03:41 PM

Had to get a new code. Promise it won't happen again!

v1.1 is out now:
  • Shrunk code. Thanks to MysticT for the code!


#7 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 27 August 2013 - 03:52 PM

Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.

#8 jay5476

  • Members
  • 289 posts

Posted 27 August 2013 - 04:42 PM

View PostKingdaro, on 27 August 2013 - 03:52 PM, said:

Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already

#9 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 28 August 2013 - 01:03 PM

View Postjay5476, on 27 August 2013 - 04:42 PM, said:

View PostKingdaro, on 27 August 2013 - 03:52 PM, said:

Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
Not really. There isn't a function in the paintutils api for that (at least there wasn't the last time I checked).

Here's a function for that:
function fillArea(x, y, w, h, color)
  if color then
    term.setBackgroundColor(color)
  end
  local line = string.rep(" ", w)
  for i = 0, h-1 do
    term.setCursorPos(x, y + i)
    term.write(line)
  end
end
That's the most efficient way to do it in CC. You could also add some checks to avoid drawing outside of the screen and save a few loops.

#10 NOTUSEDPLEASEDELETE

  • Members
  • 70 posts

Posted 30 August 2013 - 04:14 AM

View PostKingdaro, on 27 August 2013 - 03:52 PM, said:

Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
Will add fillRow(row, color) and fillColumn(column, color) soon!

#11 jay5476

  • Members
  • 289 posts

Posted 30 August 2013 - 06:00 AM

View PostMysticT, on 28 August 2013 - 01:03 PM, said:

View Postjay5476, on 27 August 2013 - 04:42 PM, said:

View PostKingdaro, on 27 August 2013 - 03:52 PM, said:

Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
Not really. There isn't a function in the paintutils api for that (at least there wasn't the last time I checked).

Here's a function for that:
function fillArea(x, y, w, h, color)
  if color then
	term.setBackgroundColor(color)
  end
  local line = string.rep(" ", w)
  for i = 0, h-1 do
	term.setCursorPos(x, y + i)
	term.write(line)
  end
end
That's the most efficient way to do it in CC. You could also add some checks to avoid drawing outside of the screen and save a few loops.
I believe its
paintutils.drawLine(startX,startY,endX,endY, color)


#12 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 August 2013 - 06:05 AM

View Postjay5476, on 30 August 2013 - 06:00 AM, said:

View PostMysticT, on 28 August 2013 - 01:03 PM, said:

View Postjay5476, on 27 August 2013 - 04:42 PM, said:

View PostKingdaro, on 27 August 2013 - 03:52 PM, said:

Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
Not really. There isn't a function in the paintutils api for that (at least there wasn't the last time I checked).

Here's a function for that:
function fillArea(x, y, w, h, color)
  if color then
	term.setBackgroundColor(color)
  end
  local line = string.rep(" ", w)
  for i = 0, h-1 do
	term.setCursorPos(x, y + i)
	term.write(line)
  end
end
That's the most efficient way to do it in CC. You could also add some checks to avoid drawing outside of the screen and save a few loops.
I believe its
paintutils.drawLine(startX,startY,endX,endY, color)
No paintutils.drawLine draws a line, where as MysticT's solution draws boxes on the screen with the given width and height, at the given x and y position.

#13 robotica34

  • Members
  • 28 posts
  • Locationpcapi.location

Posted 18 September 2013 - 12:32 PM

I was working on an API, which has fill screen and draw line lol, but it's just fillScreen(String color) or drawLine(String color, int line) (ik it's not java, but just clearing out that for you). I also have checkerboard, but sometimes it's behaving quite weird. I got it worked out now =)

#14 robotica34

  • Members
  • 28 posts
  • Locationpcapi.location

Posted 22 September 2013 - 09:30 AM

Soo... I can see your code doesn't have drawLine and drawColumn yet... I would actually give you negative reputation. In one post, you said that for catching right clicks just check for "right" parameter. It's not "right", it's 2. I'm not trying to advertise myself here, but I have better screen filling - just like the suggestion in comments, it can fill a specific area. If you want to fill the entire screen, just do pcapi.backCl(color, true). Do you even put effort to your code? Your status is "Script Kiddie", how do you then fail to do such simple tasks? If you want help, please watch Direwolf20's videos or if you already watched them, ask me for help or read everything in Ask A Pro. If you know how to code, don't post sxxx. Thanks.

#15 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 21 October 2013 - 12:40 PM

Sorry for kinda digging up the dead but... I just want to point out that this doesn't even work anymore :P
I looked at it in pastebin and well.. Look in the spoiler below
Error

And you should maybe extend your "API" a little if you want it to actually be considered an API rather than just a function.
Here's a small list of stuff you could add
* Box drawing
* Line drawing
* Circle drawing

- Hellkid98

#16 YoYoYonnY

  • Members
  • 49 posts

Posted 29 December 2013 - 06:26 AM

The code doesn't even work (Parameter doesn't match):
function fillScreen(colourans)
  if term.isColor() then
    term.setBackgroundColor(colorans)
    term.clear()
  else
    error("Advanced Monitor/Turtle Needed")
    end
  end


#17 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 29 December 2013 - 09:55 AM

It's useless.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users