|
| 10 Jul 2016 08:37 PM |
Usaully I would do
local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage") local Players = game:GetService("Players")
but now i do this
Services = { ReplicatedStorage = game:GetService("ReplicatedStorage"), ServerStorage = game:GetService("ServerStorage"), Players = game:GetService("Players"), }
|
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 10 Jul 2016 08:37 PM |
What are the pluses to doing that?
u sicko! |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 10 Jul 2016 08:38 PM |
never used them, so I would do something like this?
instead of: lol = ReplicatedStorage:findFirstChild("hi") use: lol = Services.ReplicatedStorage:findFirstChild("Hi")
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 08:41 PM |
to access it i go
Services.ReplicatedStorage
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 08:45 PM |
| Your just creating more work, although it does look more clean. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 08:53 PM |
^ ik but its not really much work and looks far nicer
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 08:55 PM |
Services = setmetatable({},{ __index=function(_,i) return game:service(i) end }) |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 08:56 PM |
Darth wins, except he didn't use GetService and he also forgot local.
local Services = setmetatable({},{ __index=function(_,k) return game:GetService(k) end })
|
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Jul 2016 08:59 PM |
| am typing on my tablet so only put in nescecities. Also op didnt use local so i figured i shouldnt. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 09:01 PM |
I do that occasionally. It does take a little extra time, though. Try this: Create a ModuleScript containing all available Services, and plop it in ReplicatedStorage. This way, you can require it from any script in your game, and have all the services there, ready. You don't need to define them in every single script.
ModuleScript: local function gs(SvcName) return game:GetService(SvcName); end
return { Marketplace = gs("MarketplaceService"); Players = gs("Players"); Run = gs("RunService"); StarterGui = gs("StarterGui"); Badge = gs("BadgeService"); GamePass = gs("GamepassService"); Insert = gs("InsertService"); ... }
Other scripts: local Service = require(game:GetService("ReplicatedStorage"):WaitForChild("Services")) local Player = Service.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 10 Jul 2016 09:04 PM |
If you're used to coding in other languages like C# it looks nicer, but I honestly like the normal way better.
u sicko! |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 10:38 PM |
I mean I guess thats a way to avoid the 200 local variable limit but its not worth it imo
|
|
|
| Report Abuse |
|
|
SerGregor
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7957 |
|
|
| 10 Jul 2016 10:43 PM |
| Wait the limit for local variables is 200 for the entire script? |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 10:48 PM |
There shouldn't be any limitations on variables?
e-e.
Also it would be so neat if roblox allowed us to make are own keywords.
Like lets say, you had a folder called SuperImportantItemContainer
SIIC = game.ReplicatedStorage.SuperImportantItemContainer;
in a roblox window make SIIC the color of your choice, would make coding look so sweet. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 10:50 PM |
Found this
'This is an integrated Lua limit. In the luaconf.h file of the language you can actually see the variable named LUAI_MAXVARS which declares them to limit to 200.'
I'v compiled lua actually, I suppose I didn't look too much into the detail's of luaconf.h if at all :3. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 11:28 PM |
You don't know anything about Lua secret
Yes people, there is a 200 local variable limit PER function. If you need that many you're doing something wrong. |
|
|
| Report Abuse |
|
|
SerGregor
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7957 |
|
|
| 10 Jul 2016 11:33 PM |
| ^Thought they meant per script. Sounds more realistic now. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 11:38 PM |
| Well if you really need more, you can always reuse them or encapsulate them in do-end blocks so their registers (stack space) can be reused later on. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 11:46 PM |
I may just use dictionaries for settings, it looks good there too
Settings = { Mode = "Auto", Damage = 23, }
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2016 11:50 PM |
| Yeah you should, it's cleaner and you make what shouldn't be visible, invisible. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 12:24 AM |
Is this 200 variable limit due to the stack size limit?
I don't really know anything about Lua here, C++/Java/C (and hate python to death) for me.
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 12:26 AM |
Yeah. Technically you may be able to raise the limit to like more than 200 but the first reason I can think of to stay below 256 is that the stack size needed is provided by the Lua compiler depending on how many local variables are used in a single byte (part of the bytecode). Another reason I guess would be "do you really need that many?"
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 12:28 AM |
| raise it to more than 200 but less than 256*** |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 12:37 AM |
Ahhhh.
I suppose anything short of a port of MS-DOS for ComputerCraft doesn't need 200 variables anyway... god MS-DOS source gets complicated *fast*.
Weird it's not 255 though.
|
|
|
| Report Abuse |
|
|