generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: dictionaries look real nice in coding

Previous Thread :: Next Thread 
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
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 is not online. 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 is not online. 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
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
10 Jul 2016 08:41 PM
to access it i go

Services.ReplicatedStorage




Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
10 Jul 2016 08:45 PM
Your just creating more work, although it does look more clean.
Report Abuse
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
10 Jul 2016 08:53 PM
^ ik but its not really much work and looks far nicer


Report Abuse
DarthStrantax is not online. DarthStrantax
Joined: 31 May 2011
Total Posts: 2610
10 Jul 2016 08:55 PM
Services = setmetatable({},{
__index=function(_,i)
return game:service(i)
end
})
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
10 Jul 2016 08:58 PM
Gross
Report Abuse
DarthStrantax is not online. DarthStrantax
Joined: 31 May 2011
Total Posts: 2610
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
ClockworkSquirrel is not online. ClockworkSquirrel
Joined: 06 Jul 2009
Total Posts: 1531
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 is not online. 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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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 is not online. 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
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
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 is not online. 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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
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
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
10 Jul 2016 11:50 PM
Yeah you should, it's cleaner and you make what shouldn't be visible, invisible.
Report Abuse
DoAnAileronRoll is not online. DoAnAileronRoll
Joined: 08 Feb 2015
Total Posts: 5360
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
11 Jul 2016 12:28 AM
raise it to more than 200 but less than 256***
Report Abuse
DoAnAileronRoll is not online. DoAnAileronRoll
Joined: 08 Feb 2015
Total Posts: 5360
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image