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

Columna1's programs | View a huge file all at once | and more

Started by columna1, 19 June 2013 - 04:53 PM
columna1 #1
Posted 19 June 2013 - 06:53 PM
Over the long time that i have been using computercraft I have made many programs. Mostly small, random programs with not much value other than entertainment. I have decided to post some of my programs here in hopes that someone would have fun or learn from them. so here they are:

Writing on multiple monitors at once (for huge files/pics in ascii)
Spoilerfirst of all i have to say this does not have color support (yet) and there are some limitations
(which are listed at the top of the program)
This is to display huge files on multiple monitors all at once. The usage is Bigfile [file here]
You have to set this up a special way which is said in the top of the program

here is the code its also located here: http://pastebin.com/wpSpW5LA
Spoiler



--v 1.1 -- this is untested but it is supposed to make it so that you can start at a higher monitor than monitor_0 please post on the forums if there is a problem

--this is a program made by columna1 please do not claim as your own
--You have permission to edit and use this code as you please just make sure to credit me


--How to use
--make a bunch of monitors THEY ALL HAVE TO BE THE SAME SIZE all next to eachother
--make sure you make a rectangle
--connect each one with a wired modem and connect them all to the computer on the left side
--NOW LISTEN UP THIS IS IMPORTANT*********!!!!!!!!!!!!!!
--you have to connect all the monitors in a certain way
--facing the frot you need to connect each monitor from left to right starting from the first row
--then you need to go down to the second row and add from left to right one by one
--and continue one by one etc

--some tips if you mess up or already have monitors connected with modems in a world
--you can change the startmonitor variable below to specfy the first monitor
--if you accidentaly clicked one and connected it in the wrong order you can use some nbt editor to go
--to that block and set the value "peripheral id" to -1 and go to the save folder and into the computer folder
--and open the file: lastid_monitor and change it to -1 or whichever was the last correct connection

--if you already placed some:
--go to the save folder and into the computer folder
--and open the file: lastid_monitor and change it to -1


-- limitations:
--all monitors have to be the same size!
--there cant be uneven edges (it cant have a layer that is 3 wide when the rest is 4)

startmonitor = 0 -- change this is your monitors dont start at monitor_0

sm = startmonitor
modem = peripheral.wrap("left")
xmons = 8
ymons = 6
scale = 0.5
modem.callRemote("monitor_"..sm,"setTextScale",scale)
xchars,ychars = modem.callRemote("monitor_"..sm,"getSize")
arg = {...}
if fs.exists(arg[1]) == false then
		error("no such file")
