1 posts
Posted 13 March 2013 - 04:53 PM
programming, need help writing it. hello I'm new to coding specially in computercraft and the forums in general; this i know will be a very simple program i'm sure but i cant seem to get it. i'm trying to make the computer detect a redstone signal from the press of a button on the wall that then will use "redpulse" and send the pulses to the frame motor 3 times at a rate of .85 and raise the frames. id love any help with it.
8543 posts
Posted 13 March 2013 - 04:56 PM
Split into new topic. A title was provided for you.
2151 posts
Location
Auckland, New Zealand
Posted 13 March 2013 - 06:20 PM
This has been asked before, but I'll get you started.
while true do
var event, side = os.pullEvent("redstone") -- Detect the button redstone signal
local frameSide = "left" --change this to what ever side the frame redstone wire is
local function pulse(delay) --basically the same as 'redpulse'
redstone.setOutput (frameSide, true)
sleep(delay)
redstone.setOutput (frameSide, false)
sleep(delay)
end
pulse(0.85)
pulse(0.85)
pulse(0.85)
end
2005 posts
Posted 13 March 2013 - 11:31 PM
You might want to move the local declarations of fixed variables (framSide and pulse()) outside of the loop, so they don't get reallocated every time.
2151 posts
Location
Auckland, New Zealand
Posted 13 March 2013 - 11:52 PM
You might want to move the local declarations of fixed variables (framSide and pulse()) outside of the loop, so they don't get reallocated every time.
Yea, It was just a quick demo I made in a minute or two.