i = 1
if 1 = 1 then
--this is where I would want it to terminate it
else
print("NO!")
end
Lua question
#1
Posted 21 January 2013 - 06:45 PM
#2
Posted 21 January 2013 - 06:48 PM
If so give break a try. like this maybe. (not 100% sure, but it's worth a shot)
i = 1
if i == 1 then
break --this is where I would want it to terminate it
else
print("NO!")
end
Don't listen to this post. I made a mistake and there are better ways below:)
#3
Posted 21 January 2013 - 06:50 PM
another way to do it though would be just add sleep(0) in there. might not be a great way, but it'd work.
i = 1
if i == 1 then
sleep(0) --this is where I would want it to terminate it
else
print("NO!")
end
#4
Posted 21 January 2013 - 06:51 PM
Willibilly19, on 21 January 2013 - 06:50 PM, said:
You are able to edit your posts to make such corrections.
#5
Posted 21 January 2013 - 06:55 PM
Willibilly19, on 21 January 2013 - 06:48 PM, said:
If so give break a try. like this maybe. (not 100% sure, but it's worth a shot)
i = 1
if i == 1 then
break --this is where I would want it to terminate it
else
print("NO!")
end
if somevar = true then if permission == true then -- Stuff else -- This happens if you want to exit out of the if statement (Optional) end end
#6
Posted 21 January 2013 - 06:57 PM
brett122798, on 21 January 2013 - 06:55 PM, said:
Uhh.. are you sure you can use break in an if statement? Did you want to get out of the if statement, or exit the program? If it's the first thing I said.. you could do this:
No, you can't it was a mistake. I just woke up (good excuse?
#7
Posted 21 January 2013 - 06:59 PM
Willibilly19, on 21 January 2013 - 06:57 PM, said:
brett122798, on 21 January 2013 - 06:55 PM, said:
No, you can't it was a mistake. I just woke up (good excuse?
#8
Posted 21 January 2013 - 07:09 PM
fuel = turtle.getFuelLevel()
function checkfuel()
if fuel < 100 then
--terminate
else
return
end
end
mining stuff
checkfuel()
Now that I'm thinking about it, it is probably pretty dumb to terminate the program instead of waiting for fuel, but now I'm curious.
#9
Posted 21 January 2013 - 07:12 PM
grand_mind1, on 21 January 2013 - 07:09 PM, said:
fuel = turtle.getFuelLevel() function checkfuel() if fuel < 100 then --terminate else return end end mining stuff checkfuel()Now that I'm thinking about it, it is probably pretty dumb to terminate the program instead of waiting for fuel, but now I'm curious.
fuel = turtle.getFuelLevel()
function checkfuel()
if fuel < 100 then
error("Fuel Ran Out!") --terminate
else
return
end
end
mining stuff
checkfuel()
#10
Posted 21 January 2013 - 07:15 PM
#11
Posted 21 January 2013 - 07:22 PM
brett122798, on 21 January 2013 - 07:12 PM, said:
#12
Posted 21 January 2013 - 07:33 PM
#14
Posted 21 January 2013 - 07:59 PM
#16
Posted 21 January 2013 - 10:43 PM
Ok I want you to do something for me. I want you to try to exit the running program using shell.exit()
Try it in the Lua prompt. What happens?
Answer
Now as for the os.reboot() I'm gunna have to see if I can find the really good explanation that was done a while back in here as to why not to use it...
#17
Posted 21 January 2013 - 10:46 PM
#19
Posted 21 January 2013 - 10:53 PM
There is a cooldown on shutdown/reboots, so there can be performance issues from using either if a computer is doing something important.
Oh, yeah...the shell exit doesn't take effect until after you exit your current program, so it doesn't do what you want. I just meant it doesn't do anything terrible.
Edited by ChunLing, 21 January 2013 - 10:54 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











