Jump to content




Immersive Engineering Arc Furnace Program


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

#1 Vingy

  • Members
  • 3 posts

Posted 02 April 2016 - 09:19 AM

I don't really know how to code Lua, but I've been trying to make a program that sets off an alarm when the Arc Furnace runs out of electrodes.
I had several variations, but this was the closest I got .
arc = peripheral.wrap("left")
while
arc.hasElectrodes(false) do
redstone.setOutput("top",true)
end
if arc.hasElectrodes(true) then
redstone.setOutput("top", false)
end

I could get it to run, but it output a redstone signal even if there were electrodes in the furnace. If some of could help me that would be awesome.

#2 moTechPlz

  • Members
  • 40 posts

Posted 02 April 2016 - 05:11 PM

You are on the right track. The error is the function hasElectrodes returns a bool. (true / false) Try it like this :
arc = peripheral.wrap( "left" )
redstone.setOutput( "top", false )
while arc.hasElectrodes( ) do
	sleep( 1 )
end
redstone.setOutput( "top", true )

Edited by moTechPlz, 02 April 2016 - 06:04 PM.


#3 Unknowntissue

  • Members
  • 15 posts

Posted 02 April 2016 - 05:12 PM

I don't really know the api for arc furnaces so if you linked a page with the documentation i can help you better but if i had to take a guess the code should look like this.
arc = peripheral.wrap("left")
while true  do   --# will loop forever. Hold ctrl+ t to stop it
if arc.hasElectrodes() == false then
  redstone.setOutput("top",true)
end
if arc.hasElectrodes()== true then
   redstone.setOutput("top", false)
end
end


#4 moTechPlz

  • Members
  • 40 posts

Posted 02 April 2016 - 06:38 PM

I have tested it and the function hasElectrodes only returns true when it has all three electrodes. Any less and it will return false.

snip of sourcecode from IE
case 6://hasElectrodes
   return new Object[]{te.electrodes[0] && te.electrodes[1] && te.electrodes[2]};

I think you need to use getElectrode.

Edited by moTechPlz, 02 April 2016 - 07:58 PM.


#5 Vingy

  • Members
  • 3 posts

Posted 02 April 2016 - 07:14 PM

View PostmoTechPlz, on 02 April 2016 - 05:11 PM, said:

You are on the right track. The error is the function hasElectrodes returns a bool. (true / false) Try it like this :
arc = peripheral.wrap( "left" )
redstone.setOutput( "top", false )
while arc.hasElectrodes( ) do
	sleep( 1 )
end
redstone.setOutput( "top", true )

A problem I found is that the alarm doesn't turn off when I put electrodes in

Edited by Vingy, 02 April 2016 - 08:15 PM.


#6 moTechPlz

  • Members
  • 40 posts

Posted 02 April 2016 - 07:44 PM

Something like this, you can modify, put it into a eternal loop, etc as you wish.

redstone.setOutput( "top", false )

furnace = peripheral.find( "IE:arcFurnace" )
repeat
  sleep( 1 ) --# dont overload the system
  nElectrodes = 3
  for nIndex = 1, 3 do
	if furnace.getElectrode( nIndex ).damage == nil then
	  nElectrodes = nElectrodes - 1
	end
  end
until nElectrodes == 0

redstone.setOutput( "top", true )

Edited by moTechPlz, 03 April 2016 - 05:31 PM.


#7 moTechPlz

  • Members
  • 40 posts

Posted 02 April 2016 - 08:28 PM

Quote

A problem I found is that the alarm doesn't turn off when I put electrodes in

Because the code i posted ends at that point. You can do a eternal loop as Unknowntissue posted.

Edited by moTechPlz, 02 April 2016 - 08:29 PM.


#8 Vingy

  • Members
  • 3 posts

Posted 02 April 2016 - 11:16 PM

View PostmoTechPlz, on 02 April 2016 - 08:28 PM, said:

Quote

A problem I found is that the alarm doesn't turn off when I put electrodes in

Because the code i posted ends at that point. You can do a eternal loop as Unknowntissue posted.

How would I implement that into your code?

#9 moTechPlz

  • Members
  • 40 posts

Posted 03 April 2016 - 10:39 AM

redstoneOutput = "top"
furnace = peripheral.find( "IE:arcFurnace" )
while true do
  nElectrodes = 3
  for nIndex = 1, 3 do
	if furnace.getElectrode( nIndex ).damage == nil then
	  nElectrodes = nElectrodes - 1
	end
  end
  if nElectrodes == 0 then redstone.setOutput( redstoneOutput, true )
  else redstone.setOutput( redstoneOutput, false ) end
  sleep( 1 )
end

Edited by moTechPlz, 03 April 2016 - 05:32 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users