Hi
I have couple questions for Plugins devlopper / lua pro!
1:
What is the difference between
andCode:function PLUGIN:myfunc() something end
My understanding is, with "PLUGIN:" make the function "public" and w/o "PLUGIN:" make it "private" to my plugin. And I know the call won't be the same (self:myfunc() vs myfunc())Code:function myfunc() something end
What are the pros/cons of each method?
2:
For this question I'll use BasePlayer as exemple
Is it better to store a BasePlayer in a var or store a userID, then search activePlayerList every time I need to use a BasePlayer?
3:
This one isn't really a question
Am I right when I say
use something:somefunc() when the function use "this."
and use something.somefunc() when the function don't use "this."
and as @Reneb already told me, use methodarray when multiple func has the same name
Thank you!
Lua/plugins questions
Discussion in 'Rust Development' started by JJLKewL69, Nov 29, 2014.
-
Wulf Community Admin
Not using the PLUGIN scope would cause possible conflicts if another plugin uses the same function name. It's better to use PLUGIN, as it isolates it to your function which you'd then call with self.
-
using
location function blabla()
is good also, i like doing that -
And what about my question #2??
-
I have no idea, i would say store BasePlayer in the var, it's faster and you dont have to loop all the players to get the userid
-
Ok thank you @Reneb