#(zen9967) multiple else if

149 messages ยท Page 1 of 1 (latest)

hollow orioleBOT
#

(zen9967) multiple else if

#

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.

hoary shoreBOT
#
Resolved

Thread closed as resolved.

hoary shoreBOT
#
Thread Reopened

Thread was manually reopened by @tulip dew.

steady veldt
#

???

tulip dew
#

Im trying to create multiple else if but it overrides the other else if

steady veldt
#

!rule 8

vivid mortarBOT
# steady veldt !rule 8
Rule 8

Don't overuse the edit/delete buttons. https://denizenscript.com/discord_rules#rule8
Use the edit button to fix typos, and the delete button to remove an accidental post shortly after posting.
Do not remove a post that pings someone, do not edit or delete a post that people have already replied to.

tulip dew
#

sorry ๐Ÿ˜ฆ

steady veldt
#
- if thing:
  - ...
- else if thing2:
  - ...
- else if thing3:
  - ...
- else if thing4:
  - ...
- narrate "Done!"
#

Wait.

tulip dew
#

oh so i can add different names?

steady veldt
#

I don't understand.

tulip dew
#

u can see my code

#

it has multiple else ifs

steady veldt
#

A lot of this seems unnecessary.

#

!c choose

vivid mortarBOT
# steady veldt !c choose
Group

queue

Syntax

choose [<option>] [<cases>]

Short Description

Chooses an option from the list of cases.

Description

Chooses an option from the list of cases.
Intended to replace a long chain of simplistic if/else if or complicated script path selection systems.
Simply input the selected option, and the system will automatically jump to the most relevant case input.
Cases are given as a sub-set of commands inside the current command (see Usage for samples).

Optionally, specify "default" in place of a case to give a result when all other cases fail to match.

Cases must be static text. They may not contain tag...

steady veldt
#

Instead of a pyramid of else/if

tulip dew
#

im trying to create a region where player pushes away from the region

steady veldt
#

I know what you mean, I was working on that myself and never finished it.

#

Someone else smarter may come up with a solution instead of several edgecases, most likely you'll want to teleport the player a little bit bit behind their own location.

#

That might be kind of problematic if you jump in from above though.

tulip dew
#

my brain is aching with this

#

trying to use velocity

steady veldt
#

There might be a way to get the area around the cuboid and teleport them outside of it somewhere.

#

Or push them yeah.

tulip dew
#

but whenever i have multiple ifs

#

it overrides the recent iffs

#

maybe there is because ifs priority?

steady veldt
#

You probably don't need to check multiple cases like that.

tulip dew
#

it overides the latest ifs

steady veldt
#

Potentially because you're changing the players velocity and then it checks the players direction afterwards?

#

Use a choose instead

tulip dew
#

yes, like if player is facing north, he will push to south, and else if player facing south so the player wont be bugged

steady veldt
#

!t locationtag.backward

vivid mortarBOT
steady veldt
#

Try pushing them backwards some instead?

#

Like don't bother with the direction check and just push them backwards some if they enter the region?

#

Might get goofy if you drop in straight from above.

#

!c push

vivid mortarBOT
# steady veldt !c push
Group

entity

Syntax