end
dataa = ""
line = {}
rum = 1
l = 0
file = fs.open(arg[1],"r")
		while rum do
				rum = file.readLine()
				l = l + 1
				if rum then line[#line+1] = rum end
		end
print(l)
lines = l
file.close()
for i = 0,xmons*ymons - 1 do
		modem.callRemote("monitor_"..i+sm,"setTextScale",scale)
		modem.callRemote("monitor_"..i+sm,"clear")
end
function str(sn,stri)
		if split > 1 then
				stt = stri:sub((sn-1)*xchars,sn*xchars)
				return stt
		end
end
function printLine(line,strings)
		mon = 0
		for d = 1,ymons-1 do
				if line > ychars*d then mon = xmons*d end
		end
		split = 1
		for c = 1,xmons - 1 do
				if #strings > xchars*c then split = c+1 end
		end
		monadd = 0
		for s = 1,split do
				modem.callRemote("monitor_"..mon+monadd+sm,"setCursorPos",1,line-((mon/xmons)*ychars))
				modem.callRemote("monitor_"..mon+monadd+sm,"write",str(s,strings))
				monadd = monadd + 1
		end
end
fi = fs.open(arg[1],"r")
if ychars*ymons > lines then
		for i = 1,lines-1 do
				printLine(i,fi.readLine())
		end
else
		for i = 1,ychars*ymons do
				printLine(i,fi.readLine())
		end
end
fi.close()

and some pics
Spoiler

Monitor password program
SpoilerThis is something I made months ago for myself on the server I used to own
honestly there may be bugs but I don't remember how I did the code before but if you asked me I would look through the code and answer any questions for you

This is one of those monitor password enter-er things that everyone seems to be making recently (and i promise i made this months ago) but this one has a full keyboard with shift and everything

Here is the code: http://pastebin.com/KmAd2VHk
Spoiler
margin = 1
mon = peripheral.wrap("right")
mon.setTextScale(1)
shift = true
cur = false
mon.clear()
password = "Pass!"
on = true
xx = 1
yy = 7
keys = {
{"1","2","3","4","5","6","7","8","9","0","-","="," "," "},
{"q","w","e","r","t","y","u","i","o","p","[","]"," ","S"},
{"a","s","d","f","g","h","j","k","l",";","'"," "," ","X"},
{"z","x","c","v","b","n","m",",",".","/"," ","<",">","_"}
}
keysShift = {
{"!","@","#","$","%","^","&amp;","*","(",")","_","+"," "," "},
{"Q","W","E","R","T","Y","U","I","O","P","{","}","|","s"},
{"A","S","D","F","G","H","J","K","L",":"," "," "," ","x"},
{"Z","X","C","V","B","N","M"," "," ","?"," ","<",">","_"}
}
temppass = ""
function prints(offx,offy,tabl)
-- print("print function called")
  for i = 1,#tabl do
	for j = 1,#tabl[i] do
	  mon.setCursorPos(offy+j,offx+i)
	  mon.write(tabl[i][j])
	  mon.setCursorPos(xx,yy)
	end
  end
end
function win()
  on = false
  printreadout(6,8,"Pass")
end
function lose()
  on = false
  printreadout(6,8,"Fail")
end
function pass(str)
  if str == password then
	win()
  else
	lose()
  end
end
function printreadout(x,y,str)
  mon.setCursorPos(x,y)
  mon.write(str)
  xx = #str+1
  yy = y
end
function printtable(table)
  for i = 1,#table do
	print(table[i])
  end
end
function detect(offx,offy,tabl)
  event,side,x,y = os.pullEvent("monitor_touch")
  x = x - offx
  y = y - offy
  height = #tabl+offy
  width = #tabl[1]+offx
  --[[
  print(x)
  print(y)
  print(offx)
  print(offy)
  print(x-offx)
  print(y-offy)
  ]]--
  if x > 0 and y < height and y > 0 and x < width then
	letter = tabl[y][x]
	if letter == ">" then
	  pass(temppass)
	elseif letter == "X" and shift == false or letter == "x" and shift == true then
	  --clear enter (clear the table 'temppass')
	  printreadout(margin,height+2,"						  ")
	  temppass = ""
	elseif letter == "_" then
	  temppass = temppass.." "
	elseif letter == "<" then
	  temppass = temppass:sub(0,#temppass-1)
	  printreadout(margin,height+2,"						   ")
	  printreadout(margin,height+2,temppass)
	elseif letter == " " then
	  
	elseif letter == "S" and shift == false or letter == "s" and shift == true then
	  cur = not cur
	else
	  temppass = temppass..letter
	end
  end
end
height = #keys
mon.setCursorPos(margin,height+2)
mon.setCursorBlink(true)
while on do
if shift == true and cur == false then
  shift = false
  prints(margin,2,keys)
elseif shift == false and cur == true then
  shift = true
  prints(margin,2,keysShift)
end
if shift == false then
  detect(2,margin,keys)
elseif shift == true then
  detect(2,margin,keysShift)
end
printreadout(margin,height+2,temppass)
end
mon.setCursorBlink(false)


Pics:
Spoiler

.nfp Viewer
SpoilerThis is a program I made when I decided that using npaint pro to view huge pics was too slow and hard to use
So I made this, the controls are simple, arrow keys to scroll and enter to exit

this was made in a hurry so do not expect a very feature full viewer

here is the code: http://pastebin.com/CfA71yH4
Spoiler
width = 0
height = 0
args = {...}
file = args[1]
w,h = term.getSize()
f = fs.open(file,"r")
--data = f.readAll()
f.close()
fi = fs.open(file,"r")
lines = 0
line = fi.readLine()
width = #line
while line do
  line = fi.readLine()
  lines = lines + 1
end
fi.close()
height = lines
--print(width)
--print(height)
mx = 0
my = 0
image = {}

color = {
["0"] = 1,
["1"] = 2,
["2"] = 4,
["3"] = 8,
["4"] = 16,
["5"] = 32,
["6"] = 64,
["7"] = 128,
["8"] = 256,
["9"] = 512,
["a"] = 1024,
["b"] = 2048,
["c"] = 4096,
["d"] = 8192,
["e"] = 16384,
["f"] = 32768,
[" "] = 32768
}
print(width)
print(height)
sleep(1)
fil = fs.open(file,"r")
for y = 1,height do
  line = fil.readLine()
  image[y] = {}
  os.queueEvent("randomEvent")
  os.pullEvent()
  print("did event "..y)
  for x = 1,width do
	--os.queueEvent("randomEvent")
	--os.pullEvent()
	if line then
	  line = line..""
	  image[y][x] = color[line:sub(x,x)]
	else
	  print("uh oh no value at x: "..x.." y: "..y)
	end
  end
end
fil.close()
function display()--xx,yy)
	for xc = 1,w do
	  for yc = 1,h do
		if xc <= width and yc <= height then
		  --print(image[xc+mx][yc+my])
		  num = image[yc+my][xc+mx]
		  --write(num)
		  if num then term.setBackgroundColor(image[yc+my][xc+mx]) else term.setBackgroundColor(colors.black) end--[yc+my]) end
		  term.setCursorPos(xc,yc)
		  write(" ")
		end
	  end
	end
