#functions
1 messages · Page 1 of 1 (latest)
What is it that you don't understand with it?
Have you used functions in any other coding languages?
Alright
Well basically
You write
function()
And inside those
So you want to replace this part:
send "&a&l‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒" to arg-2
send " &f&l Exerience Summary" to arg-2
send " " to arg-2
send " &e Your level&r&6&l 2&r&e!" to arg-2
send " &eYou need&r&6 800 xp&r&e to reach level &r&63. " to arg-2
send " " to arg-2
send " &eYour experience isn't currently being boosted" to arg-2
send "&a&l‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒" to arg-2
with a function that does that?
Correct?
Then you'd do function(text: text, p, offlineplayer)
And then you could call that function by doing function(arg-1, arg-2)
I'm really bad at explaining stuff
So I apologize for that.
They are just data you give the function, as functions can only access global things and not anything local unless given to them
command /sendcentered <offlineplayer>:
permission: op
trigger:
functionExample(arg-1)
function functionExample(p: offlineplayer):
send "&a&l‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒" to {_p}
send " &f&l Exerience Summary" to {_p}
send " " to {_p}
send " &e Your level&r&6&l 2&r&e!" to {_p}
send " &eYou need&r&6 800 xp&r&e to reach level &r&63. " to {_p}
send " " to {_p}
send " &eYour experience isn't currently being boosted" to {_p}
send "&a&l‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒" to {_p}
And if you want to add more "arguments" to the function you separate them by commas
It doesn't send it to all players
Sure
Then you don't even need arguments
Sure
But you can name it whatever
And it would be t: text
Could also be t: int
It's like in a command
If you have one argument
Yes
Just an example
And it's <int>
You then call that argument by arg-1
It's just that when you do it like this you give it a name too
And call it via {_<name of the argument>}
You can use broadcast in the function