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

Eu/T Output

Started by ihatetn931, 20 August 2014 - 12:50 AM
ihatetn931 #1
Posted 20 August 2014 - 02:50 AM
How can i get how much eu/t is going through a cable with computercraft? Since the eu-reader no longer works i'd like a way tor ead how much eu i'm outputting on a monitor. I've done some searching haven't came up with much

using direwolf20 1.0.23 pack

I'm not outputting the power from a reactor it's outputting from railcraft steam turbines.

I've tried with openperipherals but there is really no function to get how much eu you're outputting.

basically i just want a way to show my eu/t output

Maybe with openperipherals or somthing
Edited on 20 August 2014 - 02:39 AM
koslas #2
Posted 20 August 2014 - 03:11 PM
To find out how much EU is going through something I belive you'd have to make it a peripheral, and use it's functions, I don't belive that you can connect a cable as a peripheral, but you could make a program to read an MFSU, or whatever power storage you're using, and check for a change in that, like if it loses 10EU/t but replienses it, you could figure out it is using about 10EU/t
ihatetn931 #3
Posted 20 August 2014 - 04:41 PM
So all the searching i have done, i found out that there is no way to get eu/t output, anyone happen to know how to do the math to get eu/t output?
KingofGamesYami #4
Posted 20 August 2014 - 04:50 PM

local EU = --#insert amount of EU (number)
print( "EU/t: " .. EU/ 0.1 ) --#0.1 == 1 t or tick
ihatetn931 #5
Posted 20 August 2014 - 06:13 PM
I could do somthing like that but it wouldn't be very dynamic, How about a way to convert the output percent of a steam turbine to eu/t

For example the steam turbine output is at 5% it would be producing say 50 eu/t.

Would need to figure out how much it's outputting for each percent, i don't even know where to start on the math for that
KingofGamesYami #6
Posted 20 August 2014 - 06:16 PM
Ok, well that's easy enough…

local output = 1000 -#maximum outpu
local percentage = 5 --#5%
print( output * (percentage/100) )
ihatetn931 #7
Posted 20 August 2014 - 06:33 PM
I think that may have worked


local output = 200 --#maximum outpu
local percentage = con[10].getTurbineOutput() --#5%
print("Eu/t: "..tostring(output * (percentage/100)))
print("Turbine Rotor Percent: "..percentage)

One more question, when it outputs the numbers it does like 5.84629846

Anyway to make it just print the 5 and not the numbers after the 5?
KingofGamesYami #8
Posted 20 August 2014 - 06:42 PM
math.floor( 5.8 ) –> 5
math.ciel( 5.8 ) –> 6
ihatetn931 #9
Posted 20 August 2014 - 07:23 PM
Thank you for your help

This is what i came out with


function getTurbinesRotor()
return math.floor(con[10].getTurbineOutput() and con[11].getTurbineOutput() and con[12].getTurbineOutput() and con[13].getTurbineOutput() and con[14].getTurbineOutput() and con[15].getTurbineOutput() and con[16].getTurbineOutput() and con[17].getTurbineOutput and con[18].getTurbineOutput() and con[19].getTurbineOutput())
end

function getTurbineOp()
return 200*10
end

function getTurbineEu()
return math.floor(getTurbineOp() * (getTurbinesRotor()/100))
end


but for some reason, it's flashing unlike the other ones


print("Eu/T: "..getTurbineEu().." / Rotors: "..getTurbinesRotor().." / Output: "..getTurbineOp())
Edited on 20 August 2014 - 05:59 PM
KingofGamesYami #10
Posted 20 August 2014 - 08:53 PM
I think you meant to add the outputs together, yes? I've cleaned up this function a bit for you.

function getTurbinesRotor()
  local result = 0
  for i = 10, 19 do
    result = result + con[ i ].getTurbineOutput()
  end
  return math.floor( result )
end
ihatetn931 #11
Posted 20 August 2014 - 09:41 PM
That works thanks, but it's still flashing :-(

Did some changes as i noticed result + was adding, gave the turbines their own table



turbines = {
peripheral.wrap("rcsteamturbinetile_0"),
peripheral.wrap("rcsteamturbinetile_1"),
peripheral.wrap("rcsteamturbinetile_2"),
peripheral.wrap("rcsteamturbinetile_3"),
peripheral.wrap("rcsteamturbinetile_4"),
peripheral.wrap("rcsteamturbinetile_5"),
peripheral.wrap("rcsteamturbinetile_6"),
peripheral.wrap("rcsteamturbinetile_7"),
peripheral.wrap("rcsteamturbinetile_8"),
peripheral.wrap("rcsteamturbinetile_9")
}

function getTurbineOp()
return math.floor(200*10)
end

function getTurbinesRotor()
  local result = 0
  for i = 1, 10 do
	result = turbines[ i ].getTurbineOutput()
  end
  return math.floor(result)
end

function getTurbineEu()
return math.floor(getTurbineOp() * getTurbinesRotor()/100)
end

Prints


print(getTurbineEu().." EU/T")
print("Rotors: "..getTurbinesRotor().." %")
print("Output: "..getTurbineOp())

I can't add it to my monitor cause it will make the whole monitor flash, even with the edited function you did it still flashed, any idea what's casuing only these to flash? Now if i put it on top of my other prints on the console it makes them all flash

All prints that go on the console


