#(yukiyahana) How to ensure a while loop doesn't concurrently exist on a player
35 messages · Page 1 of 1 (latest)
(yukiyahana) How to ensure a while loop doesn't concurrently exist on a player
Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
This is the script's paste. This script is supposed to reduce the flight speed of the player's Elytra for 5 seconds after taking damage (at least that's what it's intended to do)
https://paste.denizenscript.com/View/117436
Content of Denizen Script Paste #117436: My Script... pasted 2023/11/11 09:27:03 UTC-08:00, Paste length: 995 characters across 29 lines, Content: #The problem with the script now is that when a player takes damage multiple times, multiple while l...
View the guide page 'Long Term Memory: Flags' at: https://guide.denizenscript.com/guides/basics/flags.html
a player flag specifically
flag while it runs, if player has the flag don't inject the script
Thank you for your help!
I modified the script, but now everything has become very strange, and I even feel a bit desperate.
My current script:
- It does not trigger when a player is flying and takes damage.
- It triggers when a player starts flying after taking damage, and it also triggers if the player takes damage during flight.
- Multiple while loops still trigger simultaneously, and sometimes the player is launched at high speed and dies upon landing.
What I want in my ideal script:
- It triggers when a player flying takes damage.
- It triggers when a player starts flying after taking damage.
- Only one while loop exists at a time.
I have to say, I don't understand what's happening with my script now...
https://paste.denizenscript.com/View/117443
Content of Denizen Script Paste #117443: how can it be...... pasted 2023/11/11 10:32:08 UTC-08:00, Paste length: 1084 characters across 30 lines, Content: StartGlidingCheck:
!debug
If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!
I have to say, due to the while loop, the debug information looks like a disaster
https://paste.denizenscript.com/View/117446
Content of Server Log Paste #117446: Denizen Debug Logs From A Minecraft Server... pasted 2023/11/11 10:35:51 UTC-08:00, Paste length: 1377379 characters across 11228 lines, Content: Java Version: 17.0.1Up-time: 1h 16m
Content of Server Log Paste #117446: Denizen Debug Logs From A Minecraft Server... pasted 2023/11/11 10:35:51 UTC-08:00, Paste length: 1377379 characters across 11228 lines, Content: Java Version: 17.0.1Up-time: 1h 16m
Paper version git-Paper-550 (MC: 1.19.4)-- (Current build :white_check_mark:)
Denizen: 1.2.9-SNAPSHOT (build 1798-REL) -- (Current build :white_check_mark:)
Depenizen: 2.1.0 (build 845) -- (Outdated build, behind by 5)
@brave jasper
4 (:white_check_mark: Online)
17.0.1 :white_check_mark:
MythicMobs: 5.3.5-64893d49, ProtocolLib: 5.1.0
Perhaps I should separate the while loop part to make the debug look less chaotic?
your triggers are the issue I think. What exactly are you trying to do? slow down elytra flight and damage players?
This script is supposed to reduce the flight speed of the player's Elytra for 5 seconds after taking damage
why not just check if player is gliding on damage?
!t entity.gliding
Returns whether this entity is gliding.
attributes
ElementTag(Boolean)
EntityTag.gliding
The slowing effect gradually weakens, but when taking damage again, the slowing effect resets to its maximum
Players can end their flight in mid-air. If I directly check if the player is gliding on damage, the effect will disappear immediately
on damage
check if player is flying
flag flight deceleration with incremental assignment and expiration
call path to deceleration
path to deceleration:
check if player is flying and has deceleration flag
-adjust player's velocity
-wait for 1s
-reduce deceleration flag content
-recursive call path to deceleration
else: stop
this is something on top of my head so you might need to separate the damaged_in_flight flag and deceleration flags
but... slowing down the gliding of Elytra requires a while loop to repeatedly adjust; otherwise, the player will only pause momentarily in the air
Hmm, I am considering your suggestions. I need some time to conduct various tests. Thank you for your help!
exactly why you do recursive calls
you can adjust the wait time
the recursive calls is just to re-evaluate whether or not you should execute the call
Wait a minute, which part of the script are we discussing? I'm a bit confused...
^ this
despite it being a pseudo code it should be the steps to simulating what you are looking for
Hmm, let me think about it and try various approaches. Thanks for that!