on variable update

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

titustitus98

Member
Feb 19, 2018
47
0
6
25
Hi this is a suggestion for an addon or a new skript feature.

My suggestion is a new event called "on variable update" which would trigger whenever a variables is changed.

For example, say I have a variable called "{money::%player%}" and that it's default value is 0, so suppose I want there to be a message sent in chat when this number is updated, this would be the code for it:

on variable update:
if event variable is {money::%player%}:
send "hi" to event-player
 
how would skript know what player did you mean
big facepalm bruh

Instead of facepalming, consider this. The event would be "on variable change", and you can loop all players and have a check, something like this: "if event-variable is {_blahblah::%loop-player%}" then go from there
 
Theres no need for this.
Variables do not update themselves, they only update when YOU update them in your code.
If you need to find out when it updates, well, look at where you change said variable, or create functions so you can do multiple things when the variable needs to be changed.
 
I think this would be a nice addition, a lot of cool stuff could be done with this without a need to rewrite all of your code to make it a function. (for example linking all variables to external database) and overall this could be used for cross-script communication without load order issues, like set {starteventnow} to true, then many scripts which listen to on variable update event, could trigger code on this variable set.

yes, for the most part this won't be needed to anyone, just a cool feature for those rare ones who need it.
 
I think this would be a nice addition, a lot of cool stuff could be done with this without a need to rewrite all of your code to make it a function. (for example linking all variables to external database) and overall this could be used for cross-script communication without load order issues, like set {starteventnow} to true, then many scripts which listen to on variable update event, could trigger code on this variable set.

yes, for the most part this won't be needed to anyone, just a cool feature for those rare ones who need it.

I agree 100%
 
I think this would be a nice addition, a lot of cool stuff could be done with this without a need to rewrite all of your code to make it a function. (for example linking all variables to external database) and overall this could be used for cross-script communication without load order issues, like set {starteventnow} to true, then many scripts which listen to on variable update event, could trigger code on this variable set.

yes, for the most part this won't be needed to anyone, just a cool feature for those rare ones who need it.

The load order issues will still remain. The only thing ur dooing is making a duplicate of the on script load: event.

Code:
Skript 1 CORE:

on var change:
    if event-var = "starteventnow":
        if change value = true:
            LOADIN SKRIPT 2

Skript 2 Dependency:

on script load:
    set {starteventnow} to true

Code:
Skript 1 CORE:

function loadsk2(value: boolean):
    LOADIN SKRIPT 2

Skript 2 Dependency:

on script load:
    loadsk2(true)

if skript 2 loads before skript 1 both won't fix the order issues.

Double databases are also not recomended except wenn making backups.

Only thing i can see is another event in skript causing our servers to lag more.
 
The load order issues will still remain. The only thing ur dooing is making a duplicate of the on script load: event.

Code:
Skript 1 CORE:

on var change:
    if event-var = "starteventnow":
        if change value = true:
            LOADIN SKRIPT 2

Skript 2 Dependency:

on script load:
    set {starteventnow} to true

Code:
Skript 1 CORE:

function loadsk2(value: boolean):
    LOADIN SKRIPT 2

Skript 2 Dependency:

on script load:
    loadsk2(true)

if skript 2 loads before skript 1 both won't fix the order issues.

Double databases are also not recomended except wenn making backups.

Only thing i can see is another event in skript causing our servers to lag more.
I think you have completely misunderstood what I meant, I wasn't talking about functions or on script load events, also I don't think events cause noticeable lag. I did not mean double databases too. (talking bout stuff like {-variables} going to a separate database, for example mysql since skript doesn't support that properly anymore, I'd make a queue on that event, and every x seconds send a query to sql to put it there)
 
I think you have completely misunderstood what I meant, I wasn't talking about functions or on script load events, also I don't think events cause noticeable lag. I did not mean double databases too. (talking bout stuff like {-variables} going to a separate database, for example mysql since skript doesn't support that properly anymore, I'd make a queue on that event, and every x seconds send a query to sql to put it there)

are u talking about databases of skript it self or not?
[doublepost=1583919420,1583919332][/doublepost]
are u talking about databases of skript it self or not?
from the config