Yes, any display obtained via peripheral.wrap() will be a monitor.
Comparing term.current() against a new peripheral.wrap result will always be false, as peripheral.wrap will generate a new table each time it's called.
Well, unless you record the result of wrapping the monitor in a variable, then redirect to
that and later compare against it. Certainly the technique will fail as written.
Likewise, comparing term.current() to term.native() runs into trouble on advanced computers, as multishell starts you off with full-screen window as your "default" terminal - not with term.native().
In any case, it's worth noting that term.current() is never the same as term. The former returns the actual pointer to whatever it is you're redirected to. term returns, well, the current terminal table, which is an altered version of whatever it is you're redirected to.
Windows and monitors have access to functions that the native display of your computer never has. These functions never appear in the current terminal table, either, even if you redirect to a window or monitor. But since term.current() returns a pointer to the
actual terminal object you're redirecting to (keeping in mind that all "terminal objects" are simply tables filled with functions for dealing with a given display), you can check if the table
that returns has the relevant functions of a monitor/window in order to determine what sort of display it points to.
Eg:
if term.current().setTextScale then
-- You're currently redirected to a monitor.
elseif term.current().setVisible then
-- You're currently redirected to a window.
elseif term.current() == term.native() then
-- You're currently directly using the computer's own display.
end
If you have a wrapped monitor, you can't determine what "side" it belongs to unless you wrapped it and saved that information at the time. Well, unless the computer only has
one external monitor available, or all the attached displays have different dimensions, or different colour-capabilities, in which case you could probe them for that information and figure it out - but they might all be the same, so this might not be possible!. I like to use peripheral.find() to embed it as a "side" key in the wrapped monitor's table:
local mon = peripheral.find("monitor", function(name, object) object.side = name return true end) -- Or "return object.isColour()", if you only want colour displays.
print(mon.side) -- Prints whatever side was wrapped.
I'm not sure what you're saying you want your script to do, but you might find this code snippet useful:
-- Populate this "displays" table with as many terminal objects as you want:
local displays = {term.current(), peripheral.find("monitor")} -- This example gets the current terminal plus all attached monitors.
local multiTerm = {}
for funcName,_ in pairs(displays[1]) do -- For each function that exists in the first object in "displays",
multiTerm[funcName] = function(...) -- ... generate a new function of the same name in the multiterm table...
for i=2,#displays do displays[i][funcName](unpack(arg)) end -- ... that calls the same function in all the OTHER objects...
return displays[1][funcName](unpack(arg)) -- ... and returns the output from the function in the first.
end
end
-- "multiterm" is now a single terminal object filled with functions that affect all of the terminal objects in the "displays" table.
term.redirect(multiTerm)