I've seen it done but I have no idea how it's done.
Essentially How my program is going to work is it's going to connect then i'll have it make another line with that blocks name.
local mon
for k, v in pairs( peripheral.getNames() ) do
if peripheral.getType( v ) == "monitor" then
mon = peripheral.wrap( v )
break
end
end
if not mon then
error( "No monitors found", 0 )
end
local reactors = {peripheral.find("reactorType")}
for i = 1, #reactors do
print(reactors[i].getEnergyOrWhatever())
end
local OSTimer = os.startTimer(0)
while true do
local event, par1 = os.pullEvent()
if event == "timer" and par1 == OSTimer then
m.clear()
Header()
ListAll()
m.setBackgroundColor(colors.black)
OSTimer = os.startTimer(1)
elseif event == "peripheral_detach" or event == "peripheral" then
m = peripheral.find("monitor")
r = {peripheral.find("BigReactors-Reactor")}
h = {peripheral.find("harvester")}
g = {peripheral.find("grinder")}
end
end
ListMachine("Harvester",#h,r[i],nil)
ListMachine("Grinder",#g,g[i],nil)
ListMachine("Harvester",h)
ListMachine("Grinder",g)
function ListMachine(Name,Peripherals)
comparison2 = comparison1
for i = 1, #Peripherals do
m.setBackgroundColor(colors.orange)
if comparison2 == 1 then
if Peripherals[i].getActive() then
Running()
else
NotRunning()
end
end
m.setCursorPos(1,YPos)
m.write(Long)
m.setCursorPos(1,YPos)
m.write(Name.." #"..i)
YPos = YPos + 1
end
end
eventQueue = {os.pullEvent()}
Good point, i'll change it in future code. eventTable maybe since it's a table not a variableeventQueue = {os.pullEvent()}
'eventQueue' is a really bad name, as that statement doesn't return a list of all events, it returns all parameters of one event. 'event' or 'eventData' would be a better name.
Good point, i'll change it in future code. eventTable maybe since it's a table not a variableeventQueue = {os.pullEvent()}
'eventQueue' is a really bad name, as that statement doesn't return a list of all events, it returns all parameters of one event. 'event' or 'eventData' would be a better name.
The function at line 55 is ListMachine(), but the function called at line 136 is FindPeripherals()…?
The calls are on lines 122/123:ListMachine("Harvester",#h,r[i],nil) ListMachine("Grinder",#g,g[i],nil)
… but what's "i" supposed to be? You aren't in one of your "for" loops here!
I guess you intended to do something like this:ListMachine("Harvester",h) ListMachine("Grinder",g)
… with a function like this:function ListMachine(Name,Peripherals) comparison2 = comparison1 for i = 1, #Peripherals do m.setBackgroundColor(colors.orange) if comparison2 == 1 then if Peripherals[i].getActive() then Running() else NotRunning() end end m.setCursorPos(1,YPos) m.write(Long) m.setCursorPos(1,YPos) m.write(Name.." #"..i) YPos = YPos + 1 end end
a=os.clock()
for i=1,3
b=os.clock()
print(b-a)
Peripherals.getEnergyStored()
a=os.clock()
print(a - B)/>
Peripherals.getEnergyStored()
end
and see if it takes ticks a noticable time to runThe big reactor information calls definately do not yield, i can only assume the mfr ones do yield which is causing the lag. unless i am mistaken. I don't have this mfr functionality installed on my minecraft, try usingand see if it takes ticks a noticable time to runa=os.clock() for i=1,3 b=os.clock() print(b-a) Peripherals.getEnergyStored() a=os.clock() print(a- B)/>/> Peripherals.getEnergyStored() end
if it does then the only solution i can think of is coroutines.
local g = {peripheral.find("grinder")}
function ListMachine(Peripherals)
a=os.clock()
for i = 1, 3 do
b=os.clock()
print(b-a)
Peripherals.getEnergyStored()
a=os.clock()
print(a- B)/>
Peripherals.getEnergyStored()
end
end
ListMachine(g)
and pastebin for some reason when i copy it doesn't copy exactly how mine looks vs how it ends up.
Yea there were a few problems and i removed them but it still was giving meyou capitalised a-BB is totally different to b
what the hell, i TYPE (a- b )and it saves (a- B )/>
A couple of ways around it; either perform all the calls, save the results to a table, then render them all in one go - or just don't clear the whole display, do it a line at a time.
The latter's faster and easier to code (you'd be modifying just a few lines), though the former would do a more thorough job of eliminating the problem. Either way you choose, done correctly, there's no need to have any flicker at all.
while true do
m.setBackgroundColor(colors.black)
local Event, EventType = os.pullEvent()
if Event == "peripheral_detach" then
term.setTextColor(colors.orange)
print(EventType.." has been detached.")
print("Screen has been reset")
FindPeripherals()
m.clear()
elseif Event == "peripheral" then
term.setTextColor(colors.blue)
print(EventType.." has been attached.")
print("Screen has been reset")
FindPeripherals()
m.clear()
elseif Event == "timer" then
OSTimer = os.startTimer(1)
end
if CONNECTED2 == 1 then
Connected2()
CONNECTED2 = 0
end
RunThrough()
end
Third thing
no os.pull does NOT have to be in {} but you will drop results if you just have two variables to hold the results it can return up to 6 depending on the event.
Second glance
you m.clear() right after you FindPeripherals()? won't that clear the moment you write to it?
Does it print that a peripheral is attached or detached?
Does it print that a peripheral is attached or detached?