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

notepad/computercraft printer program help!

Started by cmurtheepic, 20 November 2012 - 06:03 AM
cmurtheepic #1
Posted 20 November 2012 - 07:03 AM
i was trying to make a printing document type program and i cant figure out what i did wrong
oh and i made comments in the program that should help you to try to figure it out. p.s. thank you for helping if you did
[attachment=680:notepad (minecraft version).txt]
or read this

—————————————————————————————————————————————————————————————————————–


write "Welcome to Notepad"
sleep(1)
term.setCursorPos(1,1)
term.clearLine()
–this is getting rid of that line that we no longer need
sleep(1)
–this is getting the user typeing
write "you may start typing. when you are done please push 'end' to print"
function notepad()
x = io.read()
–now this is going to get the users keyboard button press p.s. i wanted it to be the end key
if event == "char" and param1 == "end" then
sleep(1)
print "which side is your printer on"
c = io.read()
local printer=perhipheral.wrap©
end
–print start
– this is to see if the printer is out of ink or paper
if printer.getInkLevel()==0 then
write "No Ink! Add Some More To Print"
while printer.getInkLevel()==o do
os.sleep(.5)
end
if printer.getPaperLevel()==0 then
write "No Paper! add some more please"
while printer.getPaperLevel()==0 do
os.sleep(.5)
end
–print end
– this is where the printer starts the print
–print start
printer.newPage()
sleep(1)
m = io.read()
if m == "yes" then
title()
printer.write(x)
printer.setCursorPos(1,2)
local w, h=printer.getPageSize()
printer.setCursorPos(1,h)


