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

Monitor Display

Started by tysciman7, 17 October 2013 - 04:40 PM
tysciman7 #1
Posted 17 October 2013 - 06:40 PM
Okay so im am trying to have a monitor display a like full chart for beer brewing.
I was wondering how I put the text with multiple lines on the monitor. Without doing mon.write("…") for each line.

this is what i am trying to replicate on the monitor http://feed-the-beas...ki/Booze_Barrel
Goof #2
Posted 17 October 2013 - 07:47 PM
Use the term.redirect(peripheral) and then just use the print() function
tysciman7 #3
Posted 17 October 2013 - 07:56 PM
but do i have to print() each line Ex:

print("…")
print("…")
print("…")
print("…")


for each next line
Bomb Bloke #4
Posted 17 October 2013 - 09:01 PM
With "print" statements, you may use the backslash escape character to specify special cases.

For example, try:

print("This\r\nis\r\n\a\r\ntest")
print("I can print quotes! \"\"\"")

There are some limitations as to when you can use escape characters, such as mentioned here.

It's also worth looking into "for" loops. Eg:

myTable = {"This","is","a","test"}
for i=1,#myTable do
  print(myTable[i])
end
ingie #5
Posted 03 February 2014 - 03:26 PM
sorry if 4 months is necro-ing, but i just wanted to add to this for anyone searching for similar…

you can always define multi-line strings using [[ and ]] as delimiters in lua.

e.g.


print([[This is
on multiple
lines ending in
this one]])

--[[
outputs:

this is
on multiple
lines ending in
this one

--]]


myVar = [[Something
spanning
multiple
lines]]

print(myVar)

--[[
outputs:

Something
spanning
multiple
lines

]]--



myTable = {
  name = "Test",
  multiLineDesc = [[A Description
over more than one line]]
}

print(myTable.multiLineDesc)

--[[
outputs:

A Description
over more than one line

]]--

see also: http://lua-users.org...StringsTutorial - which gives the detail on this and other things related.

personally, i prefer the C style "\n" type of formatting which [member='Bomb Bloke'] shows above rather than my example here , as that's what i've always used, and it's more craftable using programmatic means… but your personal preference may be different
Edited on 03 February 2014 - 02:31 PM