#(zen9967) multiple else if
149 messages ยท Page 1 of 1 (latest)
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.
Thread closed as resolved.
Thread was manually reopened by @tulip dew.
???
Content of Denizen Script Paste #122009: Unnamed Denizen Script Paste... pasted 2024/04/15 10:31:52 UTC-07:00, Paste length: 4781 characters across 75 lines, Content: testwater: type: world
Im trying to create multiple else if but it overrides the other else if
!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.
sorry ๐ฆ
- if thing:
- ...
- else if thing2:
- ...
- else if thing3:
- ...
- else if thing4:
- ...
- narrate "Done!"
Wait.
oh so i can add different names?
I don't understand.
queue
choose [<option>] [<cases>]
Chooses an option from the list of cases.
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...
Instead of a pyramid of else/if
im trying to create a region where player pushes away from the region
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.
There might be a way to get the area around the cuboid and teleport them outside of it somewhere.
Or push them yeah.
but whenever i have multiple ifs
it overrides the recent iffs
maybe there is because ifs priority?
You probably don't need to check multiple cases like that.
it overides the latest ifs
Potentially because you're changing the players velocity and then it checks the players direction afterwards?
Use a choose instead
yes, like if player is facing north, he will push to south, and else if player facing south so the player wont be bugged
!t locationtag.backward
Returns the location behind this location based on pitch and yaw. Optionally specify a number of blocks to go backward.
This is equivalent to !tag LocationTag.forward in the opposite direction.
math
LocationTag
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
entity
push [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (speed:<#.#>) (duration:<duration>) (script:<name>) (def:<element>|...) (force_along) (precision:<#>) (no_rotate) (no_damage) (ignore_collision)
Pushes entities through the air in a straight line.
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.
...
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
You're going to push them out by shoving them forward?
Yeah I see the problem, uhm.
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
!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'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.
Content of Server Log Paste #122010: Denizen Debug Logs From Server... pasted 2024/04/15 10:49:09 UTC-07:00, Paste length: 937 characters across 17 lines, Content: Java Version: 17.0.10Up-time: 1h 48m
so confusing ๐ฆ
video recording?
you can see the last second of the video
whenever i change the if lines
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
ohhhhhhhhhhhhhhhhhhhhhhh
๐คฆโโ๏ธ
wait ill check
should i put - stop in if or in else if?
its same issue ๐ฆ
Any way i can make like this?
Do you just want the players to be pushed backwards when they try to enter the water?
You don't have to check for every possible direction
!e enters|exits area
Entity
cancelling this event will have different results depending on the cause. Teleporting the entity away 1 tick later might be safer.
<entity> enters|exits <area>
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.
When the entity is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
<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.
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
<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
You're great man !!
how do i add velocity vertically?
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
!type
!type all
Find all ObjectTypes at https://meta.denizenscript.com/Docs/ObjectTypes/
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
!t locationtag.within
Did you mean to search for vectorobject.with_x?
!t locationtag.is_within
Returns whether the location is within the specified area (cuboid, ellipsoid, polygon, ...).
areas
ElementTag(Boolean)
Why are you checking for them walking and not entering?
!e player walks over
Player
player walks over notable player walks over <location>
when a player walks over a noted location. In most cases, it is preferable to use !event player enters area with a small cuboid.
Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
<context.notable> returns an ElementTag of the notable location's name.
True - this adds switches in:<area> + location_flagged:<flag name>.
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
You can use this if you really need to check for them walking over noted locations or within areas.
!e player walks
Player
This event fires very very rapidly!
player walks
when a player moves in the slightest.
Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
<context.old_location> returns the location of where the player was.
<context.new_location> returns the location of where the player is.
True - this adds switches in:<area> + location_flagged:<flag name>.
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
You could technically use this too with the in: switch
@idle stratus
Because it will bug the player ๐ฆ
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>?
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
I can't replicate this
is your noted cuboid just the water?
Because it seems to fire before you're even close to entering it
Not just water but expand vertically
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
- 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 ๐ฆ
^ 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
See what Tech said though, can use the proper enter area event and try resizing the cuboid to just the water
its bugging
i want it to look like this but player gets pushed so it has good visual unlike teleporting
i used worldguard flags for that ^\
Thread is now a Help/Support thread. A helper will check your thread when available.
<player.location.sub[<context.new_location.below[0.5]>].normalize>
try playing around with that
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
No response to request to close thread after 3 days. Automatically closing.
Thread was manually reopened by @cosmic hawk.