|
| 04 Jul 2016 04:38 PM |
I would rather not have a bunch of tables in scripts, and instead keep a poop ton of string values in Lighting to contain info.
How inefficient is this? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 04:43 PM |
Not as efficient as having a couple dozen string values, but more efficient than having a couple thousand string value.
Of course, tables are cleaner and prettier. You should probably just go with those. Use a new script or ModuleScript if you want to keep it clean. Use _G.
|
|
|
| Report Abuse |
|
|
SerGregor
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7957 |
|
|
| 04 Jul 2016 05:01 PM |
| ^ I heard _G was bad practice when I once asked someone here for methods and I suggested if I should use _G.. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:07 PM |
I guess you could have one long string and find a way to extract from the string appropriate to your system. Or just a few long strings
218,995 slices of pizza and counting |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:07 PM |
If you're going to do that, at least store them in the ServerStorage if you're trying to access them in a script (not local).
-=[ RAP: 345,446 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:10 PM |
_G is fine, it just puts it in a higher scope.
"Tell me and I forget. Teach me and I remember. Involve me and I learn." - Benjamin Franklin |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 04 Jul 2016 05:11 PM |
| You can store them in a modulescript. |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 04 Jul 2016 05:11 PM |
| (a table in a modulescript) |
|
|
| Report Abuse |
|
|
SerGregor
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7957 |
|
|
| 04 Jul 2016 05:11 PM |
| ^ People always told me it's bad to use _G and use module scripts..wow. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:13 PM |
If ModuleScripts were bad, why would Roblox even bother making them in the first place? They actually made quite a deal out of them.
"Tell me and I forget. Teach me and I remember. Involve me and I learn." - Benjamin Franklin |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:13 PM |
@Ser Whoever told you its bad to use module scripts is seriously an inefficient coder. Modules are pretty nifty to use.
-=[ RAP: 345,451 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 04 Jul 2016 05:23 PM |
| Globals are generally bad practice, modules are the exact opposite. Using modules allows code reuse, which is very good for code maintainence. |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 04 Jul 2016 05:27 PM |
There is absolutely nothing wrong with using the _G library and module scripts.
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:28 PM |
It's just bad practice to use global variables in any coding language as it's much easier to get confused on which identifier is where and doing what.
218,868 slices of pizza and counting |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 04 Jul 2016 05:30 PM |
I do agree that there are better alternatives to the global library, but it's not like storage objects in Lighting or using deprecated functions.
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:30 PM |
| There is absolutely nothing wrong with using the _G library and module scripts. [2] |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 04 Jul 2016 05:31 PM |
storing*
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 05:35 PM |
| I do think though that _G functions are much easier to use than raw coroutines. |
|
|
| Report Abuse |
|
|
Cinnace
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 370 |
|
|
| 04 Jul 2016 05:38 PM |
I would off myself without modulescripts. it would make for terrible unorganized code.
- Cinnace |
|
|
| Report Abuse |
|
|
SerGregor
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7957 |
|
|
| 04 Jul 2016 06:21 PM |
| No, module scripts are good. People said I should stop with _G and just do module scripts. I mean, I don't see why the global table is bad though. |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 05:02 AM |
Nothing explicitly wrong with them as far as I can see... Which isn't very far tbh x'D
218,626 slices of pizza and counting |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 06:44 AM |
_G is thoroughly disgusting. If you need to access something across multiple scripts, use ModuleScripts.
|
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 06:47 AM |
Yeah using a ModuleScript seems like the best solution for this. And yes, _G is bad practice because it teaches you how to write crap code. There are very few times where you would need to use _G. No, it's not inefficient, it's just bad practice. It makes no sense that your "hundreds of strings" can be accessed anywhere. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 05 Jul 2016 07:08 AM |
| _G can however be used for singletons. This is the issue that people are forgetting, because _G is perfect for singletons and utility details where it is guaranteed to exist by the time the script is run. |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2016 01:48 PM |
WaitForChild was created for a reason. It even has a handy timeout warning now if you try to wait for something that's never going to exist.
|
|
|
| Report Abuse |
|
|