| Refering to functions as objects? | |
|
|
Author | Message |
---|
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Refering to functions as objects? March 18th 2012, 7:36 pm | |
| I've noticed in Telamon's leaderstats script, that he refers to "killer" as an object, but its value is a function? How is that possible? How can I use this to create and insert a table of guis? | |
|
| |
naknak Administrator
Posts : 878 Join date : 2010-07-30
| Subject: Re: Refering to functions as objects? March 18th 2012, 9:47 pm | |
| | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Refering to functions as objects? March 19th 2012, 4:43 am | |
| i thought 'killer' was an object value... | |
|
| |
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Re: Refering to functions as objects? March 19th 2012, 8:44 am | |
| local killer = getKillerOfHumanoidIfStillInGame(humanoid)
if killer ~= nil then ... | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Refering to functions as objects? March 20th 2012, 3:32 am | |
| that means it it was referring the the values returned from that function not the function itself:
function aFunction() return 10 end
aCall = aFunction() aFunctionReference = aFunction print(aCall) print(aFunctionRefence)
>10 >function: [hexadecimalcodehere] | |
|
| |
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Re: Refering to functions as objects? March 20th 2012, 8:38 am | |
| Cool, but can you refer to more than one object, or maybe a table? | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Refering to functions as objects? March 21st 2012, 3:30 am | |
| function ReturnTable() return {1,4,3,5} end
function Return3Values() return 1,3,5 end
tab = ReturnTable() x,y,z = Return3Values()
print(x,z) >1 5 print(tab[2],tab[4]) >4 5 | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Refering to functions as objects? March 21st 2012, 3:35 am | |
| you can even reference objects like in the leaderboard script:
function ReturnWorkspace() return worksapce end
work = ReturnWorkspace()
print(work.Name) | |
|
| |
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Re: Refering to functions as objects? March 21st 2012, 9:20 am | |
| worksapc? Anyway, thats cool. I didn't really know what the whole point of return even was... I thought it would just like... reset the function of something... | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Refering to functions as objects? March 23rd 2012, 2:42 am | |
| whoops, typo i mean to say Workspace
return has many uses... i was just showing how it returns values from functions because you were wondering. i could explainmore if u wanted. | |
|
| |
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Re: Refering to functions as objects? March 23rd 2012, 12:58 pm | |
| Ok. What else can it do? I think I heard it can like return to the beginning of a function if the requirements can't be met.... btw Have you ever used tweening? | |
|
| |
blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Refering to functions as objects? March 28th 2012, 5:03 am | |
| nope, :P first time i tried it it didn't work so I used my own method that was slower :P | |
|
| |
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Re: Refering to functions as objects? March 28th 2012, 11:28 am | |
| | |
|
| |
Sethalonian Intermediate Scripter
Posts : 63 Join date : 2011-06-10 Age : 26
| Subject: Re: Refering to functions as objects? March 28th 2012, 11:29 am | |
| Ok, Answer me this, How do you get text to slide out of a gui without moving outside of it, and not showing text or anything? I don't understand it... | |
|
| |
Sponsored content
| Subject: Re: Refering to functions as objects? | |
| |
|
| |
| Refering to functions as objects? | |
|