Posted 07 August 2015 - 05:26 AM
Edit: Thanks for the nearly instant support and example code. I`ll re-post the code in the comments if I can clean up the coroutines using the parallel API. :D/>
This is my first post, so sorry in advance if I make a ridiculous mistake. ;)/>
What I basically want to do is have a main computer taking the EU level of three different storage devices, in this case MFSU`s, and printing them individually then adding them together to find the total EU stored. I also want the user to have the ability to turn charging on or off, via EU splitter cable between the MFSU`s and the power source, all with a refresh rate of somewhere from .25 to .1 seconds. The problem I`m having is that it`s throwing me this error every time I try to run it and I can`t figure out why:
bios:339: [string "eu"]:7: '(' expected
I believe it has to do with the creation of the coroutine, but I don`t know what I`m doing wrong.
P.S. Sorry if the bit about coroutine yielding and resuming makes you want to facepalm. I`m also using Minecraft 1.6.4 on FTB Tech World 2.
Thanks in advance.
This is my first post, so sorry in advance if I make a ridiculous mistake. ;)/>
What I basically want to do is have a main computer taking the EU level of three different storage devices, in this case MFSU`s, and printing them individually then adding them together to find the total EU stored. I also want the user to have the ability to turn charging on or off, via EU splitter cable between the MFSU`s and the power source, all with a refresh rate of somewhere from .25 to .1 seconds. The problem I`m having is that it`s throwing me this error every time I try to run it and I can`t figure out why:
bios:339: [string "eu"]:7: '(' expected
I believe it has to do with the creation of the coroutine, but I don`t know what I`m doing wrong.
P.S. Sorry if the bit about coroutine yielding and resuming makes you want to facepalm. I`m also using Minecraft 1.6.4 on FTB Tech World 2.
Thanks in advance.
p = peripheral.wrap("mfsu_0")
o = peripheral.wrap("mfsu_1")
i = peripheral.wrap("mfsu_2")
rs.setOutput("left", true)
q = true
eu = coroutine.create(function eu ()
while true do
term.setCursorPos(1,1)
term.clear()
z = p.getEUStored()
x = o.getEUStored()
c = i.getEUStored()
term.setCursorPos(1,1)
term.clear()
print("MFSU 1 EU:".. z)
print("MFSU 2 EU;".. x)
print("MFSU 3 EU;".. i.getEUStored())
print("Total EU stored:".. z + x + c)
print()
--os.sleep(.1)
coroutine.yield()
end
end
end
listen = coroutine.create( function listen())
while true do
--os,sleep(.1)
term.setCursorPos(1,6)
term.clear()
if q == false then
local h = true
print("Change charging setting, t/f? The setting is ".. tostring(h))
elseif q == true then
local h = false
print("Change charging setting, t/f? The setting is ".. tostring(h))
end
y = read()
if y == "f" then
q = true
rs.setOutput("left", false)
elseif y == "t" then
q = false
rs.setOutput("left", true)
end
end
end
end
while true do
os.sleep(.1)
coroutine.resume(eu)
os.sleep(.1)
coroutine.resume(eu)
os.sleep(.1)
coroutine.resume(listen)
os.sleep(.1)
coroutine.yield(listen)
end
Edited on 07 August 2015 - 04:17 AM