sigle time execution in a loop. HELP!
#1
Posted 13 May 2017 - 10:56 AM
With regards
Qwerty.
#2
Posted 13 May 2017 - 03:09 PM
#3
Posted 13 May 2017 - 06:05 PM
Edited by Lupus590, 13 May 2017 - 06:06 PM.
#4
Posted 14 May 2017 - 03:17 AM
with regards
Qwerty
#5
Posted 14 May 2017 - 05:12 AM
peripheral.find("modem", rednet.open) while true do if not rs.getInput("left") then rednet.send(1, "") print("Message sent...") end os.pullEvent("redstone") end
If you truly want it to send one message, full stop, then stick a "break" after the "print" line.
#6
Posted 14 May 2017 - 04:05 PM
Bomb Bloke, on 14 May 2017 - 05:12 AM, said:
peripheral.find("modem", rednet.open) while true do if not rs.getInput("left") then rednet.send(1, "") print("Message sent...") end os.pullEvent("redstone") end
If you truly want it to send one message, full stop, then stick a "break" after the "print" line.
Edited by qwerty, 14 May 2017 - 04:11 PM.
#7
Posted 14 May 2017 - 04:19 PM
Edit: Never mind it crashes minecraft if removed.
Edited by qwerty, 14 May 2017 - 04:26 PM.
#8
Posted 14 May 2017 - 04:27 PM
qwerty, on 14 May 2017 - 04:19 PM, said:
#9
Posted 14 May 2017 - 05:08 PM
SquidDev, on 14 May 2017 - 04:27 PM, said:
qwerty, on 14 May 2017 - 04:19 PM, said:
#10
Posted 14 May 2017 - 11:23 PM
qwerty, on 14 May 2017 - 05:08 PM, said:
See here, then. Basically the line translates to "wait here and do nothing until a redstone signal changes".
qwerty, on 14 May 2017 - 05:08 PM, said:
That's what the code I showed you does. Hard to comment on your modified version without seeing it.
#11
Posted 15 May 2017 - 12:37 PM
with regards
Qwerty
#12
Posted 15 May 2017 - 03:09 PM
qwerty, on 15 May 2017 - 12:37 PM, said:
with regards
Qwerty
Adapting BomeBlokes code:
peripheral.find("modem", rednet.open) local previousState while true do if previousState ~= rs.getInput("left") then previousState = rs.getInput("left") rednet.send(1, "") print("Message sent...") end os.pullEvent("redstone") end
Edited by Lupus590, 15 May 2017 - 03:10 PM.
#13
Posted 15 May 2017 - 04:28 PM
Lupus590, on 15 May 2017 - 03:09 PM, said:
qwerty, on 15 May 2017 - 12:37 PM, said:
with regards
Qwerty
Adapting BomeBlokes code:
peripheral.find("modem", rednet.open) local previousState while true do if previousState ~= rs.getInput("left") then previousState = rs.getInput("left") rednet.send(1, "") print("Message sent...") end os.pullEvent("redstone") end
Edited by qwerty, 15 May 2017 - 04:30 PM.
#14
Posted 15 May 2017 - 05:30 PM
qwerty, on 15 May 2017 - 04:28 PM, said:
what does the code do? explain what is not working.
Edited by Lupus590, 15 May 2017 - 05:31 PM.
#16
Posted 16 May 2017 - 02:53 AM
houseofkraft, on 15 May 2017 - 08:07 PM, said:
What is the point in using a repeat loop? It would just end up being trading one infinite loop for another.
qwerty, on 14 May 2017 - 03:17 AM, said:
with regards
Qwerty
From my interpretation of what you are wanting to do, it would be something more like this:
local sent = false --# variable to keep track of whether or not we've sent a message peripheral.find("modem", rednet.open) while true do if redstone.getInput("left") == false then if sent == false then --# only send the message if the variable is false sent = true rednet.send(1,"") print("Message sent...") end else sent = false end os.pullEvent("redstone") --# pullEvent to make it not constantly check end
For future reference... "it just doesn't want to work... " does not help us help you. Please give how it does not work. Give what it does, such as it errors, or it doesn't send a message (if it doesn't send a message is it printing that a message is sent). We can't begin to help you fix the problem if you don't tell us the problem.
Edited by valithor, 17 May 2017 - 03:28 AM.
#17
Posted 16 May 2017 - 01:42 PM
Lupus590, on 15 May 2017 - 05:30 PM, said:
qwerty, on 15 May 2017 - 04:28 PM, said:
what does the code do? explain what is not working.
I even added an os.pullEvent printer but that showed nothing except key strokes.
Edited by qwerty, 16 May 2017 - 02:02 PM.
#18
Posted 16 May 2017 - 02:15 PM
valithor, on 16 May 2017 - 02:53 AM, said:
houseofkraft, on 15 May 2017 - 08:07 PM, said:
What is the point in using a repeat loop? It would just end up being trading one infinite loop for another.
qwerty, on 14 May 2017 - 03:17 AM, said:
with regards
Qwerty
From my interpretation of what you are wanting to do, it would be something more like this:
local sent = false --# variable to keep track of whether or not we've sent a message peripheral.find("modem", rednet.open) while true do if redstone.getInput("left") == false then if sent == false then --# only send the message if the variable is false sent = true rs.send(1,"") print("Message sent...") end else sent = false end os.pullEvent("redstone") --# pullEvent to make it not constantly check end
For future reference... "it just doesn't want to work... " does not help us help you. Please give how it does not work. Give what it does, such as it errors, or it doesn't send a message (if it doesn't send a message is it printing that a message is sent). We can't begin to help you fix the problem if you don't tell us the problem.
Best regards
qwerty
Edited by qwerty, 16 May 2017 - 02:16 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users