local str="Vertical"
for i=1,#str do
printer.setCursorPos(w.i
printer.write(string.sub(str,i,i))
elseif m == "no" then
notepad()
end
–print end
– this asks if the user wants to add a title
write "would you like to add a title to show in inventory"
i = io.read()
if i == "yes" then
write "what should it be"
o = io.read()
funcion title()
printer.setPageTitle(o)
end
elseif i == "no" then
printer.endPage()
end
sleep(1)
write "your document is finished"
term.clear()
–parts of the code where the comment "print"
–was a part of the printer tutorial made by"GopherAtl"
(ORINGINAL)
———————————————————————————————————————————————————————————————–
this it fixed mostly (NEWEST)
———————————————————————————————————————————————————————————————–

write "Welcome to Notepad"
sleep(1)
term.setCursorPos(1,1)
term.clear()
--this is getting rid of that line that we no
longer need
sleep(1)
--this is getting the user typeing
write "you may start typing. when you are done please
push 'end' to print"
term.setCursorPos(1,3)
write "keys: [
[ ] to finish, [=] to move down a line"
term.setCursorPos
(1,4)
print
"---------------------------------------------------"
term.setCursorPos(1,6)
function notepad()
end
function note
()
local e, t=term.getCursorPos()
k=1,#str
term.setCUrsorPos(1,t)
local str="Vertical"
u=1,#str
term.setCursorPos(k,u + k)
end	 
x = io.read()
--now
this is going to get the users keyboard button press p.s.
i wanted it to be the end key
event, param1, param2 =
os.pullEvent()
if event == "char" and param2 == "=" then
  
    note()	  
end
if event == "char" and param1 == "["
then
sleep(1)
find()
print "which side is your printer on"
c
= io.read()
local printer=perhipheral.wrap(c)
sleep(.2)
  
if printer==nil then
   term.setTextColor(colors.red)
  
print "No Printer Detected! please try again"
  
term.setTestColor(colors.white)
   function find()
   end
  
elseif printer==true then
	   print "printer found!"
  
end
end
--print start
-- this is to see if the printer is
out of ink or paper
local printer

if printer.getInkLevel()
== "0" then
   write "No Ink! Add Some More To Print"
  
  
   while printer.getInkLevel() == "0" do
		
os.sleep(.5)
   end
end
if printer.getPaperLevel() == "0"
then
   write "No Paper! add some more please"
  
  
  
while printer.getPaperLevel() == "0" do
		 os.sleep
(.5)
   end
end
--print end
-- this is where the printer
starts the print
--print start
printer.newPage()
sleep(1)
write "would you like to print?"
m = io.read()
if m ==
"yes" then
title()
printer.write(x)
printer.setCursorPos
(1,2)
local w, h=printer.getPageSize()
printer.setCursorPos(1,h)

local str="Vertical"
for i=1,#str
do
	 printer.setCursorPos(w.i)
	 printer.write
(string.sub(str,i,i))
end	
	   elseif m == "no" then
    notepad()
end
--print end
-- this asks if the user wants
to add a title
write "would you like to add a title to
show in inventory"
i = io.read()
if i == "yes" then
   write
"what should it be"
   o = io.read()
   funcion = title()
  
printer.setPageTitle(o)
   elseif i == "no" then
	   
printer.endPage()
end
sleep(1)
write "your document is
finished"
term.clear()
--parts of the code where the
comment "print"
--was a part of the printer tutorial made
by"GopherAtl"
———————————————————————————————————————————————————————————————–
i fixed most of my code by myself but on the part where you are typing i can't figure out how to make it where the cursor will go down a line when you push enter.
when i pushed enter it said "notepad:24: attempt to index ? (a nil value)
but i cant figure out how to tell it to go down a line. please help me!!!OH and i would like the next line key to be ENTER, and the finich key to be the END key. thankyou
Doyle3694 #2
Posted 20 November 2012 - 07:07 AM
post the code in
 tags so that we can read it. nobody will go though the pain of downloading a document, nor trust a random document
billysback #3
Posted 20 November 2012 - 07:10 AM
Code:

write "Welcome to Notepad"
sleep(1)
term.setCursorPos(1,1)
term.clearLine()
--this is getting rid of that line that we no longer need
sleep(1)
--this is getting the user typeing
write "you may start typing. when you are done please push 'end' to print"
function notepad()
x = io.read()
--now this is going to get the users keyboard button press p.s. i wanted it to be the end key
if event == "char" and param1 == "end" then
sleep(1)
print "which side is your printer on"
c = io.read()
local printer=perhipheral.wrap(c)
end
--print start
-- this is to see if the printer is out of ink or paper
if printer.getInkLevel()==0 then
   write "No Ink! Add Some More To Print"
   while printer.getInkLevel()==o do
		 os.sleep(.5)
end
if printer.getPaperLevel()==0 then
   write "No Paper! add some more please"
   while printer.getPaperLevel()==0 do
		 os.sleep(.5)
end
--print end
-- this is where the printer starts the print
--print start
printer.newPage()
sleep(1)
m = io.read()
if m == "yes" then
title()
printer.write(x)
printer.setCursorPos(1,2)
local w, h=printer.getPageSize()
printer.setCursorPos(1,h)


local str="Vertical"
for i=1,#str do
   printer.setCursorPos(w.i
   printer.write(string.sub(str,i,i))
elseif m == "no" then
notepad()
end
--print end
-- this asks if the user wants to add a title
write "would you like to add a title to show in inventory"
i = io.read()
if i == "yes" then
write "what should it be"
o = io.read()
funcion title()
printer.setPageTitle(o)
end
elseif i == "no" then
printer.endPage()
end
sleep(1)
write "your document is finished"
term.clear()
--parts of the code where the comment "print"
--was a part of the printer tutorial made by"GopherAtl"
 
cmurtheepic #4
Posted 20 November 2012 - 08:26 AM
i was trying to make a printing document type program and i cant figure out what i did wrong
oh and i made comments in the program that should help you to try to figure it out. p.s. thank you for helping if you did
[attachment=680:notepad (minecraft version).txt]
or read this

—————————————————————————————————————————————————————————————————————–


write "Welcome to Notepad"
sleep(1)
term.setCursorPos(1,1)
term.clearLine()
–this is getting rid of that line that we no longer need
sleep(1)
–this is getting the user typeing
write "you may start typing. when you are done please push 'end' to print"
function notepad()
x = io.read()
–now this is going to get the users keyboard button press p.s. i wanted it to be the end key
if event == "char" and param1 == "end" then
sleep(1)
print "which side is your printer on"
c = io.read()
local printer=perhipheral.wrap©
end
–print start
– this is to see if the printer is out of ink or paper
if printer.getInkLevel()==0 then
write "No Ink! Add Some More To Print"
while printer.getInkLevel()==o do
os.sleep(.5)
end
if printer.getPaperLevel()==0 then
write "No Paper! add some more please"
while printer.getPaperLevel()==0 do
os.sleep(.5)
end
–print end
– this is where the printer starts the print
–print start
printer.newPage()
sleep(1)
m = io.read()
if m == "yes" then
title()
printer.write(x)
printer.setCursorPos(1,2)
local w, h=printer.getPageSize()
printer.setCursorPos(1,h)


local str="Vertical"
for i=1,#str do
printer.setCursorPos(w.i
printer.write(string.sub(str,i,i))
elseif m == "no" then
notepad()
end
–print end
– this asks if the user wants to add a title
write "would you like to add a title to show in inventory"
i = io.read()
if i == "yes" then
write "what should it be"
o = io.read()
funcion title()
printer.setPageTitle(o)
end
elseif i == "no" then
printer.endPage()
end
sleep(1)
write "your document is finished"
term.clear()
–parts of the code where the comment "print"
–was a part of the printer tutorial made by"GopherAtl"

————————————————————————————————————————————————————————————————————–
i fixed most of my code by myself but on the part where you are typing i can't figure out how to make it where the cursor will go down a line when you push enter.
when i pushed enter it said "notepad:24: attempt to index ? (a nil value)
but i cant figure out how to tell it to go down a line. please help me!!!
cmurtheepic #5
Posted 20 November 2012 - 10:55 AM
i was trying to make a printing document type program and i cant figure out what i did wrong
oh and i made comments in the program that should help you to try to figure it out. p.s. thank you for helping if you did
[attachment=680:notepad (minecraft version).txt]
or read this

—————————————————————————————————————————————————————————————————————–


write "Welcome to Notepad"
sleep(1)
term.setCursorPos(1,1)
term.clearLine()
–this is getting rid of that line that we no longer need
sleep(1)
–this is getting the user typeing
write "you may start typing. when you are done please push 'end' to print"
function notepad()
x = io.read()
–now this is going to get the users keyboard button press p.s. i wanted it to be the end key
if event == "char" and param1 == "end" then
sleep(1)
print "which side is your printer on"
c = io.read()
local printer=perhipheral.wrap©
end
–print start
– this is to see if the printer is out of ink or paper
if printer.getInkLevel()==0 then
write "No Ink! Add Some More To Print"
while printer.getInkLevel()==o do
os.sleep(.5)
end
if printer.getPaperLevel()==0 then
write "No Paper! add some more please"
while printer.getPaperLevel()==0 do
os.sleep(.5)
end
–print end
– this is where the printer starts the print
–print start
printer.newPage()
sleep(1)
m = io.read()
if m == "yes" then
title()
printer.write(x)
printer.setCursorPos(1,2)
local w, h=printer.getPageSize()
printer.setCursorPos(1,h)


local str="Vertical"
for i=1,#str do
printer.setCursorPos(w.i
printer.write(string.sub(str,i,i))
elseif m == "no" then
notepad()
end
–print end
– this asks if the user wants to add a title
write "would you like to add a title to show in inventory"
i = io.read()
if i == "yes" then
write "what should it be"
o = io.read()
funcion title()
printer.setPageTitle(o)
end
elseif i == "no" then
printer.endPage()
end
sleep(1)
write "your document is finished"
term.clear()
–parts of the code where the comment "print"
–was a part of the printer tutorial made by"GopherAtl"
(ORINGINAL)
———————————————————————————————————————————————————————————————–
this it fixed mostly (NEWEST)
———————————————————————————————————————————————————————————————–

write "Welcome to Notepad"
sleep(1)
term.setCursorPos(1,1)
term.clear()
--this is getting rid of that line that we no
longer need
sleep(1)
--this is getting the user typeing
write "you may start typing. when you are done please
push 'end' to print"
term.setCursorPos(1,3)
write "keys: [
[ ] to finish, [=] to move down a line"
term.setCursorPos
(1,4)
print
"---------------------------------------------------"
term.setCursorPos(1,6)
function notepad()
end
function note
()
local e, t=term.getCursorPos()
k=1,#str
term.setCUrsorPos(1,t)
local str="Vertical"
u=1,#str
term.setCursorPos(k,u + k)
end	
x = io.read()
--now
this is going to get the users keyboard button press p.s.
i wanted it to be the end key
event, param1, param2 =
os.pullEvent()
if event == "char" and param2 == "=" then
  
	note()	  
end
if event == "char" and param1 == "["
then
sleep(1)
find()
print "which side is your printer on"
c
= io.read()
local printer=perhipheral.wrap(c)
sleep(.2)
  
if printer==nil then
   term.setTextColor(colors.red)
  
print "No Printer Detected! please try again"
  
term.setTestColor(colors.white)
   function find()
   end
  
elseif printer==true then
	   print "printer found!"
  
end
end
--print start
-- this is to see if the printer is
out of ink or paper
local printer

if printer.getInkLevel()
== "0" then
   write "No Ink! Add Some More To Print"
  
  
   while printer.getInkLevel() == "0" do
		
os.sleep(.5)
   end
end
if printer.getPaperLevel() == "0"
then
   write "No Paper! add some more please"
  
  
  
while printer.getPaperLevel() == "0" do
		 os.sleep
(.5)
   end
end
--print end
-- this is where the printer
starts the print
--print start
printer.newPage()
sleep(1)
write "would you like to print?"
m = io.read()
if m ==
"yes" then
title()
printer.write(x)
printer.setCursorPos
(1,2)
local w, h=printer.getPageSize()
printer.setCursorPos(1,h)

local str="Vertical"
for i=1,#str
do
	 printer.setCursorPos(w.i)
	 printer.write
(string.sub(str,i,i))
end	
	   elseif m == "no" then
	notepad()
end
--print end
-- this asks if the user wants
to add a title
write "would you like to add a title to
show in inventory"
i = io.read()
if i == "yes" then
   write
"what should it be"
   o = io.read()
   funcion = title()
  
printer.setPageTitle(o)
   elseif i == "no" then
	  
printer.endPage()
end
sleep(1)
write "your document is
finished"
term.clear()
--parts of the code where the
comment "print"
--was a part of the printer tutorial made
by"GopherAtl"
———————————————————————————————————————————————————————————————–
i fixed most of my code by myself but on the part where you are typing i can't figure out how to make it where the cursor will go down a line when you push enter.
when i pushed enter it said "notepad:24: attempt to index ? (a nil value)
but i cant figure out how to tell it to go down a line. please help me!!!OH and i would like the next line key to be ENTER, and the finich key to be the END key. thankyou[attachment=685:notepad (minecraft version) (updated).txt]
anonimo182 #6
Posted 20 November 2012 - 11:03 AM
You misspelled term.setCursorPos in line 24: term.setCUrsorPos

Also term.setTextColor by term.setTestColor
anonimo182 #7
Posted 20 November 2012 - 11:06 AM
I just saw this post a moment ago… and solve some things
Doyle3694 #8
Posted 20 November 2012 - 11:14 AM
dont repost your threads, keep it to one thread.
cmurtheepic #9
Posted 20 November 2012 - 11:51 AM
sorry i thought the title would be miss leading to the windows program Notepad :(/>/>
oh and i changed a ot of things since then
anonimo182 #10
Posted 20 November 2012 - 11:57 AM
still, some errors…. term.setCursorPos instead of term.setCUrsorPos and term.setTextColor instead of term.setTestColor
cmurtheepic #11
Posted 20 November 2012 - 12:11 PM
i keep getting a attempt to index ( a nil value) on line 56 please help me out
anonimo182 #12
Posted 20 November 2012 - 12:13 PM
Now to count to line 56…

term.setTestColor(colors.white) = term.setTextColor(colors.white)
cmurtheepic #13
Posted 20 November 2012 - 12:26 PM
no it is the line where it is getting the ink level
Orwell #14
Posted 20 November 2012 - 12:32 PM
Every line for ink and paper level are comparing against string, change this:

printer.getInkLevel() == "0"
to this:

printer.getInkLevel() == 0
and:


printer.getPaperLevel() == "0"
to this:

printer.getPaperLevel() == 0
everywhere
cmurtheepic #15
Posted 20 November 2012 - 01:04 PM
for some reason when ever i hit enter once it f=stops the shell but when i hit enter again it says on the get ink/paper level it says attempt to Index ? (a nil value)
i have no peripherals installed but i am using the current version of computercraft.
cmurtheepic #16
Posted 20 November 2012 - 01:12 PM
oh and none of the assigned key are working either please i really wnat to get this working :(/>/>
Lyqyd #17
Posted 20 November 2012 - 02:50 PM
Topics merged. Previous posts may be in a confusing order.
cmurtheepic #18
Posted 20 November 2012 - 05:14 PM
i still havent been able to get it working