- ComputerCraft | Programmable Computers for Minecraft
- → Abstract's Content
Abstract's Content
There have been 7 items by Abstract (Search limited from 20-March 23)
#44263 Rednet help
Posted by Abstract on 25 October 2012 - 05:03 PM in Ask a Pro
Hi everybody
I've played around with rednet a little bit and wrote a little program, which doesn't work correctly.. Here is what it should do:
If it gets the command, it should extend a pisten and with another command it should retract it
Now here's the problem: It only extends and does not retract... here's the code of my receiver computer(id4)
rednet.open("left")
while true do
os.pullEvent()
id,message = rednet.receive()
if message == "on" then
rs.setOutput("back", true)
end
if message == "off" then
rs.setOutput("back", false)
end
end
what is wrong/missing there? I would be glad if someone could help me
I've played around with rednet a little bit and wrote a little program, which doesn't work correctly.. Here is what it should do:
If it gets the command, it should extend a pisten and with another command it should retract it
Now here's the problem: It only extends and does not retract... here's the code of my receiver computer(id4)
rednet.open("left")
while true do
os.pullEvent()
id,message = rednet.receive()
if message == "on" then
rs.setOutput("back", true)
end
if message == "off" then
rs.setOutput("back", false)
end
end
what is wrong/missing there? I would be glad if someone could help me
#1048 Too Long Without Yielding
Posted by Abstract on 22 February 2012 - 03:46 PM in Ask a Pro
Casper7526, on 22 February 2012 - 03:28 PM, said:
When your code just loops endlessly without yielding for a few seconds, you receive that error.
You should use a pullevent to only check when redstone is changed instead.
startup:
You should use a pullevent to only check when redstone is changed instead.
startup:
redstone.setOutput("right", true) while true do event, param = os.pullEvent() if event == "redstone" and redstone.getInput("front") == true then redstone.setOutput("right", false) sleep(10) redstone.setOutput("right", true) end end
Don't know why I've typed everything like you
EDIT: works, had a spelling mistake />
#1041 Too Long Without Yielding
Posted by Abstract on 22 February 2012 - 03:13 PM in Ask a Pro
I need some help with my program. What it should do is,output redstone to the left, if redstone comes from the front, stop outputting redstone to the right wait and reboot. this is my code:
startup:
startup:
while true do shell.run"redside" endredside:
redstone.setOutput("right", true) if redstone.getInput("front", true) then redstone.setOutput("right", false) sleep(10) os.restart() endbut if I reboot now, it works for only a couple of seconds and a error pops up which says 'Too long without yielding'. What did I do wrong?
- ComputerCraft | Programmable Computers for Minecraft
- → Abstract's Content