amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 01:09 PM |
ok put your hands down
--
local part = script.Parent
part.FormFactor = "Symmetric" part.FormFactor = Enum.FormFactor.Symmetric
--these do the exact same thing
--
now at first you are like
"why?" because you are thinking the first one works, and it is way shorter
but lets look at the following code:
local part = script.Parent part.FormFactor = "Symmetric"
if part.FormFactor == "Symmetric" then print("lol see! you can use shortcuts!") elseif part.FormFactor == Enum.FormFactor.Symmetric then print("enums man, who would of thought") end
--
The main reason I actually got into Enumeration was because of ContextActionService. I'm experimenting a lot with functions triggered by different user input, so 2 useful pages to me were the following:
http://wiki.roblox.com/index.php?title=API:Enum/KeyCode http://wiki.roblox.com/index.php?title=API:Enum/UserInputType |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 01:12 PM |
because "Symmetric" is a string, and the formfactor isn't equal to a string, it is equal to Enum.FormFactor.Symmetric, an enum
|
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 17 Mar 2015 01:18 PM |
Check this out:
for i, v in pairs(Enum.FormFactor:GetEnumItems()) do print(v.Name, v.Value) end
will print:
Symmetric 0 Brick 1 Plate 2 Custom 3 |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 17 Mar 2015 01:19 PM |
| I use Enums because I can't remember the names of everything. |
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 17 Mar 2015 01:20 PM |
| But don't you still need to know the names of everything in order to get the Enum object..? |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 17 Mar 2015 01:21 PM |
| No you can use the popup menu and scroll through all of them. |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 01:21 PM |
I know Lucas, that's pretty awesome imo because you don't even have to go to the wiki or anything to check.
However, doing that with KeyCode will spam your output pretty badly. :) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 01:23 PM |
I totally didn't know what all those things were in the Object Browser.
This makes my life easy. :3 |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2015 01:25 PM |
| Just a side note, the only reason strings and integers are allowed in assigning an Enum property is because the __newindex metamethod of Roblox objects handles it. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 17 Mar 2015 01:43 PM |
| I don't use enumerations unless I'm making them myself for internals. |
|
|
| Report Abuse |
|
|
kert109
|
  |
| Joined: 31 Dec 2009 |
| Total Posts: 681 |
|
|
| 17 Mar 2015 01:50 PM |
| In case you didn't figure it out yet, you could also use the numbers, rather then the Strings and the Enums. |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 01:53 PM |
because everyone knows that Material 864 is Pebble, of the top of their heads.
it totally wouldn't be easier to do Enum.Material.Pebble |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 01:56 PM |
I think it's interesting to know all the ways you can get the same result, however.
There are times when you would want to use integers instead of strings, strings instead of enums.
I can think of a few tricky math scripts that would take advantage of the different possible datatypes. |
|
|
| Report Abuse |
|
|