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

redstone to solar panels

Started by Kiomadria, 13 January 2015 - 12:58 AM
Kiomadria #1
Posted 13 January 2015 - 01:58 AM
I am working on creating a program that will monitor the extra utilites solar pannels and when they are full emit a redstone signal. When I run it I get error of ")" expected on the line of redstone.Output. I am guessing it is becuase of multiple perpherials but I don't know how to fix it


term.clear()
local modem = peripheral.wrap("left")

local peripherals = modem.getNamesRemote()
local amount = 0
local capacity = 0

local p = {
		solar = {};
}

for index, connection in pairs( peripherals) do
	if peripheral.getType(connection) == "powered_tile" then
		--print(peripheral.getType(connection), index)
		--print("Was added!")
		p.solar[#p.solar+1] = peripheral.wrap(connection)	
	else
		print(peripheral.getType(connection))
		print("Was not added!")
	end
end



while true do

	
	for index, energyCell in pairs(p.solar) do
		term.setCursorPos(index +1,1)
		local nEo = amount or 0
		if energyCell.getEnergyStored then
			amount = amount + energyCell.getEnergyStored()
		end
		if energyCell.getMaxEnergyStored then
			capacity = capacity + energyCell.getMaxEnergyStored()
		end
		nP = math.floor((amount/capacity)*100)
		energy = amount.."/"..capacity.." "..nP.."%"
		clock = textutils.formatTime(os.time(),false)
		print(clock)
		
		if nEo < amount then
			print("Solar Panel ", index-1, " is Charging   ")
		elseif nEo > amount then
   		 print("Solar Panel ", index-1, " is Discharging")
		else
			print("No change  ")
		end	
		
		if amount <1 then
			--print ("yes")
			redstone.setOutput("left" false)
		elseif amount >= capacity then
			--print ("No")
			redstone.setOutput("left" true)
		
		end
		sleep(1)
		
	end
end
Lyqyd #2
Posted 13 January 2015 - 02:23 AM
You forgot your comma.


redstone.setOutput("left", false)
Kiomadria #3
Posted 13 January 2015 - 04:18 AM
Thank you