Posted 08 February 2014 - 11:40 AM
I decided to make a printing program that uses a computer to design the layout then uses a turtle and wool blocks to print it out.
How to use:
Turtle Program:
If you have any problems please post bellow
Pastebin:
Computer Client: KpckFXu2
Turtle Program: 5VDBTACX
How to use:
- put the printer program on a computer and the start up program on a turtle.
- change the id to send to on the computer and the id to receive from on the turtle
- place the wool in the order it appears in the creative inventory (which is the same as the order the colors appear here. http://computercraft.info/wiki/Colors)
- run the programs on the computer and turtle respectively
- have fun printing
Spoiler
Computer Program:Spoiler
term.clear()
rednet.open("top")
selection = 1
pic = {}
function ext()
print("Enter file name:")
name = read()
f = fs.open(name,"w")
f.write(textutils.serialize(pic))
f.close()
end
function load()
print("Please enter file name:")
name = read()
f = fs.open(name,"r")
pic = textutils.unserialize(f.readAll())
f.close()
end
function new()
for i=1,100 do
pic[i] = 1
end
end
function init()
for i=11,21 do
term.setCursorPos(i,4)
print("@")
end
for i=4,15 do
term.setCursorPos(21,i)
print("@")
end
for i=11,21 do
term.setCursorPos(i,15)
print("@")
end
for i=4,15 do
term.setCursorPos(10,i)
print("@")
end
term.setCursorPos(8,1)
print("|")
term.setCursorPos(13,1)
print("|")
select()
draw()
paintutils.drawPixel(2,1,2)
term.setCursorPos(2,1)
print("Print!")
paintutils.drawPixel(9,1,colors.red)
term.setCursorPos(9,1)
print("Exit")
paintutils.drawPixel(14,1,colors.blue)
term.setCursorPos(14,1)
print("load")
end
function select()
paintutils.drawPixel(30,1,selection)
end
function send()
id = 9
rednet.send(id,textutils.serialize(pic))
end
function draw()
pic_ = 1
for i=5,14 do
for a=1,10 do
paintutils.drawPixel(a+10,i,pic[pic_])
pic_ = pic_+1
end
end
end
new()
init()
while true do
event,arg1,arg2,arg3 = os.pullEvent()
paintutils.drawPixel(1,1,colors.black)
if event == "mouse_click" then
if arg1 == 1 and arg2<=20 and arg2>10 and arg3>=5 and arg3<15 then
paintutils.drawPixel(arg2,arg3,selection)
num = arg2+arg3
if arg3 == 5 then
pic[num-15]=selection
elseif arg3 == 6 then
pic[num-6] = selection
elseif arg3 == 7 then
pic[num-(-3)] = selection
elseif arg3 == 8 then
pic[num-(-12)] = selection
elseif arg3 == 9 then
pic[num-(-21)] = selection
elseif arg3 == 10 then
pic[num-(-30)] = selection
end
elseif arg1 == 1 and arg2>=9 and arg2<=12 and arg3==1 then
term.clear()
ext()
break
elseif arg1 == 1 and arg2>=14 and arg2<=18 and arg3 == 1 then
load()
term.clear()
init()
elseif arg1==1 and arg2>=2 and arg2<=7 and arg3 == 1 then
send()
end
elseif event == "mouse_scroll" then
if selection >= 32768 then
selection = 0.5
end
selection = selection*2
select()
end
paintutils.drawPixel(1,1,32768)
end
Spoiler
rednet.open("right")
pic = {}
colors = {}
colors[1]=1
colors[2]=2
colors[4]=2
colors[8]=4
colors[16]=5
colors[32]=6
colors[64]=7
colors[128]=8
colors[256]=9
colors[512]=10
colors[1024]=11
colors[2048]=12
colors[4096]=13
colors[8192]=14
colors[16384]=15
colors[32768]=16
while true do
id, msg = rednet.receive()
if id == 8 then
pic = textutils.unserialize(msg)
for i=1,5 do
turtle.forward()
end
turtle.up()
pic_ = 1
for i=1,10 do
for a=1,10 do
turtle.digDown()
turtle.select(colors[pic[pic_]])
turtle.placeDown()
pic_ = pic_+1
turtle.forward()
end
turtle.turnRight()
turtle.turnRight()
for b=1,11 do
turtle.forward()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.forward()
end
turtle.down()
print("Print Done now i have "..tostring(turtle.getFuelLevel()).." remaning fuel")
end
end
If you have any problems please post bellow
Pastebin:
Computer Client: KpckFXu2
Turtle Program: 5VDBTACX
Edited on 08 February 2014 - 11:16 AM