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

document program help!

Started by cmurtheepic, 21 November 2012 - 12:28 PM
cmurtheepic #1
Posted 21 November 2012 - 01:28 PM
i know i posted this before. or similar but the reason i posted this again is becuase i am desperate i cant figure out how to get this to work. and their was no more help on my other topic. SOMEBODY PLEASE HELP ME!!!!!!!!!!!!!!!!
;(

here is a download: [attachment=689:notepad.txt]

and this is what is contained in side it:


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(.5)
--this is getting the user typeing
write "you may start typing. when you are done please push 'end' to print"
function notepad()
end
term.setCursorPos(1,3)
write "keys: [end] to finish, [enter] to move down a line, [ctrl+c] this opens the color choosing menu."
term.setCursorPos(1,4)
print "---------------------------------------------------"
term.setCursorPos(1,6)
function hows()
x = io.read()
button()
end

--this is getting the key pressing input
while true do
function button()
hows()
event, param1, param2 = os.pullEvent()
event, param3 = os.pullEvent()
if event == "char" and param1 == "[" then
function 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!"
   term.setTextColor(colors.white)
   write "would you like to search automatically for the printer?"
   j = io.read()
   if j == "yes" then
   for _,side in pairs(redstone.getSides()) do
	   if perhipheral.getType(side)=="printer" then
			  printer=peripheral.wrap(side)
			  break
   elseif j == "no" then
   find()
   elseif printer==true then
	   print "printer found!"
	   sleep(2)
	break
end
	printered()
   end
	   end
end
end
end
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()
button()
--this allows the person to change the text's color
if event == "char" and param2 == "enter" then
	   note()
   end
end
	if event == "key" and param3 == "ctrl+c" then
	term.clear()
	term.setBackgroundColor(colors.white)
	   function fuds()
	write "what color text do you want? WARNING! this will"
	term.setCursorPos(1,2)
	write "ownly show up as a document in diffrent colors."
	term.setCursorPos(1,3)
	write "it will not print in diffrent colors!"
	term.setCursorPos(1,4)
	print "---------------------------------------------------"
	term.setCursorPos(1,5)
	write "sorry but black won't work here sorry!"
	term.setCursorPos(1,6)
	print "---------------------------------------------------"
	term.setCursorPos(1,8)
	term.setTextColor(colors.gray)
	write "white"
	term.setCursorPos(1,9)
	term.setTextColor(colors.red)
	write "red"
	term.setCursorPos(1,10)
	term.setTextColor(colors.blue)
	write "blue"
	term.setCursorPos(1,11)
	term.setTextColor(colors.green)
	write "green"
	term.setCursorPos(1,12)
	term.setTextColor(colors.orange)
	write "orange"
	term.setCursorPos(1,13)
	term.setTextColor(colors.pink)
	write "pink"
	term.setCursorPos(1,14)
	term.setTextColor(colors.purple)
	write "purple"
	term.setCursorPos(1,15)
	term.setTextColor(colors.gray)
	write "gray"
	term.setCursorPos(1,17)
	print (">")
	z = io.read()
	if z == "white" then
	term.setTextColor(colors.white)
	hows()
	   elseif z == "red" then
	term.setTextColor(colors.red)
	hows()
	   elseif z == "blue" then
	term.setTextColor(colors.blue)
	hows()
	   elseif z == "green" then
	   term.setTextColor(colors.green)
	   hows()
		  elseif z == "orange" then
	   term.setTextColor(colors.orange)
	   hows()
	  elseif z == "pink" then
	  term.setTextColor(colors.pink)
	  hows()
		 elseif z == "purple" then
		 term.setTextColor(colors.purple)
		 hows()
			elseif z == "gray" then
		 term.setTextColor(colors.gray)
		 hows()
			else
			 term.clear()
		  sleep(.5)
			 term.setTextColor(colors.red)
		  term.setCursorPos(1,2)
			 print "invlaid answer!"
		  term.setCursorPos(1,3)
		  print "---------------------------------------------------"
		  term.setCursorPos(1,4)
		  print "please try again!"
		  term.setCursorPos(1,5)
		  print "---------------------------------------------------"
		  sleep(4)
		  term.clear()
		  term.setTextColor(colors.white)
		  fuds()
	  end
   end
end

--print start
-- this is to see if the printer is out of ink or paper
local printer
if printer.getInkLeve() == 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 where the printer starts to print
--print start
function printered()
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
   end
sleep(1)
write "your document is finished"
term.clear()
sleep(.5)
write "would you like to do another document"
b = io.read()
if b == "yes" then
notepad()
elseif b == "no" then
term.clear()
end
--parts of the code where the comment "print"
--was a part of the printer tutorial made by"GopherAtl"
anonimo182 #2
Posted 21 November 2012 - 01:41 PM
Where is the error?
cmurtheepic #3
Posted 21 November 2012 - 01:42 PM
i know i posted this before. or similar but the reason i posted this again is becuase i am desperate i cant figure out how to get this to work. and their was no more help on my other topic. SOMEBODY PLEASE HELP ME!!!!!!!!!!!!!!!!
;(

here is a download: [attachment=691:notepad.txt]

and this is what is contained in side it:


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(.5)
--this is getting the user typeing
write "you may start typing. when you are done please push 'end' to print"
function notepad()
end
term.setCursorPos(1,3)
write "keys: [end] to finish, [enter] to move down a line, [ctrl+c] this opens the color choosing menu."
term.setCursorPos(1,4)
print "---------------------------------------------------"
term.setCursorPos(1,6)
function hows()
x = io.read()
button()
end

--this is getting the key pressing input
while true do
function button()
hows()
event, param1, param2 = os.pullEvent()
event, param3 = os.pullEvent()
if event == "char" and param1 == "[" then
function 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!"
   term.setTextColor(colors.white)
   write "would you like to search automatically for the printer?"
   j = io.read()
   if j == "yes" then
   for _,side in pairs(redstone.getSides()) do
	   if perhipheral.getType(side)=="printer" then
			  printer=peripheral.wrap(side)
			  break
   elseif j == "no" then
   find()
   elseif printer==true then
	   print "printer found!"
	   sleep(2)
	break
end
	printered()
   end
	   end
end
end
end
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()
button()
--this allows the person to change the text's color
if event == "char" and param2 == "enter" then
	   note()
   end
end
	if event == "key" and param3 == "ctrl+c" then
	term.clear()
	term.setBackgroundColor(colors.white)
	   function fuds()
	write "what color text do you want? WARNING! this will"
	term.setCursorPos(1,2)
	write "ownly show up as a document in diffrent colors."
	term.setCursorPos(1,3)
	write "it will not print in diffrent colors!"
	term.setCursorPos(1,4)
	print "---------------------------------------------------"
	term.setCursorPos(1,5)
	write "sorry but black won't work here sorry!"
	term.setCursorPos(1,6)
	print "---------------------------------------------------"
	term.setCursorPos(1,8)
	term.setTextColor(colors.gray)
	write "white"
	term.setCursorPos(1,9)
	term.setTextColor(colors.red)
	write "red"
	term.setCursorPos(1,10)
	term.setTextColor(colors.blue)
	write "blue"
	term.setCursorPos(1,11)
	term.setTextColor(colors.green)
	write "green"
	term.setCursorPos(1,12)
	term.setTextColor(colors.orange)
	write "orange"
	term.setCursorPos(1,13)
	term.setTextColor(colors.pink)
	write "pink"
	term.setCursorPos(1,14)
	term.setTextColor(colors.purple)
	write "purple"
	term.setCursorPos(1,15)
	term.setTextColor(colors.gray)
	write "gray"
	term.setCursorPos(1,17)
	print (">")
	z = io.read()
	if z == "white" then
	term.setTextColor(colors.white)
	hows()
	   elseif z == "red" then
	term.setTextColor(colors.red)
	hows()
	   elseif z == "blue" then
	term.setTextColor(colors.blue)
	hows()
	   elseif z == "green" then
	   term.setTextColor(colors.green)
	   hows()
		  elseif z == "orange" then
	   term.setTextColor(colors.orange)
	   hows()
	  elseif z == "pink" then
	  term.setTextColor(colors.pink)
	  hows()
		 elseif z == "purple" then
		 term.setTextColor(colors.purple)
		 hows()
			elseif z == "gray" then
		 term.setTextColor(colors.gray)
		 hows()
			else
			 term.clear()
		  sleep(.5)
			 term.setTextColor(colors.red)
		  term.setCursorPos(1,2)
			 print "invlaid answer!"
		  term.setCursorPos(1,3)
		  print "---------------------------------------------------"
		  term.setCursorPos(1,4)
		  print "please try again!"
		  term.setCursorPos(1,5)
		  print "---------------------------------------------------"
		  sleep(4)
		  term.clear()
		  term.setTextColor(colors.white)
		  fuds()
	  end
   end
end

--print start
-- this is to see if the printer is out of ink or paper
local printer
if printer.getInkLeve() == 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 where the printer starts to print
--print start
function printered()
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
   end
sleep(1)
write "your document is finished"
term.clear()
sleep(.5)
write "would you like to do another document"
b = io.read()
if b == "yes" then
notepad()
elseif b == "no" then
term.clear()
end
--parts of the code where the comment "print"
--was a part of the printer tutorial made by"GopherAtl"
cmurtheepic #4
Posted 21 November 2012 - 02:01 PM
the events for the buttons on the keyboard don't load and if you look at my function they are all over the place and they wont lead anywhere because of the contradicting places they need to be in. and i cant figure out how to move them so they work please help me. ;(
lieudusty #5
Posted 21 November 2012 - 02:22 PM
What error are you getting and what line is it on? Its a little hard to help when we don't know the problem :(/>/>
lieudusty #6
Posted 21 November 2012 - 02:24 PM
Well why are you putting os.pullEvent 2 times?
EDIT: There is no such thing as a button on the keyboard (in my experience) that says ctrl+c
cmurtheepic #7
Posted 21 November 2012 - 05:07 PM
yes and the reason there is two os.pullevents is becuase it kept telling me to put a = over and over when like this:

event, param1, param2, param3 = os.pullEvent()
ok still please help me out. ;(
cmurtheepic #8
Posted 22 November 2012 - 06:23 AM
no i want it to open when you hold down control or (ctrl) and then you push the c button for colors
remiX #9
Posted 22 November 2012 - 08:51 AM
I'm busy rewriting it at the moment. So far I have done the choose colours and the writing with enter, space, backspace etc and a print function. I just need to find out how to do this backspace thing properly with it return to the end of the line before if it gets to the end of a line. So I need to save each line into a table, which the program 'edit' has. It should be done by tomorrow.
cmurtheepic #10
Posted 22 November 2012 - 09:16 AM
thanks a lot remiX
you helped me out greatly i owe you one man.
thanks a lot
cmurtheepic #11
Posted 22 November 2012 - 10:26 AM
oh and remix if you could add the ability to change font size of the text. that would be greatly appreciated.
i really don't know how to do that ;)/>/>
Lyqyd #12
Posted 22 November 2012 - 02:00 PM
Topics merged. Previous posts may be in a confusing order.
remiX #13
Posted 22 November 2012 - 10:25 PM
oh and remix if you could add the ability to change font size of the text. that would be greatly appreciated.
i really don't know how to do that ;)/>/>

If I'm not mistaken, you can only do that on Monitors
cmurtheepic #14
Posted 23 November 2012 - 07:09 AM
yeah but im not forcing you to do it you can if you want to ;)/>/>
cmurtheepic #15
Posted 23 November 2012 - 07:11 AM
oh and remix i am surely going to give you 50% credit in the program don't worry im not greedy ;)/>/> ill post a comment on the beginning and the end of the program that says this was created by remiX and cmurtheepic -_-/>/>
Lyqyd #16
Posted 23 November 2012 - 09:11 AM
It doesn't matter how much credit your promise to give him, he can't change how the computers work. setTextScale() is available on monitors, but not the computer terminals. It also sets the scale for all text on the screen.
cmurtheepic #17
Posted 23 November 2012 - 11:41 AM
how much have you gotten done on it remiX?
remiX #18
Posted 23 November 2012 - 11:06 PM
Been quite busy lately so haven't had a lot of time for CC. But it's very close ;)/>/> Just need to fix some small errors… Should be up by tonight
cmurtheepic #19
Posted 24 November 2012 - 08:38 AM
thanks remiX
cmurtheepic #20
Posted 25 November 2012 - 11:01 AM
remiX if you could post a copy of what you've gotten done i would really like to see it so then i may mess with it a bit :D/>/>
remiX #21
Posted 25 November 2012 - 01:31 PM
I came to a sudden realization that there is no point of doing this because it would do the same as edit? What exactly do you want for this?

Reason why I haven't posted it because I mainly used functions from the edit program, because that's basically what you're asking for, is it not? And selecting the colours, I just can't get that to work because it redraws each line all the time.

Sorry for this.
cmurtheepic #22
Posted 03 December 2012 - 04:18 PM
it's ok

:(/>
:(/>
:(/>
;(
;(
;(
*sad face*