This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jay5476's profile picture

Way of showing failure

Started by jay5476, 16 August 2012 - 09:16 AM
jay5476 #1
Posted 16 August 2012 - 11:16 AM
I just had an idea for a way to show an error within a program
In a pre determined program in the lua program it's return false
Eg.

Turtle.turnLeft()
Return true
Else return false
But what about add abit so that it constly opens modems and closes them
if it it's a wireless turtle please tell me if you think this is a good idea
Pinkishu #2
Posted 16 August 2012 - 01:19 PM
Uhm I have no clue what you're trying to say?
ElvishJerricco #3
Posted 17 August 2012 - 12:38 AM
Reading this made literally no sense. The syntax of that program wouldn't work no matter how the Turtle.turnLeft() function could be changed to work.
nitrogenfingers #4
Posted 17 August 2012 - 12:54 AM
This is almost entirely extrapolation on my part but are you trying to say whenever a wireless turtle calls a function that returns false you fire off a rednet message informing… someone nearby that the turtle was unable to move?


function meanderForwads()
  if not turtle.forward() and peripheral.getType("right") == "modem" then
    rednet.open("right")
    rednet.broadcast("I'm having engine troubles captain!")
    rednet.close("right")
  end
end

Be it that or something else you had in mind the best way to test if it's a good idea is to do it; Think about what you want to do and why, then have a go implementing it and see what happens!
D3matt #5
Posted 17 August 2012 - 06:42 AM
I'm givin' her all she's got, captain!
Luanub #6
Posted 17 August 2012 - 06:51 AM
The turtle movements already return a bool stating if they fail or not. Just utilize it in an if statement like nitrogenfingers did above.