nezd 2 Posted May 6, 2016 Share Posted May 6, 2016 Hi!(again) My program for robot(flashed in eeprom) dont work and causes error i typed in topic title. Here is the code: robot = component.proxy(component.list("robot")()) rs = component.proxy(component.list("redstone")()) function getBatteryPercent () local percent = computer.energy() * 100 / computer.maxEnergy() return percent end function wait(seconds) local begin = os.time() repeat computer.pullSignal(0.05) until os.time() - begin >= seconds end while true do robot.turn(true) robot.turn(true) robot.move(1) while robot.compare() ~= true do robot.move(3) if robot.detect(5) == true then robot.turn(false) robot.swing() robot.turn(true) end if robot.detect(4) == true then robot.turn(true) robot.swing() robot.turn(false) end end robot.turn(true) robot.move(0) robot.turn(true) while true do if redstone.getInput(1) > 0 then if getBatteryPercent() < 20.0 then rs.setOutput(0, 15) else rs.setOutput(0, 0) end wait(60) else robot.move(3) end end end Quote Link to post Share on other sites
0 Solution Log 16 Posted May 7, 2016 Solution Share Posted May 7, 2016 You forgot to specify the direction in a functions swing() and compare() Ðnd the robot can not move to the sides 4 and 5, for this it is necessary to turn to left/right. Quote Link to post Share on other sites
0 nezd 2 Posted May 7, 2016 Author Share Posted May 7, 2016 On 5/7/2016 at 6:11 AM, Log said: You forgot to specify the direction in a functions swing() and compare() Ðnd the robot can not move to the sides 4 and 5, for this it is necessary to turn to left/right. What do you mean about sides 4 and 5? There is no code thats moves it to this sides. Quote Link to post Share on other sites
0 Log 16 Posted May 7, 2016 Share Posted May 7, 2016 Only this way: Reveal hidden contents robot = component.proxy(component.list("robot")()) rs = component.proxy(component.list("redstone")()) function getBatteryPercent() return computer.energy() * 100 / computer.maxEnergy() end function wait(seconds) local begin = os.time() repeat computer.pullSignal(0.05) until os.time() - begin >= seconds end while true do robot.turn(true) robot.turn(true) robot.move(1) while not robot.compare(3) do robot.move(3) robot.turn(false) robot.swing(3) robot.turn(true) robot.turn(true) robot.swing(3) robot.turn(false) end robot.turn(true) robot.move(0) robot.turn(true) while true do if rs.getInput(1) > 0 then if getBatteryPercent() < 20 then rs.setOutput(0, 15) else rs.setOutput(0, 0) end wait(60) else robot.move(3) end end end Quote Link to post Share on other sites
Hi!(again)
My program for robot(flashed in eeprom) dont work and causes error i typed in topic title.
Here is the code:
Link to post
Share on other sites