I am using a redsotne cable that is connected to my computer or a bundled cable.
So my script goes as follows
if rs.testBundledInput("left",colours.black) then
print("Induction furnace is running")
end
So it works fine and all but,
as i am using the Eu detector cable at the bottom of my Induction furnace so that when Eu is
flowing through it emits a signal to my computer.
however to keep the furnace running at 100% heat it every now and then requires a burst of Eu.
And i dont want my Computer to display "Induction furnace is on" everytime it just gets redsonte for 1
second.
I think i have a selution to my problem but dont know how to script it so what better place to ask for help than here.
I was thinking of maing it if the computer receives a signal for 3 second or more it should
print("Inductionfurnace is running")
oherwise it should desplay nothing.
Any script that might be used for this?
please help
Sasuke
(Qeustion using a timing)
Started by Uch1ha_Sasuke, Jun 08 2012 01:31 PM
4 replies to this topic
#1
Posted 08 June 2012 - 01:31 PM
#2
Posted 08 June 2012 - 05:07 PM
Ok what you have to check is simple you have to only execute the code if the input is not triggering. So what you can do is that:
You may have to change the delay time. Another way of doing it is to start a loop that constantly checks whether the signal is still on and if so for at least n milliseconds print the line.
In code it will look like so:
Keep in mind this code is untested! But it should work.
if rs.testBundledInput("left", colors.black) then
//Ok signal is on
sleep(3)
if rs.testBundledInput("left", colors.black) then
//Signal is still on
print("Induction furnace is running")
end
end
You may have to change the delay time. Another way of doing it is to start a loop that constantly checks whether the signal is still on and if so for at least n milliseconds print the line.
In code it will look like so:
if rs.getBundledInput("left", colors.black) then
i = os.clock()
on = true
while on do
on = rs.getBundledInput("left", colors.black)
if (os.clock() - i) >= 3000 then
on = false
print("Induction furnace running")
end
sleep(0.1)
end
end
Keep in mind this code is untested! But it should work.
#3
Posted 08 June 2012 - 05:51 PM
Here's another way of doing it:
Any interruptions in the redstone signal between the start of the timer and the end will cause the timer check to fail, so we know that it was continuously on for three seconds rather than just on at the start of the three seconds and on also at the end of three seconds. This code assumes only one redstone input.
local inputSide = "right"
while true do
e, p1 = os.pullEvent()
if e == "redstone" then
if rs.getInput(inputSide) then
runTimer = os.startTimer(3)
else
runTimer = nil
end
elseif e == "timer" then
if p1 == runTimer then
print("Furnace is running!")
end
end
end
Any interruptions in the redstone signal between the start of the timer and the end will cause the timer check to fail, so we know that it was continuously on for three seconds rather than just on at the start of the three seconds and on also at the end of three seconds. This code assumes only one redstone input.
#5
Posted 08 June 2012 - 06:01 PM
MysticT, on 08 June 2012 - 05:55 PM, said:
Well, I don't know why you made two posts with the same question, but here's a link to the other one, where I already answered this: link
Heh. I saw this post first as I was going through the new topics. Interesting that we came up with identical solutions independently. Yours does, however, account for multiple inputs, while mine does not.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











