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

making a Power monitoring programm

Started by Tomgnus, 21 May 2016 - 11:26 PM
Tomgnus #1
Posted 22 May 2016 - 01:26 AM
hi need som help with my program when i run it i get this error:
bios:14: [string "prog"]:19 '=' expected
what can be wrong?

--peripheral warp--
r1 = peripheral.warp("tile_thermalexpansion_cell_resonant_name_0")
d1 = peripheral.warp("tile_thermalexpansion_dynamo_magmatic_name_0")
f1 = peripheral.warp("tile_thermalexpansion_machine_furnace_name_0")
while true do
levelr1 = r1.getEnergyStored()
levelr1max = r1.getMaxEnergyStored()
  
leveld1 = d1.getEnergyStored()
leveld1max = d1.getMaxEnergyStored()
d1tick = d1.getEnergyPerTickInfo()
  
term.clear
term.setCursorPos(1,1)
term.setTextColor(colors.white)
print("------CELLS------")
term.setTextColor("colors.green")
  
if levelr1 == levelr1max then
print(">Resonant Cell[01] "..levelr1.." RF -- Full")
else
print(">Resonant Cell[01] "..levelr1.." RF")
end
  
term.setTextColor(colors.white)
print("------DYNAMOS------")
term.setTextColor(colors.blue)
  
if leveld1 == leveld1max then
print(">Magmatic Dynamo"..leveld1.." @ "..d1tick.." RF/t --full")
else
print(">Magmatic Dynamo"..leveld1.." @ "..d1tick.." RF/t")
end
sleep(1)
end
Dragon53535 #2
Posted 22 May 2016 - 01:38 AM
term.clear should be term.clear()
Dog #3
Posted 22 May 2016 - 01:43 AM
You also need to change peripheral.warp to peripheral.wrap - note the 'wrap' vs. your 'warp'
Waitdev_ #4
Posted 22 May 2016 - 02:00 AM
It's peripheral.wrap, not peripheral.warp - notice 'wrap' vs. 'warp'

On that note, check over your code if you ever get an error like this when working with peripherals, or anything really. A lot of the time this can be caused because of a simple typo.
Tomgnus #5
Posted 22 May 2016 - 12:03 PM
hi tnx for the help on that but now i got a error that says:

prog:14: attempt to index ? (a nil value)
Bomb Bloke #6
Posted 22 May 2016 - 12:13 PM
You're trying to treat something that isn't a table as if it were a table. This'll likely either be r1, d1, or f1, which may be nil if peripheral.wrap() fails to find any of the peripherals you've named.
Tomgnus #7
Posted 22 May 2016 - 12:18 PM
starting to get mad xD :P/> now i only get the
——CELLS——
prog:22: Expected a number
Bomb Bloke #8
Posted 22 May 2016 - 01:31 PM
"colors.green", in quotes like that, is a string - not a number.
Tomgnus #9
Posted 22 May 2016 - 04:31 PM
Awsome it works now thx so mutch for the help guys :D/>