Skript: Make function variables[Suggestion]

Created on 17 Jun 2019  Â·  10Comments  Â·  Source: SkriptLang/Skript

I think if there is such a function variables provides making skript libraries
i will give an example for function variable's

on load:
    set {test()} to function(a: integer, b: integer) :: string:
        return "%{_a} + {_b}%"

command /test <integer> <integer>:
    if {test()} is set:
        broadcast run {test(20,30)}

Most helpful comment

This is completely possible just using normal functions:

on load:
  set {func::should-run} to true

function test(a: integer, b: integer) :: string:
  return "%{_a} + {_b}%"

command /test <integer> <integer>:
  trigger:
     if {func::should-run} is set:
       broadcast test(arg-1, arg-2)

What you've proposed, at least to me is just a more confusing way of using them, besides it being complex to implement since you're trying to mix two completely different concepts in Skript (expressions and sections).

I am sorry but I am unable to see any advantage over the current behaviour, and that being the case, I am closing the issue.

All 10 comments

This is completely possible just using normal functions:

on load:
  set {func::should-run} to true

function test(a: integer, b: integer) :: string:
  return "%{_a} + {_b}%"

command /test <integer> <integer>:
  trigger:
     if {func::should-run} is set:
       broadcast test(arg-1, arg-2)

What you've proposed, at least to me is just a more confusing way of using them, besides it being complex to implement since you're trying to mix two completely different concepts in Skript (expressions and sections).

I am sorry but I am unable to see any advantage over the current behaviour, and that being the case, I am closing the issue.

Dear @FranKusmiruk,
you did not understand me enough
my example is not a issue or suggestion its only an simple example of an suggestion

i mean if there is such a 2 skript and if i use your way
the error begins
1.sk

on load:
  set {func::should-run} to false

2.sk

command /test <integer> <integer>:
  trigger:
     if {func::should-run} is set:
       broadcast test(arg-1, arg-2)

but if my they add my suggestion there can be such an option

1.sk

on load:
#nothing

2.sk

command /test <integer> <integer>:
    if {test()} is set:
        broadcast run {test(20,30)}

I agree with Snow here. What you are proposing can already be done (the way Snow described)

Variables and functions will work across all of your scripts. Your proposal does not add anything new to Skript or change it for the better.

oh @ShaneBeee you said Your proposal does not add anything new to Skript
im agree with you
but
change it for the better.
why variable functions is not better than solid functions ?

and i already said making skript library with Snow's way is impossible i think

I’m not quite sure I completely understand why you want this, but I’m assuming it’s so you can have a function that runs only if it exists, and doesn’t throw an error when the script is loaded if it doesn’t exist.
While yes, that might have uses in niche situations, it would be extremely limited.

There are currently two open suggestions, one for a “parse if <.+>” condition and the other for try/catch sections.
Both of these would fulfil what I assume you’re asking for here, and do it in a much better way.

Besides, the implementation you’re proposing here is complicated and also has nothing to do with skript variables, as far as I can see.

If I’ve misunderstood what you actually want, would you mind explaining it more clearly? Otherwise I’d suggest you support one of the other open suggestions that fulfills this, given that they both have more practical scope.

@Moderocky you said try/catch sections.
im agree with try/catch sections. else function variables

First class functions would be useful, but I don't think inline definitions would be a good idea.

@bensku yes i mean class functions too
my examples is not real or something only for explain what i want to skript team

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  3Comments

Romitou picture Romitou  Â·  3Comments

LeotomasMC picture LeotomasMC  Â·  3Comments

Anoniempje1234 picture Anoniempje1234  Â·  3Comments

Anarchick picture Anarchick  Â·  3Comments