Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 19 Apr 2013 05:18 PM |
How many variables do you commonly make per a ROBLOX item? For me, it's a 1:1 ratio, for almost every ROBLOX object, I guarantee it's existence, and in many cases, the script generates the item (Modularity FTW).
For a lot of other scripters, I see this:
script.Parent.Parent.Text = script.Parent.Parent.Parent.Parent.Parent.Name script.Parent.Parent.Parent.CharacterName.Text = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name
And stuff... I think I refer to the variable "script" once in a 1,500 line script, with about 3000 lines of support code. -__-
Do you think it's worth it to make new variables (I do), and why do you think newer members like to use script.Parent.... a ton? I think it's a misconception of lag and efficiency. :/
|
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 19 Apr 2013 05:26 PM |
I have a 3 tables at the top of each of my scripts for the following:
Event connections Created objects Services
Is that obsessive?
~ Dekkonot ~ |
|
|
| Report Abuse |
|
|
HaxHelper
|
  |
| Joined: 19 Dec 2009 |
| Total Posts: 1208 |
|
|
| 19 Apr 2013 05:27 PM |
| because that kind of linearity is probably easier to understand for new coders than OOP-like systems |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 19 Apr 2013 05:28 PM |
| If it's going to be needed more than once when the script is running then I make a variable. I think newer people will use script.Parent so much because that's how it used to be done in all the ROBLOX wiki beginner scripting tutorials. I think it still is done in one or two of them. Another reason could be they don't want to remember too many of their variable's names I guess. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 19 Apr 2013 05:39 PM |
I'm programming in a OOP type system right now. I store my event's in an object called 'EventBin,' derived from Stravant's code (With a few modifications),
Services are just a table, but packaged in a constructor for scope-reasons. Speaking of which, I wonder what people's header-code/broiler plate code looks like... |
|
|
| Report Abuse |
|
|
j1my3p1x
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 978 |
|
|
| 19 Apr 2013 06:03 PM |
| What type of table do you use, coffee tables, dinner tables, are they granite, i have a table thats onyx. How big is your monitor too, and does it use gorilla glass? like how does it hold three tables? Are they like carbon fiber or something? |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2013 06:37 PM |
'script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name'
Now why on earth would you need that many parents?
And yes, I use script.Parent somewhat; unless I think I'll need to access it again, then I will make a variable strictly for efficiency. I'm not a fan of using variables mainly because I can never remember what ones I have and what I called them, etc. |
|
|
| Report Abuse |
|
|
woot3
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 3599 |
|
|
| 19 Apr 2013 06:44 PM |
In local scripts I have a table containing the Player, Mouse, Character, Gui, Camera. I also normally have a reference to a Server script which allows me to check the connection speed of players so I can ease their load if I need to. Then, if I still have more references I need to make, I use a second table.
|
|
|
| Report Abuse |
|
|
|
| 19 Apr 2013 07:09 PM |
I agree with Quenty it seems that many people do things like script.Parent.Parent.Parent.Parent.Base instead of Game.Workspace.Base
I don't think something so minor like that would be much of a problem... more of a formatting issue
~ 3.14 It is pie ~ |
|
|
| Report Abuse |
|
|
woot3
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 3599 |
|
|
| 19 Apr 2013 07:11 PM |
| I try to avoid script.Parent |
|
|
| Report Abuse |
|
|
oreosol
|
  |
| Joined: 01 Feb 2011 |
| Total Posts: 6 |
|
| |
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 19 Apr 2013 07:50 PM |
@Fatty I actually would do this
local Base = WaitForChild(Workspace, "Base")
|
|
|
| Report Abuse |
|
|
|
| 19 Apr 2013 08:05 PM |
I would use WaitForChild but I am using older studio and it is unsupported on the older version, so meh.
~ 3.14 It is pie ~ |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2013 09:47 PM |
It really depends. When it comes to Guis, I don't want to have 30 or 40 reference handles to objects when it's easier to manage my Guis with :GetChildren() calls.
Right now, I'm most focused on easy readability instead of efficiency.
So I guess I'm about 1:8 for permanent reference handles to objects (many are allocated on the stack and get deleted almost instantly). |
|
|
| Report Abuse |
|
|