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

---IDEA Please Help---

Started by matmatspeed, 30 June 2013 - 10:00 AM
matmatspeed #1
Posted 30 June 2013 - 12:00 PM
I have a idea I want a Advanced monitor to the display "Speedys Farm" but I want it to be scrolling across the screen and the on the second line of my monitors I want a bit of coloured text saying " Farm Shop Open " in green and " Farm Shop Closed " and to beable to switch between open/closed with a Redstone input.


if some could help Me write a progam to do that I would be forever grateful. I know very limited code so I need some help.


Thanks

Speedy
Lyqyd #2
Posted 30 June 2013 - 01:50 PM
Moved to Ask a Pro.
Apfeldstrudel #3
Posted 30 June 2013 - 03:04 PM
Remember people are rarely happy to write code for you.
"Scrollig a cross and text scale 5"?
matmatspeed #4
Posted 30 June 2013 - 03:08 PM
Edited and I Know but I would really be grateful if someone could help.
Robert00001 #5
Posted 30 June 2013 - 04:31 PM

local tin = .1
local tim = os.startTimer(tin)
local i = 0
local rside = "left" -- Redstone Side
local mside = "right" -- Monitor Side
local mon = peripheral.wrap(mside)
local w,h = mon.getSize()
local st = "Speedy's Farm"
local ro = "Farm Shop Open"
local rc = "Farm Shop Closed"

mon.clear()
while true do
  local e,p = os.pullEvent()
  if e == "timer" and p == tim then
    tim = os.startTimer(tin)
    mon.setTextColor(colors.white)
    mon.setCursorPos(1,1)
    mon.clearLine()
    for j=1, #st do
      local x = i + j
      if x > w then x = x - w end
      mon.setCursorPos(x, 1)
      mon.write(st:sub(j, j))
    end
    i = i + 1
    if i > w then i = 0 end
    local inp = redstone.getInput(rside)
    mon.setCursorPos((w/2)-((inp and #ro or #rc)/2),2)
    mon.setTextColor(inp and colors.lime or colors.red)
    mon.clearLine()
    mon.write(inp and ro or rc)
  end
end

Tried my best
matmatspeed #6
Posted 30 June 2013 - 05:39 PM
THANK YOU!!!!!!!!! But could You make the text scale to fit a monitor 2 high by 5 wide. :)/>
KaoS #7
Posted 30 June 2013 - 05:54 PM
here is my take on it


local delay=0.1
local scrolled=1
local str="Speedy's Farm"
term.redirect(peripheral.wrap("right"))
local timer=os.startTimer(delay)
local tOpts={[true]="Open",[false]="Closed"}
local evt={}
while true do
  if evt[1]=="timer" and evt[2]==timer then
    scrolled=(scrolled+1)%term.getSize()
    timer=os.startTimer(delay)
  end
  term.clear()
  term.setCursorPos(1,1)
  print((str..(term.getSize()-#str>0 and string.rep(" ",term.getSize()-#str) or "")):sub(scrolled+1,#str>term.getSize() and term.getSize()+scrolled or nil)..(#str<term.getSize() and str:sub(1,scrolled) or term.getSize()+scrolled>#str and str:sub(1,term.getSize()+scrolled-#str) or ""))
  print("Farm Shop "..tOpts[rs.getInput("left")])
  evt={os.pullEvent()}
end
apemanzilla #8
Posted 30 June 2013 - 05:58 PM
After the line

local mon = peripheral.wrap(mside)
add a line

mon.setTextScale(1.0)
Play around with the 1.0 until it fits, increasing and decreasing it.
KaoS #9
Posted 30 June 2013 - 05:58 PM
PS my version auto scales, I then modified it again to re-scale every render so if you change the monitors while it is running it auto-fits and always works

After the line

local mon = peripheral.wrap(mside)
add a line

mon.setTextScale(1.0)
Play around with the 1.0 until it fits, increasing and decreasing it.

he means make it span both monitors man, just add more spaces. No need to make things bigger
Edited on 30 June 2013 - 03:59 PM
matmatspeed #10
Posted 01 July 2013 - 11:08 AM
Robert00001 version works the best. thanks for your input Kaos. thanks for the telling me how to change the size but could the top line be like size 4 and the bottom line like size 2. and is it possible to make the scrolling slower. thanks
albrat #11
Posted 03 July 2013 - 04:19 AM
to make the scrolling slower just add a sleep(0.5) in the script…

Just after the mon.write line should be a good place to put the sleep command in . (increase the 0.5 to 1 if the speed is too fast and decrease it by 0.1 if it's too slow)
Lyqyd #12
Posted 03 July 2013 - 01:22 PM
You cannot use two different scales on one monitor.
matmatspeed #13
Posted 05 July 2013 - 12:32 PM
you can just change the number on first line "Local tin"
Galactica4 #14
Posted 11 July 2013 - 03:00 AM
So using this, thanks, saved me a post!!
matmatspeed #15
Posted 12 July 2013 - 05:53 PM
So using this, thanks, saved me a post!!
Glad you like it works really well just put pastebin z2fe6BEy Startup into the computer.

thanks to all the people that helped :)/>