end
term.clear()
display(0,0)
run = true

function go()
  term.setBackgroundColor(colors.black)
  term.clear()
  display(mx,my)
end

while run do
  event,key = os.pullEvent("key")
  if key == 200 and my >= 20 then
	my = my - 20
	go()
  elseif key == 208 and my <= height - h - 20 then
	my = my + 20
	go()
  elseif key == 203 and mx >= 20 then
	mx = mx - 20
	go()
  elseif key == 205 and mx <= width - w - 20 then
	mx = mx + 20
	go()
  elseif key == 28 then
	 run = false
  end
end

and some pics:
Spoiler

Mandelbrot fractal viewer
SpoilerThis I made after I saw funshinex's version but that was broken for me so I made my own

here is the code: http://pastebin.com/9G7bKrjR
Spoiler
function load()

	cou = 0
	highest = 0
	
	pixels = {}
	w,h = term.getSize()
	
	for x = 1,w do
		pixels[x] = {}
		for y = 1,h do
			pixels[x][y] = 0
		end
	end
	zoom = 1 -- 419622325484.5764--  1779.803945297549--1--10.87870050486385
	moveX =  -0.5 -- -1.574958474577329--  -0.7431533999637661--  -0.5 -- -0.756171356183087
	moveY =  0 -- -0.005723458362839707--  -0.1394057861346605--0 -- -0.09928312602189358
	maxIterations = 255

	for x = 1,w do
	for y = 1,h do
	pr = 1.5 * (x - w / 2) / (0.5 * zoom * w) + moveX
		pi = (y - h / 2) / (0.5 * zoom * h) + moveY
		newRe = 0
		newIm = 0
		oldRe = 0
		oldIm = 0
		for i = 1,maxIterations do
			oldRe = newRe
			oldIm = newIm
			newRe = oldRe * oldRe - oldIm * oldIm + pr
			newIm = 2 * oldRe * oldIm + pi
			cc = i
			cd = i
			if newRe * newRe + newIm * newIm > 4 then break end
		end
		temp = math.floor(cc / 16)
		if temp > 0 then
		col = temp - 1
		else
		col = temp
		end
		if cc == 255 then col = 15 end
		pixels[x][y] = col
	end
	end
end

function draw()
	term.clear()
	for x = 1,w do
		for y = 1,h do
			ting = pixels[x][y]
			term.setBackgroundColor(2^pixels[x][y])
			term.setCursorPos(x,y)
			term.write(" ")
		end
	end
end

load()
draw()
sleep(1)


and some pics
Spoiler

2D/3D Turtle Printer
Spoiler
2D/3D turtle printer

by:columna1





This is my first program that I have released on the computercraft forums.

I have spent a lot of time and effort making this and making it relatively bug free.

On this post i will include the printer program as well as some screenshots and 2 demo files to print






I know nitrogen fingers has a 3D printer but this was in the works before he released his.

I would Love to see what pictures you can make with this so please post pictures showing what you have made


