swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 04:34 PM |
Myth:
The name of the function (onTouched, onClicked) determines when it is triggered.
Fact:
The event the function is connected to determines when its triggered.
function onClicked() print("This will work") end
script.Parent.ClickDetector.MouseClick:connect(onClicked) -- function Clicked() print("This will work too.") end
script.Parent.ClickDetector.MouseClick:connect(Clicked) -- function onTouched() print("You can even lie to it.") end script.Parent.ClickDetector.MouseClick:connect(onTouched) -- function cookies() print("See?") end
script.Parent.ClickDetector.MouseClick:connect(cookies) -- script.Parent.ClickDetector.MouseClick:connect(function() print("There can even be no name at all!") end)
Seriously, functions are just variables. Just like
a = 4 print(a) four = 4 print(four) And print(4)
All print 4, those scripts will all connect correctly to a click detector.. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
| |
|
|
| 05 Sep 2011 05:19 PM |
| OMG really?! [/dripping with sarcasm/] |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2011 05:20 PM |
| The wiki has poisioned the minds of our children. :( |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 05:22 PM |
@city
As Point-Out-The-Obvious as it sounds, some people do believe this. |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2011 05:22 PM |
| That is why the wiki is untrustable. |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Sep 2011 05:23 PM |
| swamniac, pleast get your butt over to my forum thread :) Thank you. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
| |
|
|
| 05 Sep 2011 07:21 PM |
| Haha, I know so many people who think you HAVE to type 'onTouched', when you can type 'poop' aswell. |
|
|
| Report Abuse |
|
|
billwiw
|
  |
| Joined: 03 Sep 2008 |
| Total Posts: 2765 |
|
| |
|
| |
|
|
| 05 Sep 2011 08:25 PM |
^kthnxbai
-Like an __AWESOME__ boss |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 05 Sep 2011 08:51 PM |
The wiki is still trustable. The only reason those terms are used is because it follows the lua style guidlines. I actually got in a bit of trouble for not following these rules because it can look fairly improfessional.
http://wiki.roblox.com/index.php/User_talk:Sduke524 |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 08:54 PM |
| So perpetuating a myth about scripting that is ultimately bad for people's scripting ability < Style? |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2011 08:56 PM |
| Nice thread, swmaniac! I hope people will read it & learn |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 09:00 PM |
I mean, seriously this myth exists and it gets in the way of people's understanding of scripting. For instance, one can't connect the same function to multiple events if it would mean naming the same function multiple things (suppose you could do function a() print("a") end function b() a() end but that's really... bad).
Also, what is more telling of a gun's functionality: onButton1Down() or Fire() ChangeMode() or KeyDown()
You can look at the connection line to see when these events fire, it's much harder to see what they actually do.
|
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 05 Sep 2011 09:05 PM |
| The fact that you can use a name for any function or variable has been shown in the wiki many times. For example, how do you know about this? Whenever someone is just starting to learn to script, they'll first copy the scripts and test them out, then later edit it to do what they want. Only after feeling comfortable with this will they attempt to make their own from scratch, which includes individual names. |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2011 09:05 PM |
| I used to think that a long time ago, but then I realized you can name the function anything. This will be a very useful thread for inexperienced scripters. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 09:12 PM |
"The fact that you can use a name for any function or variable has been shown in the wiki many times."
Evidently not visibly enough, the myth still exists.
The wiki needs restructuring. I don't know exactly how much or what would be the correct way, but from the number of people that say "The wiki doesn't help me" or words to that effect implies it needs work. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 05 Sep 2011 09:14 PM |
| And how exactly would you explain it better? The fact of the matter is if people say that it's because they aren't trying and want it handed to them on a silver platter. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 09:18 PM |
Functions in particular, or scripting in general?
I'd explain variables as teaching the computer a word (and functions as teaching the computer a verb). That word can be anything and mean anything that you want it to.
function Verb(Information the Verb needs) -- Definition of the word, what does it mean to do Word?
end
And for the connection line, I'd explain it as telling the computer that when something happens, it should perform the Verb.
And I'd do that in a somewhat less grammatically awkward way. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 05 Sep 2011 09:24 PM |
| And how would you fit in everything else about functions? You can only put so much into a tutorial before it gets too long, extraneous, and the reader losses interest and/or forgets the information. These points are brought up in every tutorial on the wiki about creating variables and/or creating functions. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 09:29 PM |
I'm not sure what you mean about everything else.
Like anonymous functions?
Give the script a set of instructions rather than defining a word.
Recursive functions?
The verb needs to be done more than once, and is self continuing, like running:
function Run() wait(.1) TakeStep() if not AtDestination() then Run() end end
Separate different topics about functions into different tutorials branching off the one about their basic use. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 05 Sep 2011 09:33 PM |
| And on that note I think we've somewhat derailed the thread. If you'd like to continue this discussion can we do it over PMs rather than going off topic? |
|
|
| Report Abuse |
|
|