#(uncvr) 'if:' arg returned false, command won't run.

24 messages · Page 1 of 1 (latest)

lyric hatch
#

I'm trying to damage an entity within 4.5 blocks of a right clicked block that is within 20 blocks of a player that is not the player themselves, and the if argument for the hurt command returns false even though the target is not a player.

The Code: https://paste.denizenscript.com/View/122851

The Console Debug:
https://paste.denizenscript.com/View/122852

dark hullBOT
#

(uncvr) 'if:' arg returned false, command won't run.

dark hullBOT
#

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.

potent jasper
#

!debug

upbeat elkBOT
# potent 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!

potent jasper
#

Please use our debug tool to record debugs

lyric hatch
potent jasper
#

Thank you, much better

#

Oh that is the global if arg

#

!lang global if

upbeat elkBOT
# potent jasper !lang global if

The "if:<boolean>" argument is a special meta-argument that is available for all commands, but is more useful for some than others.
It is written like:


- stop if:<player.has_flag[forbidden]>
# Equivalent to
- if <player.has_flag[forbidden]>:
  - stop

When the if argument is used, the command will only run if the value of the argument is 'true'.

The most useful place to have this is a 'stop' command, to quickly stop a script if a condition is true (a player has a flag, lacks a permission, is outside a region, or whatever else).

If you need more complex matching, especially using '&&', '||', '==', etc. you should probably just do an 'if' command rather than using the argument.
Though if you really want to, you can use tags here like !tag objecttag.is.to or !tag elementtag.and or !tag elementtag.or.

Group

Script Command System

potent jasper
#

iiirc if operators don't work here

#

you need to tagify them

#

!t element.equals

upbeat elkBOT
potent jasper
#

ie <[target].equals[<player>].not>

#

but also target is currently a list

#

thinking about it you probably want something else

#
- define target <[targetLoc].find_entities[living].within[4.5].exclude[<player>].first.if_null[null]>
- if <[target]> != null:
  - hurt 30 <[target]> source:<player>
#

.first returns the first entry in this list and if_null returns literal null if this fails

#

that way you make sure you have a target

#

.exclude excludes the player here

lyric hatch
#

thank you sir! 😃