First is the pictures
Spoiler

All of these have been printer by a turtle using my printing program.

Nyan cat!

computer 2d image
(can be printed two different ways)

computer 3d

Main menu

2D menu

3D menu




Next is the star of the show The printing program!

Spoiler
--[[ Made by columna1 Please dont claim as your own ]]--
plane = 0
line = {}
x = 0
selecteditem = 1
mainmenu = true
menu2d = false
menu3d = false
col = {
w = 1,
o = 2,
m = 3,
b = 4,
y = 5,
l = 6,
p = 7,
G = 8,
g = 9,
c = 10,
P = 11,
B = 12,
n = 13,
e = 14,
r = 15,
d = 16,
s = 20
}
--functions
function forward()
forw = true
while forw do
  if turtle.forward() then
   forw = false
  else
   turtle.dig()
   turtle.attack()
  end
end
end
function placeDown()
if turtle.getItemCount(selected) &amp;amp;gt; 1 then
  turtle.placeDown()
else
  nom = true
  print("Enter material")
  while nom do
   sleep(1)
   if turtle.getItemCount(selected) &amp;amp;gt; 1 then
	nom = false
	print("continuing")
	turtle.placeDown()
   end
  end
end
end
function place()
if turtle.getItemCount(selected) &amp;amp;gt; 1 then
  turtle.place()
else
  nom = true
  print("Enter material")
  while nom do
   sleep(1)
   if turtle.getItemCount(selected) &amp;amp;gt; 1 then
	nom = false
	print("continuing")
	turtle.place()
   end
  end
end
end
function printer()
sleep(0.1)
up = job.readLine()
for j = 1,tonumber(up) do
  curline = job.readLine()
  if x == 1 then
   curline = curline:reverse()
  end
  for i = 1,#curline do
   line[i] = curline:sub(i,i)
  end
  for i = 1,#line do
   if col[line[i]] == 20 then
	--no selecting
   else
	turtle.select(col[line[i]])
	selected = col[line[i]]
   end
   if plane == 0 then
	if col[line[i]] == 20 then
	 --no placing
	else
	 placeDown()
	end
	forward()
   else
	if x == 0 then
	 if col[line[i]] == 20 then
	  --no placing
	 else
	  place()
	 end
	 turtle.turnRight()
	 forward()
	 turtle.turnLeft()
	elseif x == 1 then
	 if col[line[i]] == 20 then
	  --no placing
	 else
	  place()
	 end
	 turtle.turnLeft()
	 forward()
	 turtle.turnRight()
	end
   end
  end
  if plane == 0 then
   if x == 0 then
	turtle.turnRight()
	forward()
	turtle.turnRight()
	forward()
	x = 1
   elseif x == 1 then
	turtle.turnLeft()
	forward()
	turtle.turnLeft()
	forward()
	x = 0
   end
  else
   if x == 0 then
	turtle.down()
	turtle.turnLeft()
	forward()
	turtle.turnRight()
	x = 1
   elseif x == 1 then
	turtle.down()
	turtle.turnRight()
	forward()
	turtle.turnLeft()
	x = 0
   end
  end
end
end
function exit()
main = false
term.clear()
term.setCursorPos(1,1)
print("Thanks for using Columna1's printer")
end
function face()
plane = 1
end
function d3()
  sleep(0.1)
  selecteditem = 1
  menu3d = true
  while menu3d do
	term.clear()
	term.setCursorPos(1,1)
	printmenu(menu3)
	event,key = os.pullEvent("key")
	onkeypress(key,menu3)
  end
end
function d2()
  selecteditem = 1
  menu2d = true
  while menu2d do
	term.clear()
	term.setCursorPos(1,1)
	printmenu(menu2)
	event,key = os.pullEvent("key")
	onkeypress(key,menu2)
  end
end
function exit3d()
  selecteditem = 1
  menu3d = false
  selecteditem = 1
end
function exit2d()
  selecteditem = 1
  menu2d = false
  selecteditem = 1
end
function print3d()
	sleep(0.1)
