Jump to content




Help with Thermal Expansian and CC

peripheral

  • You cannot reply to this topic
9 replies to this topic

#1 steadw

  • Members
  • 4 posts

Posted 08 April 2014 - 11:42 PM

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]




#2 CometWolf

  • Members
  • 1,283 posts

Posted 09 April 2014 - 01: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...?

Quote

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...heral_%28API%29
http://computercraft.info/wiki/Loops
http://www.computerc...openperipheral/

#3 steadw

  • Members
  • 4 posts

Posted 09 April 2014 - 02: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")

#4 CometWolf

  • Members
  • 1,283 posts

Posted 09 April 2014 - 02: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


#5 steadw

  • Members
  • 4 posts

Posted 09 April 2014 - 02: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 :)

#6 steadw

  • Members
  • 4 posts

Posted 09 April 2014 - 02: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

#7 CometWolf

  • Members
  • 1,283 posts

Posted 09 April 2014 - 03: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.

#8 blipman17

  • Members
  • 92 posts

Posted 09 April 2014 - 04:09 PM

http://www.dnacraft....one-energy-cell

for some documentation

#9 apemanzilla

  • Members
  • 1,421 posts

Posted 09 April 2014 - 04:41 PM

View Postblipman17, on 09 April 2014 - 04:09 PM, said:

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 by Apemanzilla, 09 April 2014 - 04:41 PM.


#10 blipman17

  • Members
  • 92 posts

Posted 10 April 2014 - 09: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users