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

GUI Help

Started by Csstform, 02 April 2014 - 11:03 AM
Csstform #1
Posted 02 April 2014 - 01:03 PM
What is the best way to get the size of a terminal, then print out a gui that fits that? Up until this point, I've done non-stretching GUIs, which I know people don't neccessarily like. *cough* Engineer *cough* Also, I know how to print a picture, but can I stretch that, or is there some other way to draw a background?

Thanks,
~Csstform
TheOddByte #2
Posted 02 April 2014 - 01:16 PM
What kind of gui do you mean? Can you make some paint-like example of what you mean?
And the best way to get the terminal size is ofcourse

local w, h = term.getSize()
A function that I use when drawing gui etc

local function drawBox( sX, fX, sY, fY, background )
	if term.isColor() then
		if background then
			term.setBackgroundColor( background )
		end
	end
	local line = ""
	for x = sX, fX do
		line = line .. " "
	end
	for y = sY, fY do
		term.setCursorPos( sX, y )
		term.write( line )
	end
end
As you probably have figured out it draws boxes, But it can be very useful when creating GUI
Edited on 02 April 2014 - 11:17 AM
Csstform #3
Posted 02 April 2014 - 01:27 PM
What kind of gui do you mean? Can you make some paint-like example of what you mean?
And the best way to get the terminal size is ofcourse

local w, h = term.getSize()
A function that I use when drawing gui etc

local function drawBox( sX, fX, sY, fY, background )
	if term.isColor() then
		if background then
			term.setBackgroundColor( background )
		end
	end
	local line = ""
	for x = sX, fX do
		line = line .. " "
	end
	for y = sY, fY do
		term.setCursorPos( sX, y )
		term.write( line )
	end
end
As you probably have figured out it draws boxes, But it can be very useful when creating GUI

Link to a mock up of what I want: https://github.com/GoldProgramming/GoldSuite/blob/master/tdlbak.nfp
apemanzilla #4
Posted 02 April 2014 - 02:03 PM
What kind of gui do you mean? Can you make some paint-like example of what you mean?
And the best way to get the terminal size is ofcourse

local w, h = term.getSize()
A function that I use when drawing gui etc

local function drawBox( sX, fX, sY, fY, background )
	if term.isColor() then
		if background then
			term.setBackgroundColor( background )
		end
	end
	local line = ""
	for x = sX, fX do
		line = line .. " "
	end
	for y = sY, fY do
		term.setCursorPos( sX, y )
		term.write( line )
	end
end
As you probably have figured out it draws boxes, But it can be very useful when creating GUI

Link to a mock up of what I want: https://github.com/GoldProgramming/GoldSuite/blob/master/tdlbak.nfp
So a function to resize a block like that to the screen?
Csstform #5
Posted 02 April 2014 - 02:11 PM
Thanks for the help, I think the folks on IRC have helped me figure this out.