x = 0
if tip then
  files = job.readLine()
  job.close()
  for k = 1,tonumber(files) do
   job = fs.open(timp.."_"..k,"r")
   printer()
   if #curline %2 == 0 then
	turtle.turnLeft()
	for h = 1,#curline do
	 forward()
	end
	turtle.turnRight()
	turtle.up()
   else
	turtle.turnRight()
	for h = 1,#curline do
	 forward()
	 end
	turtle.turnLeft()
	for h = 1,#curline-1 do
	 forward()
	end
	turtle.turnLeft()
	turtle.turnLeft()
	turtle.up()
   end
   job.close()
   x = 0
   tip = nil
  end
else
  print("No file Entered")
  sleep(1)
end
end
function print2d()
x = 0
if tipe then
  printer()
  tipe = nil
else
  print("No file entered")
  sleep(1)
end
end
function enter3d()
print("Enter file prefix")
timp = read()
if fs.exists(timp) then
  job = fs.open(timp,"r")
  tip = job.readLine()
  if tip == "3d" then
   -- over with
  else
   print("Not a 3d file")
   sleep(1)
  end
else
  print("invalid file")
  tip = nil
  sleep(1)
end
end
function enter2d()
print("Enter filename")
local temp = read()
if fs.exists(temp) then
  job = fs.open(temp,"r")
  tipe = job.readLine()
  if tipe == "2d" then
	--another comment to do nothing
  else
   print("Not a 2d file")
   sleep(1)
  end
else
  print("invalid file")
  tipe = nil
  sleep(1)
end
end
menu = {
[1] = {text = "2D",handler = d2},
[2] = {text = "3D",handler = d3},
[3] = {text = "Exit",handler = exit}
}
menu2 = {
[1] = {text = "Enter filename",handler = enter2d},
[2] = {text = "Print",handler = print2d},
[3] = {text = "Plane y",handler = face},
[4] = {text = "Main menu",handler = exit2d}
}
menu3 = {
[1] = {text = "Enter filename",handler = enter3d},
[2] = {text = "Print",handler = print3d},
[3] = {text = "Main menu",handler = exit3d}
}
--printmenu
function printmenu(menu)
  for i = 1,#menu do
	if i == selecteditem then
	  print("[[ "..menu[i].text.." ]]")
	else
	  print("   "..menu[i].text.."   ")
	end
  end
end
--handlers
function onkeypress(key,menu)
  if key == keys.enter then
	onitemselected(menu)
  elseif key == keys.up then
	if selecteditem &amp;amp;gt; 1 then
	  selecteditem = selecteditem - 1
	end
  elseif key == keys.down then
	if selecteditem &amp;amp;lt; #menu then
	  selecteditem = selecteditem + 1
	end
  end
end
function onitemselected(menu)
  menu[selecteditem].handler()
end
--main
function main()
  while main do
	term.clear()
	term.setCursorPos(1,1)
	printmenu(menu)
	event,key = os.pullEvent()
	onkeypress(key,menu)
  end
end
main()

Next is the demo print files

Spoiler3D computer (yes you need all the files)
Spoilername comp

3d
16
name comp_1

16
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
dddddddddddddddd
name comp_2

16
dggggggggggggggd
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
dggggggggggggggd
name comp_3

16
dggggggggggggggd
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
dgggggggggggddgd
name comp_4

16
dggggggggggggggd
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
dggggggggggggggd
name comp_5

16
dggggggggggggggd
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
dgddddddddddddgd
name comp_6

16
dggggggggggggggd
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
dgddddddddddddgd
name comp_7

16
dggggggggggggggd
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
gssssssssssssssg
dgddddddddddddgd
name comp_8

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGddddddddddddGd
name comp_9

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGddddddddddddGd
name comp_10

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGddddddddddddGd
name comp_11

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGdwddddddddddGd
name comp_12

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGddwdddddddddGd
name comp_13

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGdwddddddddddGd
name comp_14

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGddddddddddddGd
name comp_15

16
dGGGGGGGGGGGGGGd
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
GssssssssssssssG
dGGGGGGGGGGGGGGd
name comp_16

16
dddddddddddddddd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dGGGGGGGGGGGGGGd
dddddddddddddddd

Now for the 2D file
Spoilerjust 1 file this time


2d
16
dddddddddddddddd
dGGGGGGGGGGGGGGd
dGddddddddddddGd
dGdwddddddddddGd
dGddwdddddddddGd
dGdwddddddddddGd
dGddddddddddddGd
dGddddddddddddGd
dGddddddddddddGd
dgddddddddddddgd
dgddddddddddddgd
dgddddddddddddgd
dggggggggggggggd
dgggggggggggddgd
dggggggggggggggd
dddddddddddddddd

