Luckyxero
|
  |
| Joined: 26 Feb 2014 |
| Total Posts: 505 |
|
|
| 14 Oct 2017 01:22 PM |
do print("hi") end
Apparently that is working. Why? What is "do end"? |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2017 01:29 PM |
look in a dictionary for "do" thats it |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 14 Oct 2017 01:29 PM |
I guess "do" is just formal for following certain conditional statements but doesn't require those statements to work on it's own
lua is weird |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2017 01:31 PM |
thats pretty interesting actually looks like i will use do end to stretch out my scripts lolll |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2017 01:31 PM |
stackoverflow . com / questions /23895406/ why-use-a-do-end-block-in-lua
basically for organization and having non-colliding variables.
local x=0 do local x=1 print(x) end
print(x) |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2017 01:33 PM |
" basically for organization and having non-colliding variables.
local x=0 do local x=1 print(x) end
print(x)"
wouldnt having the "do" follow the script the same way anyways? |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 14 Oct 2017 02:18 PM |
| so its like curly brackets in languages like java/c#? |
|
|
| Report Abuse |
|
|
Ezuras
|
  |
| Joined: 07 Nov 2012 |
| Total Posts: 8768 |
|
|
| 14 Oct 2017 02:35 PM |
@Horrible_Pun
No.
Say I declare a variable within a function, it'll only be accessed inside of that function, and no other function within that script will be able to read that variable without declaring it again.
For example,
local Var = true -- declare a variable outside of a code block local IsTrue = false
if Var == true then isTrue == true end
If you were to declare isTrue as a local variable within that block, the problem I started earlier would occur. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Oct 2017 03:18 PM |
| "so its like curly brackets in languages like java/c#?" Yes. Those standalone curly brackets with code ###### ## ##### It's just making a new scope without the overhead of a conditional or other type of statement. |
|
|
| Report Abuse |
|
|