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

Help with Thermal Expansian and CC

Started by steadw, 08 April 2014 - 10:42 PM
steadw #1
Posted 09 April 2014 - 12:42 AM
So I am as new as it gets to ComputerCraft and coding in general so I dont even know if this is possible but I wanted to know if it is and how I could do it:
[indent]Does anyone know how to get an advanced computer to send a redstone signal when an energy cell from thermal expansion has a certain energy level then stop sending when it hits another level and then only resend the signal when it re-hits the original level?
for example send the signal when power level is at 40,000,000 and stop when power level is at 100,000. I don't know how to get it so that it sends at 40,000,000 and stop at 100,000 then doesnt restart untill it hits 40,000,000 again. I don't want it to send the signal when its charging.
Thanks[/indent]


CometWolf #2
Posted 09 April 2014 - 02:36 PM
If you want it to start sending a signal at 40m and not stop until it hits 100m, wouldn't that mean it needs to send a signal while charging…?
I don't want it to send the signal when its charging.

Anyways, this should be fairly simple. Something like

local eCell = peripheral.wrap"top"
local fullCharged = false
while true do -- constant program loop
  rs.setOutput("back",true)
  while eCell.getStoredEnergy() < 10000000 do --idk what the actual function name is, cause openP >.>
    sleep(1)
  end
  rs.setOutput("back",false)
  while eCell.getStoredEnergy() > 4000000 do
    sleep(1)
  end
end
I'd suggest you read up on peripheral usage, loops, and openP.
http://computercraft.info/wiki/Peripheral_%28API%29
http://computercraft.info/wiki/Loops
http://www.computercraft.info/forums2/index.php?/topic/13063-mc-16x-openperipheral/
steadw #3
Posted 09 April 2014 - 03:22 PM
Thankyou, this helps a lot, I meant I didnt want I wanted it to stop sending the signal as it charges back from 100,000 to 40,000,000 if that makes sense?
so send at 40M
stop at 100K
re-send when it hits 40M again
and just loop that

Also where would I put a print("Energy Required, Sending Signal") or ("Insufficient Energy, Charging")
CometWolf #4
Posted 09 April 2014 - 03:50 PM
The code i posted was more of an example than a fully working code, although i guess you might give it a go. I added some comments so you can understand better what it's doing.

local eCell = peripheral.wrap"top" --wrap the energy cell as a peirpheral
while true do -- constant program loop
  rs.setOutput("back",true) --activates the signal
  while eCell.getStoredEnergy() < 10000000 do --this loop just waits until the energy is not less than 100m
    sleep(1)
  end
  rs.setOutput("back",false) --deavtivates the signal
  while eCell.getStoredEnergy() > 4000000 do -- this loop waits until the energy is less than 40m
    sleep(1)
  end
end
steadw #5
Posted 09 April 2014 - 03:52 PM
Ok thankyou, that is a real help, ive also read some of those links you added and they help as well, i think my problem is now solved
Thanks :)/>
steadw #6
Posted 09 April 2014 - 03:58 PM
Im getting this error code:
startup:4: Parameter 'slot' is missing

Any idea what is wrong, I used the second code u put in and followed it exactly other than a change in energy values
CometWolf #7
Posted 09 April 2014 - 04:06 PM
It's probably the openP stuff, like i said idk what the actual function name is. I just took a guess. If you look around in the openP thread i linked, there should be a mention of a docs program. Have a look through that and see what you can find.
blipman17 #8
Posted 09 April 2014 - 05:09 PM
http://www.dnacraft.info/open.info/web/app.php/openperipheral/documentation/thermalexpansion/redstone-energy-cell

for some documentation
apemanzilla #9
Posted 09 April 2014 - 05:41 PM
A good amount of information there will be out of date. I recommend you use the in-game documentation available through this command:

openp/docs <peripheral side/name> [method name]
Running it without supplying the method name shows available methods. Running it with one will describe and show the usage of the given method.
Edited on 09 April 2014 - 03:41 PM
blipman17 #10
Posted 10 April 2014 - 10:01 AM
I know, but a lot is still valid. But for the energy-cell, I used this method like 5 days ago and I can say that it is still working.