Jump to content




Billboard program works when run manually but not on startup?


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

#1 D3matt

  • Members
  • 830 posts

Posted 30 May 2012 - 12:46 AM

I can't get the code write now because the server has hit its paste limits, but basically it was a variation of Casper's cPrint that used monitor instead of term. The program works just fine if I run it manually, but if I try to run it with startup, it returns true with no errors, but doesn't put anything on the monitor.

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 30 May 2012 - 12:59 AM

Did you use the exact same code both times? Maybe you are missing some step to initialize the monitor. I don't know, without the code it's pretty hard to see the error.

#3 Zalerinian

  • New Members
  • 68 posts
  • LocationThe Internet

Posted 30 May 2012 - 01:03 AM

haha, easy work around to that. First, you need a pastebin account. Next use 'pastebin get vd5cxi8S <a name here>' (i left the link so you can click to the paste.) This is the 'Better Patebin Program.' I am not sure who made this, but it was NOT me. All you need to do is type the program name, i'll use 'pb' as an example, and 'billboard as the program you want to use.

pb put billboard

It will ask you to login. Login using your account and give the paste a name. It will be 1. posted onto pastebin, and 2. conveniently in your accounts pastebin waiting for you. This bypasses the pastebin limit, and makes oyu not need to constantly look back at the code or screenshot it. Please use this method and then paste the code ^^

#4 D3matt

  • Members
  • 830 posts

Posted 30 May 2012 - 01:26 AM

    function cWrite(text, side, scale)
	  if (peripheral.isPresent(side)) and (peripheral.getType(side) == "monitor") then
	    monitor = peripheral.wrap(side)
	  else return false
	  end
	  monitor.clear()
	  monitor.setCursorPos(1,1)
	  local x2,y2 = monitor.getCursorPos()
	  local x, y = monitor.getSize()
	  monitor.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), math.ceil(y / 2))
	
	  monitor.setTextScale(scale)
	  monitor.write(text)
	  return true
    end
	
    print(cWrite("Pheonix", "back", 5))


#5 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 30 May 2012 - 01:47 AM

I think the problem might be setting the text scale after the cursor position, wich would make the cursor be outside the screen.
Change the function to this:
local function cWrite(text, side, scale)
  if peripheral.isPresent(side) and peripheral.getType(side) == "monitor" then
    local monitor = peripheral.wrap(side)
    monitor.clear()
    monitor.setTextScale(scale)
    local w, h = monitor.getSize()
    monitor.setCursorPos(math.ceil((w / 2) - (#text / 2)), math.ceil(h / 2))
    monitor.write(text)
    return true
  end
  return false
end


#6 D3matt

  • Members
  • 830 posts

Posted 30 May 2012 - 02:01 AM

That seems to have worked, thanks!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users