How to make a file to print
Spoiler3D:
first you make a file that is the prefix and then put something like this into it ie test

3d
5
3d is the file type and 5 is the number of files(layers) that it will print
Next for 3d you make the files test_1 through test_5 and in them you put sonething like this


3
wdw
dwd
wdw
the 3 tells how many lines there are in the file and the rest is the actual picture which ill tell you how to make later



Next is the 2D files

this one is simple just make a file and put something like this into it


2d
3
dwd
wdw
dwd
the 2d is declairing what type of file it is
the 3 tells how many lines there are in the file
and the rest is the actual pic


How to make the pics

This should be easy to figure out so ill just give a list of the colors and what letters they are represented by

w = white
o = orange
m = magenta
b = lightblue
y = yellow
l = lime
p = pink
G = grey
g = lightgrey
c = cyan
P = purple
B = blue
n = brown
e = green
r = red
d = black
s = space

Now for links

To get the printer program from pastebin go to
http://pastebin.com/7R2rvCEf

to get all the demo files easily get this program and run it
http://pastebin.com/T91JUu4w

EDIT: I just realized that i forgot to say how to load the turtle. lol
- To load the turtle you just grab the colors out of the creative menu and stick them in the same order that they are in in the menu the same goes for NEI or TMI.

Thank you for Viewing my post and a like/upvote is appreciated :D/>


I Borrowed this from my other post here in the turtle section

Maze Generator (gui not in-world)
SpoilerThis genereates a maze and displays it in real time, After it is done generating you have the option of solving it like a game.

here is the code: http://pastebin.com/fVV2N19s
Spoiler

print("generate maze instantly? y/n")
instants = read()
print("play the maze like a game? y/n")
games = read()

if games == "y" then games = true else games = false end
if instants == "y" then instants = true else instants = false end

w,h = term.getSize()
curx = 1
cury = 1
stack = {}
visited = {}
mazex = (h - 1) / 2
mazey = (w - 1) / 2
showstack = true

--non color conversions
textcolors = {
[colors.black] = " ",
[colors.blue] = "X",
[colors.lime] = "@",
[colors.red] = "F"
}

canvas = {}
for xx = 1,w do
canvas[xx] = {}
for yy = 1,h do
canvas[xx][yy] = colors.blue
end
end

--first thing is first draw the maze
term.clear()
function draw()
if term.isColor() then
for i = 1,w do
for j = 1,h do
term.setCursorPos(i,j)
term.setBackgroundColor(canvas[i][j])
write(" ")
end
end
term.setBackgroundColor(colors.black)
else
for i = 1,w do
for j = 1,h do
term.setCursorPos(i,j)
write(textcolors[canvas[i][j]])
end
end
end
end
draw()

function movecell(x,y)

  -- removing wall and  x at cells
  canvas[curx * 2][cury * 2] = colors.black
  canvas[x * 2][y * 2] = colors.black
  if x > curx then canvas[(x * 2) - 1][y * 2] = colors.black end
  if y > cury then canvas[x * 2][(y * 2) - 1] = colors.black end
  if x < curx then canvas[(x * 2) + 1][y * 2] = colors.black end
  if y < cury then canvas[x * 2][(y * 2) + 1] = colors.black end
  canvas[curx * 2][cury * 2] = colors.black
  curx = x
  cury = y
  canvas[curx * 2][cury * 2] = colors.lime
  if not instants then draw() end---------------------------------------------------
end

function checkvisited(y,x)
  if x <= 0 or y <= 0 or x > mazex or y > mazey then return true end
  local v
  for _,v in pairs(visited) do
	if v[1] == y and v[2] == x then
	  return true
	end
  end
  return false
end

function addvisited(x,y)
  table.insert(visited,{x,y})
end

addvisited(curx,cury)

function addstack(x,y)
  table.insert(stack,{x,y})
end

