|
| 13 Mar 2017 09:38 PM |
So, recently in a lot of scripts for my game, I have been needing to use local Booleans. They usually take the form of something like this.
local d = true local d1 = true local d2 = true local d3 = true etc.
I was wondering if there was a way to make local Booleans d1-100 or something without having to list them out like I am. A more efficient way to make booleans. It's hard to explain kinda but I need a more efficient way to make 1-100 numbered Booleans without listing them like I am. Thanks. :) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 13 Mar 2017 09:39 PM |
Have a table of booleans, so like: local d = { true, true, true, true, ... }
and to check if a certain one is true: if d[3] then ... |
|
|
| Report Abuse |
|
|
|
| 13 Mar 2017 09:43 PM |
local d,d1,d2 = true,true,true
local boolTable = {}
for i = 1, 100, 1 do boolTable[i] = true end |
|
|
| Report Abuse |
|
|
|
| 14 Mar 2017 03:15 PM |
| Thanks guys this helped a lot :D |
|
|
| Report Abuse |
|
|
Atavis
|
  |
| Joined: 10 Apr 2012 |
| Total Posts: 1463 |
|
|
| 14 Mar 2017 03:28 PM |
loops > the meaning and result of our lives
747,365 slices of pizza and counting! |
|
|
| Report Abuse |
|
|
|
| 14 Mar 2017 04:29 PM |
or...
for i = 1,100 do getfenv()["d"..i] = true end
|
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Mar 2017 05:03 PM |
| To be fair the term "local boolean" doesn't even make sense but that's regard the point. By using `getfenv` you miss the entire point of what the OP wants and made a less efficient, more disgusting script. Even if you used debug.setlocal (which ofc. was removed by Roblox) you would have been more relevant. |
|
|
| Report Abuse |
|
|
|
| 14 Mar 2017 05:04 PM |
OP probably meant booleans that are only accessible to the scope of the current function.
|
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|