Solved Please send help my OCD is killing me (skQuery async stuff)

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

jaylawl

Active Member
Jan 29, 2017
173
31
0
So, i just added the "$ thread" portions to the code below. In doing so, i was able elimate a quite significant lag spike. These functions pretty much all contain yml edits using skUtilities.

Fair enough, the lag is gone and im rather happy. The new additional lines of code however, are kinda bugging me. Is there any way to group stuff like that up so "$ thread" doesnt have to be put before every individual line? I'm having a hard time finding the appropriate documentation on this.

A workaround i've come up with, is to put all these function calls in a new master-function, so to say. But that would force me to export all variables, the data of the event, to the new function and i'd love to prevent having to do so.

Cheers peeps!

code_language.skript:
    $ thread
    addPlayerStats({_player}, "Holes", 1)
    $ thread
    addPlayerStats({_player}, "Strokes.Total", {_strokes})
    $ thread
    addPlayerStats({_player}, "Time.Total", {_time})
    $ thread
    addPlayerStats({_player}, "Courses.%{_course}%.Holes.%{_hole}%.Holes", 1)
    $ thread
    addPlayerStats({_player}, "Courses.%{_course}%.Holes.%{_hole}%.Strokes.Total", {_strokes})
    $ thread
    addPlayerStats({_player}, "Courses.%{_course}%.Holes.%{_hole}%.Time.Total", {_time})
    $ thread
    addPlayerStats({_player}, "Scores.Totals.%{_score}%", 1)
    broadcast "&c%system milliseconds - {_t}% &7ms"
    $ thread
    recalculatePlayerStats({_player}, {_course}, {_hole})
    delete yml nodes "Latest.Hole" of file "%{_playerfile}%"
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Date", -1, "%now%")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Course", -1, {_course})
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Hole", {_hole}, "")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Strokes", {_strokes}, "")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Time", {_time}, "")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Route", {_ball_route}, "")
    $ thread
    checkPersonalBest({_player}, {_course}, {_hole}, {_strokes}, {_time}, {_par})
    $ thread
    checkGlobalBest({_player}, {_course}, {_hole}, {_strokes}, {_time}, {_par})
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.ScoreTotal", ({_strokes_total} - {_par_current}))
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.StrokesCurrent", 0)
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.Strokes.%{_hole}%", {_strokes})
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.Times.%{_hole}%", {_time})
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.HolesCompleted", {_hole})
    $ thread
    addGameStats({_player}, "Scores.%{_player}'s uuid%.BallRouteTotal", {_ball_route})
    $ thread
    addGameStats({_player}, "Scores.%{_player}'s uuid%.EfficiencyTotal", ({_length} / {_ball_route}))
 
So, i just added the "$ thread" portions to the code below. In doing so, i was able elimate a quite significant lag spike. These functions pretty much all contain yml edits using skUtilities.

Fair enough, the lag is gone and im rather happy. The new additional lines of code however, are kinda bugging me. Is there any way to group stuff like that up so "$ thread" doesnt have to be put before every individual line? I'm having a hard time finding the appropriate documentation on this.

A workaround i've come up with, is to put all these function calls in a new master-function, so to say. But that would force me to export all variables, the data of the event, to the new function and i'd love to prevent having to do so.

Cheers peeps!

