Posted 14 March 2014 - 06:02 PM
Hello, i'm very new to ComputerCraft and this is my first little program that shows the Energy stored in an Energycell (Thermalexpansion) with a percentage on an Monitor.
For Example:
Energycell 2: 400000 Redstone Flux 100%
Energycell 3: 300000 Redstone Flux 75%
Energycell 4: 100000 Redstone Flux 25%
Energycell 5: 150000 Redstone Flux 37,5%
Code (http://pastebin.com/r2GTYstx):
My Problem is that i get this Error: bios:339: [string "startup"]:4: '}' expected (to close '{' at line 2)
Where is my Failure?
PS: Sorry for my bad english
For Example:
Spoiler
Energycell 1: 200000 Redstone Flux 50%Energycell 2: 400000 Redstone Flux 100%
Energycell 3: 300000 Redstone Flux 75%
Energycell 4: 100000 Redstone Flux 25%
Energycell 5: 150000 Redstone Flux 37,5%
Code (http://pastebin.com/r2GTYstx):
-- Energycells 1-5
con = {
peripheral.wrap("cofh_thermalexpansion_energycell_17")
peripheral.wrap("cofh_thermalexpansion_energycell_18")
peripheral.wrap("cofh_thermalexpansion_energycell_19")
peripheral.wrap("cofh_thermalexpansion_energycell_20")
peripheral.wrap("cofh_thermalexpansion_energycell_21")
}
-- Monitor
local mon = peripheral.wrap('right')
-- Reading the Amount of Energy
function getEnergy(Str)
return con[Str].getEnergyStored("unknown")
end
-- Reading Max Energy
function getMaxEnergy(Str)
return con[Str].getMaxEnergyStored("unknown")
end
-- Giving out a Percentage
function percent(minVal, maxVal)
return math.floor((minVal/maxVal)*100)
end
-- Displaying the Amount of Energy and the Percentage of Energy on an monitor
while true do
for i = 1, 5 do
mon.setCursorPos((i*2)-1, 1)
mon.write("Energycell "..i..": "..getEnergy(i).." Redstone Flux "..percent(getEnergy(i), getMaxEnergy(i)).."%")
sleep(1)
end
end
My Problem is that i get this Error: bios:339: [string "startup"]:4: '}' expected (to close '{' at line 2)
Where is my Failure?
PS: Sorry for my bad english