print("Oil: "..getLiquid(1).."/"..getMaxLiquid(1))
print("Fuel: "..getLiquid(2).."/"..getMaxLiquid(2))
print("Energy: "..getEnergy().."/"..getMaxEnergy())
--Below this line is the ones that flash
print(getTurbineEu().." EU/T")
print("Rotors: "..getTurbinesRotor().." %")
print("Output: "..getTurbineOp())
Edited on 20 August 2014 - 07:43 PM
KingofGamesYami #12
Posted 20 August 2014 - 09:47 PM
Try printing only once. "\n" makes a new line. Therefor, print( "hello\nworld" ) outputs:

hello
world
ihatetn931 #13
Posted 20 August 2014 - 09:54 PM
change the prints to this


print("Oil: "..getLiquid(1).."/"..getMaxLiquid(1).."\nFuel: "..getLiquid(2).."/"..getMaxLiquid(2).."\nEnergy: "..getEnergy().."/"..getMaxEnergy().."\n"..getTurbineEu().." EU/T".."\nRotors: "..getTurbinesRotor().." %".."\nOutput: "..getTurbineOp())

Now that whole print line is flashing
KingofGamesYami #14
Posted 20 August 2014 - 09:56 PM
Maybe update it less often? What interval are you using for sleep?
ihatetn931 #15
Posted 20 August 2014 - 10:00 PM
I was using 1, i've changed it to 3, it flashes everytime it updates.

if i comment out these 2 prints


print(getTurbineEu().." EU/T")
print("Rotors: "..getTurbinesRotor().." %")

It dosen't flash, so i assume it's somthing in those functions

It's this function that's causing it to flash


function getTurbinesRotor()
  local result = 0
  for i = 1, 10 do
    result = turbines[ i ].getTurbineOutput()
  end
  return math.floor(result)
end
Edited on 20 August 2014 - 08:04 PM
ihatetn931 #16
Posted 21 August 2014 - 01:40 AM
After a few hours of messing with it, even put the turbines in their own script, i wasn't able to get them to stop flashing so i guess i'm leaving the turbines stats out :-(
Bomb Bloke #17
Posted 21 August 2014 - 01:50 AM
Get all the data you want to print before you clear the screen and print it.

For example, instead of this sort of thing:

term.clear()
print("Rotors: "..getTurbinesRotor().." %")

… do this:

local rotors = getTurbinesRotor()
term.clear()
print("Rotors: "..rotors.." %")

That said, that function looks a bit odd anyway. Did you mean to use this line in it instead?:

result = result + turbines[ i ].getTurbineOutput()
ihatetn931 #18
Posted 21 August 2014 - 02:57 AM
I feel like a moron, that fixed the flashing issue. Thank you

End result


turbines = {
peripheral.wrap("rcsteamturbinetile_0"),
peripheral.wrap("rcsteamturbinetile_1"),
peripheral.wrap("rcsteamturbinetile_2"),
peripheral.wrap("rcsteamturbinetile_3"),
peripheral.wrap("rcsteamturbinetile_4"),
peripheral.wrap("rcsteamturbinetile_5"),
peripheral.wrap("rcsteamturbinetile_6"),
peripheral.wrap("rcsteamturbinetile_7"),
peripheral.wrap("rcsteamturbinetile_8"),
peripheral.wrap("rcsteamturbinetile_9")
}



function getTurbineOp()
return 2000
end

function getTurbinesRotor()
local result = 0
for i = 1 ,10 do
result = turbines[ i ].getTurbineOutput()
end
return math.floor(result)
end

function getTurbineEu()
return math.floor(getTurbineOp() * getTurbinesRotor()/100)
end



local getEuAll = getTurbineEu()
local rAll = getTurbinesRotor()



print(getEuAll.." EU/T All")
print("Rotors: "..rAll)

I dunno how accurate it it and it's kinda hard to tell how accurate the eu readout is, no way to tell in game

adding the result + to

result = turbines[ i ].getTurbineOutput()
Added a ton of eu to the output
Edited on 21 August 2014 - 01:06 AM
Bomb Bloke #19
Posted 21 August 2014 - 03:26 AM
adding the result + to

result = turbines[ i ].getTurbineOutput()
Added a ton of eu to the output

Of course. That's because the version of the function you posted is the equivalent of this:

function getTurbinesRotor()
return math.floor(turbines[ 10 ].getTurbineOutput())
end

Beats me what you want it to do, but that's what it does.
ihatetn931 #20
Posted 21 August 2014 - 04:27 AM
So removing the result + makes it only call the 10th item in the table?
KingofGamesYami #21
Posted 21 August 2014 - 04:31 AM
So removing the result + makes it only call the 10th item in the table?
What you were trying to do was use the "and" thingy. This works way differently than you probably thought. It does call all the items, but does not retain the values (if I'm remembering correctly).

print( 1 and 1 ) --#prints 1
print( 1 and 2 ) --#prints 2 (Thanks Lyqyd)
--#now, as to how you are supposed to use it
print( true and false ) --#false
print( true and true ) --#true
Edited on 21 August 2014 - 11:18 AM
ihatetn931 #22
Posted 21 August 2014 - 04:34 AM
oh i see, ya i thought adding the ands for each would call the value and send it to my print
Lyqyd #23
Posted 21 August 2014 - 06:08 AM

print( 1 and 2 ) --#prints 1

That would print 2.