Jump to content




Outputting to a Monitor or Terminal

peripheral computer networking

5 replies to this topic

#1 Lost Ninja

  • Members
  • 39 posts

Posted 10 June 2013 - 08:30 AM

I want to send a small message via network cable to a nearby monitor, but I'm stumped on the way to send messages via the cable. When I initially tried I got errrors that the peripheral didn't support those commands (term.clear() & term.setCursorPos()) so I worked out that I was trying to send those commands just to the wired modem and not down the wire.

function monOutput(msg)
	term.redirect(peripheral.wrap(monSide))
	term.clear()
	term.setCursorPos(1,1)
	term.print(pName)
	term.print(textutils.formatTime(os.time(),boolean))
	term.print(msg)
	term.restore()
end

function output(msg)
	if monitor == 1 then
		monOutput(msg)
	else
		term.clear()
		term.setCursorPos(1,1)
		print(textutils.formatTime(os.time(), boolean))
		print(msg)
	end
end

I've had another look at the wiki and realised that I should be using p.callRemote(peripheral name, peripheral method) but I cannot work out how to use it in the above code. Do I have to send a callRemote() for each of the commands, or is there some way to wrap it so I can do it once?

edit: derp derp derp... :/
Also I need an easy method to return the monitor name so that when I initialise the program I can store that name in the ini. When I called the correct API function I got a table string which is less than helpful.

Calling the p.getMethodsRemote() instead of p.getNamesRemote() will of course return a table instead of a string... :/

Edited by Lost Ninja, 10 June 2013 - 11:27 AM.


#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 10 June 2013 - 08:49 AM

The monitor's name (that you wrap or that you redirect the terminal to) is the name given by the wired modem on activation (right click). I mean, you place a wired modem on the monitor, right click on it and it says something like "monitor_0" registered. In that case, the monitor's name is not left or right, but monitor_0.

#3 Lost Ninja

  • Members
  • 39 posts

Posted 10 June 2013 - 11:34 AM

OP changed to reflect my idiocy... :/

The program is to build a simple (yet complex) TE battery monitor that can intuitively monitor the battery (via MiscPeriphs) and turn on/off engines. Because I loathe actually changing the guts of TE engines to function the same as BC/Foresty/etc engines (eg redstone signal on = engine on) it is designed to work either way on (it doesn't work well with mixed engines ofc). The output() functions above are merely to send an message to a monitor so I don't have to leave access to the computer which is often obscured.

However above and beyond that I prefer to have my oft used code (like this output() function) work under many scenarios, eventually it will go into my internal API so I can use it in all my programs. (Actually the output() function is in fact in that API, I want to expand it to allow for external monitors however.

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 10 June 2013 - 11:51 AM

So... My time to be kinda idiot... Is it solved then?

#5 Lost Ninja

  • Members
  • 39 posts

Posted 10 June 2013 - 04:57 PM

Uh:

How do I send output to a monitor connecting through a cable (as opposed to dire3ctly connecting). Bearing in mind I want to send the entirety of the term. section of the monOutput() function in the above code.

I guess that I can send each line separately with the p.callRemote(peripheral name, peripheral method) so I could use a:

p.callRemote(monitor_1,term.clear())

Or something, but I figured that there is an easier method (or something that works).

#6 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 10 June 2013 - 05:04 PM

When you activate the cable with the monitor, it tells you the name. After that you can simply wrap to that name and redirect the monitor with that.

And for your information; if you can call it, you can wrap it too.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users