|
| 14 Jan 2016 01:15 PM |
For the longest time, there is this thing, this thing that restricts what i can do and its so annoying cause i dont understand them - arguments. I don't understand how people know what the arguments are, that may not make sense lemme give an example:
function OnTouched(touchingPart, touchedPart) print(touchingPart .. " has touched " .. touchedPart.Name) end local Part = Instance.new("Part") Part.Touched:connect(function(hitPart) OnTouched(Part, hitPart) end)
(from the wiki)
I understand how to use events with one arg, the touching part is the part that fired the event, but with two, i just dont get it. How does it work?
|
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 14 Jan 2016 01:19 PM |
It's the same concept whether it's one argument or 20. Values passed to the function from the line that called it.
Not sure how you can't extend your knowledge of using one argument, to using multiple? |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2016 01:23 PM |
| wait, im looking for a better example, i get what the two parameters mean in this example sorry |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2016 01:29 PM |
found one:
PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance) -- Show message indicating that a player has gotten points local message = Instance.new('Message', game.Workspace) message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!" wait(5) message:Destroy() end)
how does the writer know what each arg represents if the don't set them |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2016 01:32 PM |
| Because they are the function's standard arguments |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2016 01:34 PM |
Because they are already defined and specific to functions.
Touched just passes the part that was touched. PlayerAdded only passes the player that joined. PointsAwarded returns four arguments, just read the wiki. http://wiki.roblox.com/index.php?title=API:Class/PointsService/PointsAwarded
That is how you learn scripting and APIs after all, from the wiki.
|
|
|
| Report Abuse |
|
|
|
| 14 Jan 2016 01:37 PM |
| @ happy so certain events have built in parameters? |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Jan 2016 02:00 PM |
| oh, that clears up the mystery (on my side, the rest of u are just looking at me like 0.o?) thanks guys :) |
|
|
| Report Abuse |
|
|