#(yukiyahana) How to ensure a while loop doesn't concurrently exist on a player

35 messages · Page 1 of 1 (latest)

untold path
#

I know there are several ways to achieve this, such as giving a player a flag and then adding a bunch of ifs. I'm worried whether I might have missed a better way.
Also, is there a way to execute a command when a while loop ends? This can also be solved with an if, but perhaps there's a better way?

last nymphBOT
#

(yukiyahana) How to ensure a while loop doesn't concurrently exist on a player

last nymphBOT
#

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.

untold path
#

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

raven maple
#

use a flag

#

!guide long term memory

knotty isleBOT
raven maple
#

a player flag specifically

#

flag while it runs, if player has the flag don't inject the script

untold path
# raven maple use a flag

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

knotty isleBOT
# brave jasper !debug
Info: 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!

untold path
brave jasper
knotty isleBOT
# brave jasper !checklog https://paste.denizenscript.com/View/117446
Server Version

Paper version git-Paper-550 (MC: 1.19.4)-- (Current build :white_check_mark:)

Plugin Version(s)

Denizen: 1.2.9-SNAPSHOT (build 1798-REL) -- (Current build :white_check_mark:)
Depenizen: 2.1.0 (build 845) -- (Outdated build, behind by 5)

Checked For

@brave jasper

UUID Version

4 (:white_check_mark: Online)

Java Version

17.0.1 :white_check_mark:

Other Noteworthy Plugin(s)

MythicMobs: 5.3.5-64893d49, ProtocolLib: 5.1.0

untold path
#

Perhaps I should separate the while loop part to make the debug look less chaotic?

brave jasper
#

your triggers are the issue I think. What exactly are you trying to do? slow down elytra flight and damage players?

untold path
brave jasper
#

!t entity.gliding

knotty isleBOT
untold path
untold path
brave jasper
#

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

untold path
#

Hmm, I am considering your suggestions. I need some time to conduct various tests. Thank you for your help!

brave jasper
#

you can adjust the wait time

#

the recursive calls is just to re-evaluate whether or not you should execute the call

untold path
#

Wait a minute, which part of the script are we discussing? I'm a bit confused...

brave jasper
#

despite it being a pseudo code it should be the steps to simulating what you are looking for

untold path
#

Hmm, let me think about it and try various approaches. Thanks for that!