function popstack()
  local val = stack[#stack]
  table.remove(stack,#stack);

  return val[1],val[2]
end

repeat

--find unvisited cells next to current one
  local posiblecells = {}

  if checkvisited(curx-1,cury) == false then
	table.insert(posiblecells,{curx - 1,cury})
  end
  if checkvisited(curx,cury - 1) == false then
	table.insert(posiblecells,{curx,cury - 1})
  end
  if checkvisited(curx + 1,cury) == false then
	table.insert(posiblecells,{curx + 1,cury})
  end
  if checkvisited(curx,cury + 1) == false then
	table.insert(posiblecells,{curx,cury + 1})
  end

  if #posiblecells > 0 then
	addstack(curx,cury)
	local targetx, targety
	local i = math.random(1,#posiblecells)
	targetx = posiblecells[i][1]
	targety = posiblecells[i][2]

	addvisited(targetx,targety)
	movecell(targetx,targety)
  else
	local targetx, targety
	targetx, targety = popstack()
	movecell(targetx,targety)
  end

  --sleep(0.05)
  os.queueEvent("randomevent")
  os.pullEvent()

until #stack == 0

if games then
canvas[w-1][h-1] = colors.red
draw()
running = true
px = 2
py = 2
while running do
changed = false
lpx = px
lpy = py
event,p1 = os.pullEvent("key")
if p1 == 200 then
if canvas[px][py-1] == colors.black or canvas[px][py-1] == colors.red then
py = py - 1
changed = true
end
elseif p1 == 208 then
if canvas[px][py+1] == colors.black or canvas[px][py+1] == colors.red then
py = py + 1
changed = true
end
elseif p1 == 203 then
if canvas[px-1][py] == colors.black or canvas[px-1][py] == colors.red then
px = px - 1
changed = true
end
elseif p1 == 205 then
if canvas[px+1][py] == colors.black or canvas[px+1][py] == colors.red then
px = px + 1
changed = true
end
elseif p1 == 16 then
running = false
end
if px == w-1 and py == h - 1 then
running = false
end
if changed then
canvas[px][py] = colors.lime
canvas[lpx][lpy] = colors.black
draw()
end
end
else
draw()
os.pullEvent()
end

and some pics:
Spoiler

CC Tar
Spoilerthis program allows you to pack and unpack real binary tar files with computercraft

I have built in an automatic updater so if some bug cimes up I should be able to fix it and everyone will get the new version automatically.

As of now It requires http to pack up files but I can change that to just give a warning if you guys want.

*WARNING* This program makes and reads BINARY FILES so you CAN'T get them through the http api with normal methods (like http.get("http://www.mysite.com/test.tar") because of the way luaj handles strings!!! so you have to make a custom downloader (in a completely new way) or drag and drop the files in the computer's save folder. I'm not sure what will happen if you read a file download that way so don't blame me if something happens
-if you guys want I can also explain how I get around this limitation but it isn't easy-


To use you launch the program as so
tar c [directory] [output file] or tar u [input file]

aka

tar c dir dirtest.tar
or
tar u dirtest.tar


This program uses absolute paths so just remember that when you try to use it.

These tar files are REAL so they can be opened with programs like 7zip, winrar, GNU tar, and others etc…
this format is not compressed at all so sometimes It has problems with large files but Ive tried to fix them, If you have and legit solutions (aka. look at the code first before saying anything) you can tell me and I can fix it.

here is the pastebin
pastebin.com/bcgmNT2Q
or
pastebin get bcgmNT2Q tar
Edited on 22 August 2014 - 03:52 AM
Beastly #2
Posted 19 June 2013 - 07:37 PM
Doesn't NPaint adapt to resized / larger monitors. So by making your PC bigger in CCEmu it would make the veiwer bigger
columna1 #3
Posted 19 June 2013 - 07:52 PM
Doesn't NPaint adapt to resized / larger monitors. So by making your PC bigger in CCEmu it would make the veiwer bigger
it does but it ends up being realy realy realy slow
Shazz #4
Posted 19 June 2013 - 08:58 PM
Awesome programs, especially the first one!
columna1 #5
Posted 20 June 2013 - 12:07 AM
Awesome programs, especially the first one!
Thank you! :D/>
theoriginalbit #6
Posted 20 June 2013 - 12:18 AM
I agree, very nice looking programs, especially the multiple monitor drawing program. A few areas the code could be improved, but compared to what most people would produce as a solution for it, it is very small, with a great result… well done :)/>
jesusthekiller #7
Posted 20 June 2013 - 02:06 AM
In maze:

  if checkvisited(curx-1,cury) == false then
	    table.insert(posiblecells,{curx - 1,cury})
  end

Why not

  if not checkvisited(curx-1,cury) then
	    table.insert(posiblecells,{curx - 1,cury})
  end
columna1 #8
Posted 20 June 2013 - 02:33 PM
In maze:

  if checkvisited(curx-1,cury) == false then
		table.insert(posiblecells,{curx - 1,cury})
  end

Why not

  if not checkvisited(curx-1,cury) then
		table.insert(posiblecells,{curx - 1,cury})
  end

in my programs i have had problems getting 'not' to work the way I want so I just use if var == false instead so that I dont run into any problems either way
unobtanium #9
Posted 20 June 2013 - 02:37 PM
I am having problems comparing string with "not".
Sometimes it works sometime it doesnt, dont know why.
But i never had problems with boolean values.
svdragster #10
Posted 20 June 2013 - 02:40 PM
These are really great!
jesusthekiller #11
Posted 20 June 2013 - 02:44 PM

local a = ""

if not a then
  print("false")
end

> false

This might be your error :)/>
columna1 #12
Posted 20 June 2013 - 03:58 PM

local a = ""

if not a then
  print("false")
end

> false

This might be your error :)/>

