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

I cant use Peripheral.wrap. ...

Started by kruschen, 07 July 2016 - 02:40 PM
kruschen #1
Posted 07 July 2016 - 04:40 PM
I cant use it.

And I need a Programm for Big Reactors to show the Reactor stats



Lyqyd #2
Posted 07 July 2016 - 05:12 PM
Moved to Ask a Pro.

There isn't a print method on a monitor peripheral.
ReBraLaCC #3
Posted 07 July 2016 - 08:00 PM
need to define it and then do <def>.write(text)

<def> is the definition you gave it

would suggest looking at this http://computercraft.info/wiki/Monitor
Bomb Bloke #4
Posted 08 July 2016 - 12:40 AM
When you "connected" the monitor by right-clicking the wired modem, you were given a "network name" (likely "monitor_0" or somesuch). That is the name you should be using when wrapping; in this case, "back" ends up wrapping the wired modem connected to the back of the computer.

Though as Lyqyd points out, either way you won't get a "print" function. Refer to the link ReBraLaCC gave you, the term API, and perhaps term.redirect() in particular.
The Crazy Phoenix #5
Posted 08 July 2016 - 09:31 AM
If you're going to use term.redirect, I suggest you store a copy of term.current before hand and then redirect to that copy once your program is finished.
Lyqyd #6
Posted 08 July 2016 - 02:34 PM
The usual idiom for redirecting a terminal is as follows:


local _oldTerm = term.redirect(mon)

--# redirected drawing code

if _oldTerm then
  term.redirect(_oldTerm)
else
  term.restore()
end
kruschen #7
Posted 09 July 2016 - 10:26 AM
Thanks for all the awnsers i try it monday :)/>
kruschen #8
Posted 09 July 2016 - 08:33 PM
You awnsers helped a lot

but i have a error:



the script works well

but if i will clear the monitor then it gave an error in line 6

Anavrins #9
Posted 09 July 2016 - 09:58 PM
kraftwerk.getActive is a function, call it using () at the end of it.
if kraftwerk.getActive() then…

Edit: Same thing for monitor.clear, should be monitor.clear()
Edited on 09 July 2016 - 07:59 PM
kruschen #10
Posted 09 July 2016 - 10:41 PM
Thanks that helps a lot :)/>