Problem 1: In both chunks of code, my monitors never set the text scale to 3 - they do everything else just fine, except that one thing - what am I doing wrong?
Problem 2: In code block A both of my monitors are found; in code block B only 1 is found - both monitors are attached via modem/network cable (modems are on) - what did I do wrong?
Spoiler
local mon = { }
for _, side in pairs(rs.getSides()) do
if peripheral.getType(side) == "modem" and not peripheral.call(side, "isWireless") then
for _, name in pairs(peripheral.call(side, "getNamesRemote")) do
if peripheral.getType(name) == "monitor" then
peripheral.call(name, "setTextScale", 1)
local x, y = peripheral.call(name, "getSize")
if x == 18 and y == 5 then
peripheral.call(name, "setTextScale", 3) --# doesn't happen for some reason
mon[#mon + 1] = peripheral.wrap(name)
--mon[#mon].setTextScale(3) --# doesn't work either
end
end
end
end
end
Spoiler
local mon = {
peripheral.find("monitor",
function(name, object)
object.setTextScale(1)
local x, y = object.getSize()
if x == 18 and y == 5 then
object.setTextScale(3) --# doesn't happen for some reason
return true
else
return false
end
end
)
}
I'm using this code in a countdown timer - everything works, except all the text is at textScale 1 instead of 3 and I can't figure out why - the above code is the only place is the program that calls setTextScale so I'm reasonably sure it's not happening somewhere else in the program. For reference, the entire program…
Spoiler
local nHours = 0 --# leave this at 0
local nMinutes = 0
local nSeconds = 30
local totalTime = (nHours * 36000) + (nMinutes * 600) + (nSeconds * 10)
local hours, minutes, seconds, sHours, sMinutes, sSeconds, sTenths, countdownTimer
local lcGate = false
local gate = peripheral.find("stargate")
if not gate then lcGate = true gate = peripheral.find("StargateBase") end
if not gate then error("No Stargate located") end
local mon = { }
for _, side in pairs(rs.getSides()) do
if peripheral.getType(side) == "modem" and not peripheral.call(side, "isWireless") then
for _, name in pairs(peripheral.call(side, "getNamesRemote")) do
if peripheral.getType(name) == "monitor" then
peripheral.call(name, "setTextScale", 1)
local x, y = peripheral.call(name, "getSize")
if x == 18 and y == 5 then
peripheral.call(name, "setTextScale", 3)
mon[#mon + 1] = peripheral.wrap(name)
--mon[#mon].setTextScale(3)
end
end
end
end
end
local function cdTimer()
local continue, timer, sgEvent, _, new_State, old_State = false
while true do
if lcGate then
os.pullEvent("connect")
continue = true
else
sgEvent, _, new_State, old_State = os.pullEvent("sgStargateStateChange")
if new_State == "Connected" then continue = true end
end
if continue then
if mon[1] then
for i = 1, #mon do
mon[i].setTextColor(colors.white)
end
end
for i = totalTime, 0, -1 do
hours = totalTime > 35999 and math.floor(totalTime / 36000) or 0
sHours = tostring(hours)
minutes = totalTime > 599 and math.floor((totalTime - (hours * 36000)) / 600) or 0
sMinutes = minutes > 9 and tostring(minutes) or "0" .. tostring(minutes)
seconds = totalTime > 9 and math.floor((totalTime - ((hours * 36000) + (minutes * 600))) / 10) or 0
sSeconds = seconds > 9 and tostring(seconds) or "0" .. tostring(seconds)
sTenths = tostring(math.floor(totalTime - ((hours * 36000) + (minutes * 600) + (seconds * 10))))
if totalTime == 0 then
continue = false
if lcGate then
pcall(gate.disengageStargate)
else
gate.disconnect()
end
end
if mon[1] then
for i = 1, #mon do
mon[i].setCursorPos(1, 1)
if totalTime == 0 and mon[i].isColor() then mon[i].setTextColor(colors.red) end
mon[i].write(sMinutes .. ":" .. sSeconds .. ":" .. sTenths .. " ")
end
end
if totalTime > 0 then
countdownTimer = os.startTimer(0.1)
while true do
_, timer = os.pullEvent("timer")
if timer == countdownTimer then
totalTime = totalTime - 1
break
end
end
end
end
end
end
end
local function gateLiaison()
shell.run("/gateLiaison")
end
parallel.waitForAny(cdTimer, gateLiaison)