Thank you ill be sure to note that as it does sound familiar
theoriginalbit #13
Posted 20 June 2013 - 11:29 PM
I am having problems comparing string with "not".
Sometimes it works sometime it doesnt, dont know why.
But i never had problems with boolean values.

local a = ""

if not a then
  print("false")
end

> false

This might be your error :)/>
Ummmm… That wouldn't print… Only nil resolves to false, and "" is not nil.

This is your problem…

local t = "test"
if not t == "test" then
not t resolves to false (a value is true, not true is false), and false is not equal to "test". So when comparing strings you need to do one of two things:
#1 evaluate the conditional and then not it.

if not (t == "test") then
#2 use not equal.

if t ~= "test" then
jesusthekiller #14
Posted 21 June 2013 - 01:19 AM
I'm 99% sure that empty string, 0, nil and false will wok as false… Can you check? I'm on tablet.
theoriginalbit #15
Posted 21 June 2013 - 01:24 AM
I'm 99% sure that empty string, 0, nil and false will wok as false… Can you check? I'm on tablet.
I don't really need to check, I know that only nil and false resolve to false, but an image will be better proof, so I'll make one… http://puu.sh/3kEex.png
jesusthekiller #16
Posted 21 June 2013 - 03:37 AM
Oh? Hmm… I was sure it works :-P




Oh yeah, it would be false in PHP…
unobtanium #17
Posted 21 June 2013 - 07:02 AM
Thank you once again, theoriginalbit :P/>
That makes sense to me now ^^
TheOddByte #18
Posted 21 June 2013 - 03:00 PM
These programs is really great! :D/>
But I have an suggestion though..
When the maze is fully generated you should make so that it goes to a starting point and then you should make it so you actually can play and try to get out of the maze.
columna1 #19
Posted 21 June 2013 - 08:55 PM
These programs is really great! :D/>
But I have an suggestion though..
When the maze is fully generated you should make so that it goes to a starting point and then you should make it so you actually can play and try to get out of the maze.

Thanks and I have had that suggested many times to me by my friends that i have showed this to. When I wrote it I was being totally stupid on how I did it, In order to make that happen I would have to re-write most of it but… that sounds fun to me right now so i guess ill try. Hopefuly I can finish it before I go away to camp for a week.

—————————————————————————————————————————————————————————

ok I re-wrote it to be a maze game, I also added an option to make it instant or watch as the maze generates
jesusthekiller #20
Posted 22 June 2013 - 04:09 AM
There is always Maze or Maze 3D if you want to play it :P/>
TheOddByte #21
Posted 22 June 2013 - 08:30 AM
There is always Maze or Maze 3D if you want to play it :P/>/>
Yeah I know, Those are amazing as well! :)/>
Zudo #22
Posted 22 June 2013 - 09:02 AM
I like the first one a lot!
jesusthekiller #23
Posted 22 June 2013 - 01:13 PM
Thanks! :D/>