Jump to content




Monitor Display


  • You cannot reply to this topic
4 replies to this topic

#1 tysciman7

  • Members
  • 41 posts

Posted 17 October 2013 - 05: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

#2 Goof

  • Members
  • 751 posts

Posted 17 October 2013 - 06:47 PM

Use the term.redirect(peripheral) and then just use the print() function



#3 tysciman7

  • Members
  • 41 posts

Posted 17 October 2013 - 06:56 PM

but do i have to print() each line Ex:

print("...")
print("...")
print("...")
print("...")


for each next line

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 17 October 2013 - 08: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


#5 ingie

  • Members
  • 69 posts
  • LocationMannin

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 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 by ingie, 03 February 2014 - 03:31 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users