push [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (speed:<#.#>) (duration:<duration>) (script:<name>) (def:<element>|...) (force_along) (precision:<#>) (no_rotate) (no_damage) (ignore_collision)

Short Description

Pushes entities through the air in a straight line.

Description

Pushes entities through the air in a straight line at a certain speed and for a certain duration,
triggering a script when they hit an obstacle or stop flying.

You must specify an entity to be pushed.

Usually, you should specify the origin and the destination. If unspecified, they will be assumed from contextual data.

You can specify the script to be run with the (script:<name>) argument,
and optionally specify definitions to be available in this script with the (def:<element>|...) argument.
...

tulip dew
#

it will be the same. nothing will change. I was planning to make a region where they can get pushed out on where they are facing

#

otherwise they will bug out

steady veldt
tulip dew
#

i meant like this

#

that is bug

steady veldt
#

Oh I see the problem

#

Let me double check push.

tulip dew
#

push and velocity is the same

#

the only problem is facing requirement

steady veldt
#

Yeah I see the problem, uhm.

tulip dew
#

else if is the problem for me, i dont know how i can fix it

#

because when else if 1 is in latest line and else if 2 is in lowest line

the else if 2 will not work

crimson jewel
#

!debug

vivid mortarBOT
# crimson jewel !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!

steady veldt
#

I'd definitely like someone smarter than me to figure out how to push someone away from somewhere that they're entering, since it seems adjusting velocity/push seems to have quirks when entering from the side or walking backwards.

tulip dew
#

so confusing ๐Ÿ˜ฆ

crimson jewel
#

You have to trigger the event

#

while recording

tulip dew
#

video recording?

#

you can see the last second of the video

#

whenever i change the if lines

crimson jewel
#

This uh

#

doesn't really help me understanding your issue

tulip dew
#

basically, i tried making water region that pushes out player reversely from the region. For example if player enters facing north, he will push back to the south which is the land

crimson jewel
#

I think you want a - stop

#

to stop the queue and stop checking ifs

tulip dew
#

ohhhhhhhhhhhhhhhhhhhhhhh

#

๐Ÿคฆโ€โ™‚๏ธ

#

wait ill check

#

should i put - stop in if or in else if?

#

its same issue ๐Ÿ˜ฆ

silver turretBOT
tulip dew
#

this is crazy ๐Ÿ˜ฆ

#

is this a denizen bug?

tulip dew
#

Any way i can make like this?

idle stratus
#

You don't have to check for every possible direction

#

!e enters|exits area

vivid mortarBOT
# idle stratus !e enters|exits area
Group

Entity

**WARNING**

cancelling this event will have different results depending on the cause. Teleporting the entity away 1 tick later might be safer.

Event Lines

<entity> enters|exits <area>

Triggers

when an entity enters or exits a noted area (cuboid, ellipsoid, or polygon). On Spigot servers, only fires for players. Paper is required for other mob types.

Has Player

When the entity is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.area> returns the area object that was entered or exited.
<context.cause> returns the cause of the event. Can be: WALK, WORLD_CHANGE, JOIN, QUIT, TELEPORT, VEHICLE.
<context.to> returns the location the entity moved to (might not be available in exit events).
<context.from> returns the location the entity moved from (when available, depending on cause).
<context.entity> returns the entity that entered/exited an area.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

idle stratus
#

<context.to> returns the location the entity moved to (might not be available in exit events).

#

You can substract that ^ from the player's current location and apply it as velocity

#

(Might have to play around and multiply/divide it, whatever suits what you want best)

#
    on player enters water_area:
    - actionbar "<&e>You aren't allowed to enter the water!"
    - playsound <player> sound:entity_elder_guardian_curse pitch:0.5
    - adjust <player> velocity:<player.location.sub[<context.to>].mul[2]>```
Threw this together rq to test and it seems to work fine
tulip dew
#

how do i add velocity vertically?

tulip dew
tulip dew
#

this is the bug

#

i think it will be fixed to have like whenever the player is inside region, it will keep spamming the event inorder to fix

#

because on player enters area only works when player enters and not during inside the region

#

!t

vivid mortarBOT
# tulip dew !t
Need input for '!Tag' command

Please specify a Tag to search, like !Tag SomeTagHere. Or, use !Tag all to view all documented tags.

tulip dew
#

!type

vivid mortarBOT
# tulip dew !type
Need input for '!ObjectType' command

Please specify a ObjectType to search, like !ObjectType SomeObjectTypeHere. Or, use !ObjectType all to view all documented objecttypes.

tulip dew
#

!type all

vivid mortarBOT
tulip dew
#
    type: world
    events:
       on player walks:
        - if <player.location.is_within[antiwater]>:
            - actionbar "<&e>You aren't allowed to enter the water!"
            - playsound <player> sound:entity_elder_guardian_curse pitch:0.5
            - adjust <player> velocity:<player.location.sub[<context.to>].mul[2]>```
#

tried this but it does not work

steady veldt
#

!t locationtag.within

vivid mortarBOT
#
Possible Confusion

Did you mean to search for vectorobject.with_x?

steady veldt
#

!t locationtag.is_within

vivid mortarBOT
steady veldt
#

!e player walks over

vivid mortarBOT
# steady veldt !e player walks over
Group

Player

Event Lines

player walks over notable player walks over <location>

Triggers

when a player walks over a noted location. In most cases, it is preferable to use !event player enters area with a small cuboid.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.notable> returns an ElementTag of the notable location's name.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

steady veldt
#

You can use this if you really need to check for them walking over noted locations or within areas.

#

!e player walks

vivid mortarBOT
# steady veldt !e player walks
Group

Player

**WARNING**

This event fires very very rapidly!

Event Lines

player walks

Triggers

when a player moves in the slightest.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.old_location> returns the location of where the player was.
<context.new_location> returns the location of where the player is.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

steady veldt
#

You could technically use this too with the in: switch

tulip dew
#

@idle stratus

tulip dew
#

I tried player walks and if player inside region, then the event velocity with context does not work

#

Can i do on player walks in:<region name>?

tulip dew
#

error is Invalid LocationTag specified

  • adjust <player> velocity:<player.location.sub[<context.to>].mul[2]>
#

errors pop up

For mechanism 'velocity' with value 'player.location.sub[<context.to>].mul[5]', while adjusting object

#

!sub

#

the velocity does not work when i put on player walks in:
but when i put it in event with on player enters <region> it works idk why

tulip dew
idle stratus
#

is your noted cuboid just the water?

#

Because it seems to fire before you're even close to entering it

tulip dew
#

Not just water but expand vertically

idle stratus
#

I can replicate with it expanded vertically

#

But when it's just the water blocks that are noted, I can't seem to bug it out

tulip dew
#
            - actionbar "<&e>You aren't allowed to enter the water!"
            - playsound <player> sound:entity_elder_guardian_curse pitch:0.5
            - adjust <player> velocity:<player.location.sub[<context.new_location>].mul[1]>```
#

its buggy ๐Ÿ˜ฆ

proven bone
# vivid mortar

^ that's because this isn't the right event to use, look at what the meta says - when a player moves in the slightest. it triggers when the player makes any slight movement, including it's velocity being changed, which means your script is triggering itself and just spamming

proven bone
tulip dew
#

its bugging

#

i used worldguard flags for that ^\

hoary shoreBOT
#
Changed to Help/Support

Thread is now a Help/Support thread. A helper will check your thread when available.

potent flower
#

try playing around with that

potent flower
# tulip dew

and reset player velocity to 0 after applying it so this doesnt happen

hoary shoreBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@tulip dew

hoary shoreBOT
#
Auto-Close Timeout

No response to request to close thread after 3 days. Automatically closing.

hoary shoreBOT
#
Thread Reopened

Thread was manually reopened by @cosmic hawk.