Jump to content




[1.31] Small Monitor API v1.2


  • This topic is locked This topic is locked
28 replies to this topic

#21 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 15 June 2012 - 05:24 PM

Give me a shout if either of those don't work and I'll see if I can fix them up for you.

#22 Xemiru

  • Members
  • 38 posts

Posted 23 June 2012 - 09:29 AM

For the marquee, try
x,y = term.getSize()
function marqueeRight(text,ypos)
  val = 1
  while true do
    term.clear()
    term.setCursorPos(val,ypos)
    write(text)
    if val == x then
	  val = 1
    else
	  val = val + 1
    end
    sleep(0.5)
  end
end

It failed when I tested it, but maybe you can build something off of it.

#23 ihaveamac

  • New Members
  • 15 posts

Posted 25 June 2012 - 08:51 PM

View PostLyqyd, on 15 June 2012 - 05:24 PM, said:

Give me a shout if either of those don't work and I'll see if I can fix them up for you.
It didn't work properly, the text was going up. It was moving to the side I believe though. Try it yourself.

#24 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 26 June 2012 - 12:57 AM

function marqueeLeft(side, text, ypos, sleep)
    if peripheral.isPresent(side) then
		    term.redirect(peripheral.wrap(side))
		    local sx, sy = term.getSize()
		    text = string.rep(" ", sx - 1)..text
		    for i=1,string.len(text) do
				    term.clearLine()
				    displayString = string.sub(text, i, math.min(string.len(text), (i + sx - 2)))
				    term.setCursorPos(1, ypos)
				    write(displayString)
				    os.sleep(sleep)
		    end
		    term.clearLine()
		    term.restore()
    end
end
function marqueeRight(side, text, ypos, sleep)
    if peripheral.isPresent(side) then
		    term.redirect(peripheral.wrap(side))
		    local sx, sy = term.getSize()
		    text = string.rep(" ", sx - 1)..text..string.rep(" ", sx - 1)
		    for i = 1,string.len(text) - (sx - 1) do
				    term.clearLine()
				    displayString = string.sub(text, -math.min(string.len(text), i + sx - 2), -i)
				    term.setCursorPos(1, ypos)
				    write(displayString)
				    os.sleep(sleep)
		    end
		    term.clearLine()
		    term.restore()
    end
end

Fixed versions. Tested them and they seem to work fine here on a variety of monitor sizes. Give these guys a whirl.

#25 ihaveamac

  • New Members
  • 15 posts

Posted 30 June 2012 - 10:03 PM

View PostLyqyd, on 26 June 2012 - 12:57 AM, said:

function marqueeLeft(side, text, ypos, sleep)
	if peripheral.isPresent(side) then
			term.redirect(peripheral.wrap(side))
			local sx, sy = term.getSize()
			text = string.rep(" ", sx - 1)..text
			for i=1,string.len(text) do
					term.clearLine()
					displayString = string.sub(text, i, math.min(string.len(text), (i + sx - 2)))
					term.setCursorPos(1, ypos)
					write(displayString)
					os.sleep(sleep)
			end
			term.clearLine()
			term.restore()
	end
end
function marqueeRight(side, text, ypos, sleep)
	if peripheral.isPresent(side) then
			term.redirect(peripheral.wrap(side))
			local sx, sy = term.getSize()
			text = string.rep(" ", sx - 1)..text..string.rep(" ", sx - 1)
			for i = 1,string.len(text) - (sx - 1) do
					term.clearLine()
					displayString = string.sub(text, -math.min(string.len(text), i + sx - 2), -i)
					term.setCursorPos(1, ypos)
					write(displayString)
					os.sleep(sleep)
			end
			term.clearLine()
			term.restore()
	end
end

Fixed versions. Tested them and they seem to work fine here on a variety of monitor sizes. Give these guys a whirl.
Thanks, it worked! I'll add it for the next version. :P/>

#26 ihaveamac

  • New Members
  • 15 posts

Posted 15 July 2012 - 11:22 PM

Updated to v1.2, fixed marquee functions and added monitorapi.run(side, func).

#27 FuzzyPurp

    Part-Time Ninja

  • Members
  • 510 posts
  • LocationHarlem, NY

Posted 11 August 2012 - 10:55 AM

Changed title for you, next time just edit your topic, then choose Full Editor.

#28 Jamboozlez

  • Members
  • 9 posts

Posted 01 May 2013 - 02:33 PM

Could you please create a function for:
m.setTextScale(size) -- size can be any number from 1 to 5
--example:
monitorapi.setTextScale(side, size) -- make it return an error when you use a size not within 1-5
Thanks ;)

#29 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 01 May 2013 - 04:08 PM

That function is a pretty trivial addition.

function setTextScale(side, size)
  return peripheral.call(side, "setTextScale", size)
end

Might as well just use the peripheral call. Either way, this is pretty old. Locked.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users