while not night do --Blah blah night = true endChanging night to true breaks out of the loop anyways. So you in essence don't have any loops at all.
- ComputerCraft | Programmable Computers for Minecraft
- → Dragon53535's Content
Dragon53535's Content
There have been 2 items by Dragon53535 (Search limited from 29-March 23)
#279543 How do I get a boolean to become false? I've tried everything and it does...
Posted by Dragon53535 on 26 November 2020 - 10:54 PM in Ask a Pro
That's mostly because of the way your code is set up. You actually don't have any while loops.
#279539 How do I get a boolean to become false? I've tried everything and it does...
Posted by Dragon53535 on 20 November 2020 - 08:00 PM in Ask a Pro
Lupus you're getting rusty...
All of the lines marked as ISSUE are creating new variables inside the loops. They are not modifying the earlier variables as you used the local keyword. Remove the local keyword and you're in business.
Remember, use local only when you're creating the variable to start with. If you use it afterwards, the code just makes a new variable and hides the earlier one.
local night = false local nightmode = false while not night do rs.setOutput("right", true) rs.setOutput("back", false) sleep(15) rs.setOutput("right", false) rs.setOutput("back", false) sleep(3) rs.setOutput("right", false) rs.setOutput("back", true) sleep(15) rs.setOutput("right", false) rs.setOutput("back", false) rs.setOutput("left", false) sleep(3) if rs.getInput("front") then break end local night = true -- ISSUE local nightmode = true --ISSUE end while not nightmode do rs.setOutput("right", false) rs.setOutput("back", false) sleep(1) rs.setOutput("left", true) if rs.getInput("front") == false then break end local nightmode = not nightmode --ISSUE local night = not night --ISSUE end
All of the lines marked as ISSUE are creating new variables inside the loops. They are not modifying the earlier variables as you used the local keyword. Remove the local keyword and you're in business.
Remember, use local only when you're creating the variable to start with. If you use it afterwards, the code just makes a new variable and hides the earlier one.
- ComputerCraft | Programmable Computers for Minecraft
- → Dragon53535's Content