Is it possible to recognise the length of a redstone pulse? So in other words if a pulse is received for 3 seconds it will recognise and translate that as say for example a word and if its shorter it wont print/recognise it?
If thats possible how would you code the computer to translate the pulse?
[Question] Recognising the length of redstone pulse
Started by Stormkrow, Jun 15 2012 10:44 AM
3 replies to this topic
#1
Posted 15 June 2012 - 10:44 AM
#2
Posted 15 June 2012 - 11:40 AM
Well, you could periodically check for redstone activity. Like:
However, if you simply want to communicate between computers, you should use wireless modems and the rednet api.
-- wait for pulse while not redstone.getInput(side) do sleep(0.5) end -- count on time local duration = 0 while redstone.getInput(side) do duration = duration + 0.5 sleep(0.5) end -- duration now holds the pulse length in seconds.
However, if you simply want to communicate between computers, you should use wireless modems and the rednet api.
#3
Posted 15 June 2012 - 03:26 PM
Im confused why everyone uses redstone and not rednet... Rednet is so much easier... Check out the api at the wiki. It will save your life
#4
Posted 15 June 2012 - 04:23 PM
The best way to do it would be with "redstone" events:
Rednet is for communication between computers, redstone is for redstone input and output, and it's usefull to "communicate" with other mods or things that work with redstone. They are two different things.
local sSide = "left"
local bPulseOn = false
local nStart
while true do
os.pullEvent("redstone")
if rs.getInput(sSide) ~= bPulse then
if bPulseOn then
local duration = os.clock() - nStart
bPulseOn = false
print("Pulse duration: ", duration)
else
nStart = os.clock()
bPulseOn = true
end
end
end
It's efficient and will give you the pulse duration in milliseconds.
tfoote, on 15 June 2012 - 03:26 PM, said:
Im confused why everyone uses redstone and not rednet... Rednet is so much easier... Check out the api at the wiki. It will save your life
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











