|
| 15 Nov 2012 08:49 PM |
You know how in batch, you can use the goto 5 :5 and it will skip over a section of script? is there a way to do this in lua? |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 15 Nov 2012 08:50 PM |
for n=1,10 do if(num~=5)then print(n) end end
|
|
|
| Report Abuse |
|
|
Octopus
|
  |
| Joined: 26 Feb 2008 |
| Total Posts: 460 |
|
|
| 15 Nov 2012 08:51 PM |
| Not really. In lua, you create functions and call them. You basically make a list and pick out certain ones at certain times. So in theory yes, but actually no. |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2012 08:52 PM |
| so is n num? and is it a random from 1-10? |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2012 08:52 PM |
goto is usually universally condemned as bad practice. You should not ever have to write code that uses GOTOs.
You should definitely be using a different sort of code structure if you're finding yourself needing them. |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 15 Nov 2012 08:54 PM |
| You need a tutorial on for loops, don't you? :P |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2012 08:54 PM |
e.e it's part of a coding language called batch look it up my friend |
|
|
| Report Abuse |
|
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 15 Nov 2012 08:56 PM |
I know what batch is, I've never coded in it though. I figured you knew what a for loop was to, since you obviously know batch. |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2012 08:57 PM |
| I havent ever used a for loop in any of the languages I know. Ever. |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2012 08:58 PM |
| the comment on looking it up wasnt @u top |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 15 Nov 2012 09:02 PM |
Mmk, so..
for -- defines you're about to use a for loop Number=1 -- defines what variable you're using to track the loop, and where you're starting. In this case Number is the variable, and 1 is the start
So far we have for Number=1
Next we need a comma, and what number we are ending at. I'm going to stop the loop at 4.
for Number=1,4
Now we need another comma, and how we're going in to get to our number 4.
for Number=1,4,.5 -- Counting by .5, so it will start at 1, then go to 1.5, 2, etc
Add do after this, so the code knows we're ending our for loop arguments
for Number=1,4,.5 do print("I'm number "..Number.."!") -- Just a simple print statement end -- This will end our for loop |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2012 09:22 PM |
| Thank you, i think I get it now. |
|
|
| Report Abuse |
|
|