code_language.skript:
    $ thread
    addPlayerStats({_player}, "Holes", 1)
    $ thread
    addPlayerStats({_player}, "Strokes.Total", {_strokes})
    $ thread
    addPlayerStats({_player}, "Time.Total", {_time})
    $ thread
    addPlayerStats({_player}, "Courses.%{_course}%.Holes.%{_hole}%.Holes", 1)
    $ thread
    addPlayerStats({_player}, "Courses.%{_course}%.Holes.%{_hole}%.Strokes.Total", {_strokes})
    $ thread
    addPlayerStats({_player}, "Courses.%{_course}%.Holes.%{_hole}%.Time.Total", {_time})
    $ thread
    addPlayerStats({_player}, "Scores.Totals.%{_score}%", 1)
    broadcast "&c%system milliseconds - {_t}% &7ms"
    $ thread
    recalculatePlayerStats({_player}, {_course}, {_hole})
    delete yml nodes "Latest.Hole" of file "%{_playerfile}%"
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Date", -1, "%now%")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Course", -1, {_course})
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Hole", {_hole}, "")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Strokes", {_strokes}, "")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Time", {_time}, "")
    $ thread
    setPlayerStats({_player}, "Latest.Hole.Route", {_ball_route}, "")
    $ thread
    checkPersonalBest({_player}, {_course}, {_hole}, {_strokes}, {_time}, {_par})
    $ thread
    checkGlobalBest({_player}, {_course}, {_hole}, {_strokes}, {_time}, {_par})
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.ScoreTotal", ({_strokes_total} - {_par_current}))
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.StrokesCurrent", 0)
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.Strokes.%{_hole}%", {_strokes})
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.Times.%{_hole}%", {_time})
    $ thread
    setGameStats({_game}, "Scores.%{_player}'s uuid%.HolesCompleted", {_hole})
    $ thread
    addGameStats({_player}, "Scores.%{_player}'s uuid%.BallRouteTotal", {_ball_route})
    $ thread
    addGameStats({_player}, "Scores.%{_player}'s uuid%.EfficiencyTotal", ({_length} / {_ball_route}))
Yes there are better ways but this isn't doing anything anyway. Functions are synchronous, and most things in skript can't even be run async
 
Yes there are better ways but this isn't doing anything anyway. Functions are synchronous, and most things in skript can't even be run async
I'm sorry, but this is far from not doing anything. The event that contains the code i posted, caused some major lag by killing .1-2 ticks of minecraft, and it took 150 milliseconds to complete. Ever since i added the "$ thread", in the manner in which i quoted the code, the lag is gone although the event now takes ~1000-1300 milliseconds to complete.

I did not measure that stuff by intuition, but spent about 2 hours with painstakingly making minor differences and then recording TPS timings for about 15 each time.

So you were saying there are better ways? Please let me know! :emoji_slight_smile:
 
I'm sorry, but this is far from not doing anything. The event that contains the code i posted, caused some major lag by killing .1-2 ticks of minecraft, and it took 150 milliseconds to complete. Ever since i added the "$ thread", in the manner in which i quoted the code, the lag is gone although the event now takes ~1000-1300 milliseconds to complete.

I did not measure that stuff by intuition, but spent about 2 hours with painstakingly making minor differences and then recording TPS timings for about 15 each time.

So you were saying there are better ways? Please let me know! :emoji_slight_smile:

Requires mundosk it Will run everything thats tabbed out underneed iT async

code_language.skript:
broadcast "Retrieving text!"
async:
    set {_var} to text from url "mundosk.github.io"
wait until {_var} is set
broadcast "Text retrieved: %{_var}%"
 
I'm sorry, but this is far from not doing anything. The event that contains the code i posted, caused some major lag by killing .1-2 ticks of minecraft, and it took 150 milliseconds to complete. Ever since i added the "$ thread", in the manner in which i quoted the code, the lag is gone although the event now takes ~1000-1300 milliseconds to complete.

I did not measure that stuff by intuition, but spent about 2 hours with painstakingly making minor differences and then recording TPS timings for about 15 each time.

So you were saying there are better ways? Please let me know! :emoji_slight_smile:
That doesn't mean it wasn't influenced from other factors. You can't just stick async on something and expect it to work
 
That doesn't mean it wasn't influenced from other factors. You can't just stick async on something and expect it to work
Adding "$ thread" was the only thing i've done. There were no other factors. The point is it did work.
 
Adding "$ thread" was the only thing i've done. There were no other factors. The point is it did work.

Of course there were other factors. You mean to tell me you recreated the amount of chunks loaded, entities loaded, players online, etc?
 
Of course there were other factors. You mean to tell me you recreated the amount of chunks loaded, entities loaded, players online, etc?
I appreciate your original post, but at this point i feel like you're taking me for a complete idiot. This matter is solved anyway, thanks for your time.
 
Hes right though you sould find the root of the cause befor procceding adding async shouldnt be your solution
 
Hes right though you sould find the root of the cause befor procceding adding async shouldnt be your solution
I have located the issue and i haven't found a way to make the process faster / get rid of the lag. Async was the only solution for the time being.
 
I have located the issue and i haven't found a way to make the process faster / get rid of the lag. Async was the only solution for the time being.
You can prob ask any of the advance skripters to take a look like snow and pikachu
 
Status
Not open for further replies.