#(paintsplat) Looking to make an item magnet
1 messages · Page 1 of 1 (latest)
(paintsplat) Looking to make an item magnet
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.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>
Im still learning all of this lol
I know how to check item for X nbt flag and whatnot.
I will create an MMOitem and have denizen check if that item is in player's hand. if it is pull all nearby items within 10 blocks to the player holiding it
#showcase message
this might help
why cant you make a denizen item instead?
becuase my server uses mmoitems
ah i see
I wan it to be able to be called throughmmoitems api
this and
!t locationtag.find_entities
Returns a list of entities within a radius, with an optional search parameter for the entity type.
Result list is sorted by closeness (1 = closest, 2 = next closest, ... last = farthest).
finding
ListTag(EntityTag)
Ok thanks
you can set matcher as item
btw
?
what switch do i use o check if item has X nbt
i dont think there is a switch for that
youll have to check via if statements
ok
what type of nbt tag is MMO_ITEM_TYPE <type> ?
type: task
definitions: radius
script:
- if <[item].raw_nbt> matches <some nbt>```
do i need to put in
string:(text here)
?
so```itemmagnet:
type: task
definitions: radius
script:
- if <[item].raw_nbt> matches string:MMOITEM_TYPE itemmagnet
!t <ItemTag.raw_nbt>
Returns a map of all non-default raw NBT on this item.
Refer to format details at !language Raw NBT Encoding.
properties
MapTag
ItemTag.raw_nbt
compare that i think
do /ex narrate <player.item_in_hand.raw_nbt>
in game
with the magnet in your hand
and see wht it gives you
then put that next to the == sign
Ok
way too much
i only want to check a single NBT tag @hybrid moat
specifically the string MMOITEMS_NAME = string:&9Item_Magnet
otherwise there is a crap load of NBT that changes from time to time depending on how the item is used
can you show us what .raw_nbt outputs?
I just nabbed the showcase magnet and did some modifications lol. I need to look over it tho cuz it's not perfect.
will help immensely
type: task
script:
- if <[item].raw_nbt> matches StringTag: string:(&9Item Magnet)
- foreach <player.location.find_entities[<[dropped_item]]>].within[<[10]>]> as:location:
- ```
i have this so far
do i need to indent foreach as well?
alright, try <[item].raw_nbt.get[MMOITEMS_ITEM_ID]> for me please
ok
you'll want to use the internal id instead of the item name
!g display text vs data
Did you mean to search for common mistakes - display text vs. data?
View the guide page 'Common Mistakes - Display Text vs. Data' at: https://guide.denizenscript.com/guides/troubleshooting/common-mistakes.html#display-text-vs-data
this guide page talks more about that
oop. mistype, edited
@ripe sapphire i wrote it wrong mb xD
just narrate that tag i sent you, with the definition item being the mmoitems item you wsnt
replace [item] for player.item_in_hand and it should work
tag <[player.item_in_hand].raw_nbt.get[MMOITEMS_ITEM_ID]> is invalid
forgot to take out the []
ok
just the first 2
string:ITEM_MAGNET
type: task
script:
- if <[item].raw_nbt> matches StringTag: string:ITEM_MAGNET
- foreach <player.location.find_entities[<[dropped_item]]>].within[<[10]>]> as:location:
- ```?
you just narrated it
itemmagnet:
type: task
script:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> matches ITEM_MAGNET
- foreach <player.location.find_entities[<[dropped_item]]>].within[<[10]>]> as:location:
- ```
hey i just noticed something
?
have you read the guide?
yes. I understand the basic idea Im referencing it
youre doing some common beginner mistakes that are covered in the guide
im familar with world scripts moreso
youre failing at syntax, the most basic level of any language, so me giving you any answers on this fairly complicated (for a newbie) script wont help you at all
i can only tell you to go practice more on easier things, make them work, then make them work well, and understand what makes it work and what would make it break
are you sure
the mechanic used to add a matching item
i can get it working ive written others
then get it working
Im getting together a sloppy version rn
lets do it in parts
you just got the first part, the figuring out the item, done
so now make it work
theeen we'll get to the magnet thingy
the forall lists all dropped items nearvy. i want to add that list to the players inventory if there is space
can you paste your whole current script pls
ill change to as Player
type: task
script:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> matches ITEM_MAGNET
- foreach <player.location.find_entities[<[dropped_item]]>].within[<[10]>]> as:player:
- ```
i may need to add a : after item magnet
lemme go heck syntax again
is the console not screaming at you?
1 sec
actually
No it isnt
are you using the vsc editor WITH the plugin?
yes
it would highlight and tell you these errors
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!
the only error it says is on the last line
its on
what do i do before i submit?
i
Im gettig no errors
Content of Server Log Paste #111774: Denizen Debug Logs From A Minecraft Server... pasted 2023/06/30 21:18:09 UTC-07:00, Paste length: 3504 characters across 43 lines, Content: Java Version: 17.0.3Up-time: 1d 23h
start recording
run the script
submit
send link
done
oh
and yes debugging is on in config.yml
oh what i was going to say that right now
damn man i've got no clue whats causing this
Im not totally new to this type of stuff.
we'll have to wait for a helper
gg ye
at least in denizen :P
It has no action its trying to perform
yeah your code is just filled with syntax errors, it shouldnt even run
does this need to be w world script?
not exactly, depends on what you'll use it for
if a player is holding this item i need it to bring dropped items from X radius to the player
event scripts run on, yeah, events
tasks run only when called
!e delta time
Core
delta time hourly|minutely|secondly
every:<count> to only run the event every *count* times (like "on delta time secondly every:5" for every 5 seconds).
every <count> seconds, minutes, or hours of game calculation time. Default repetitions count of 1.
This is specifically based on the rate of time advancement in the game server,
which is not necessarily equivalent to the real passage of time (for example, this event may fire slower if the server is lagging).
For real time, see !event system time.
<context.second> returns the exact delta time since system start.
thanks
this should output smt
type: world
events:
on delta time secondly every:5:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> matches ITEM_MAGNET
- foreach <player.location.find_entities[<[dropped_item]]>].within[<[10]>]> as:player:```
Idk what entity name to use for dropped item
its just dropped_item iirc
but you're naming it as a definition
should be plain text
the 10 too
type: world
events:
on delta time secondly every:5:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> matches ITEM_MAGNET:
- foreach <player.location.find_entities[dropped_item].within[10]> as:player:```\
your if is malformed, should have an : at the end AND change indent for whatever happens inside it, my guess is that its the foreach
ok
item magnet was the output of that string tag
Ok
does not work
@main comet <element[string:ITEM_MAGNET].advanced_matches[item_magnet]>
Tag parse results for <element[string:ITEM_MAGNET].advanced_matches[item_magnet]>: https://paste.denizenscript.com/View/111775
false
(advanced_matches is the tag equivalent to if's matches)
@main comet <element[string:ITEM_MAGNET].after[:]>
Tag parse results for <element[string:ITEM_MAGNET].after[:]>: https://paste.denizenscript.com/View/111776
ITEM_MAGNET
you'll use this
Ok
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> matches ITEM_MAGNET.after[:] == item_magnet:
the == a 2nd time
?
isnt it already checking matches?
you wont use matches, you'll use == (equivalent to equals)
ok
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after[:]:
read your own code
do you think thats good? would that break? what would each tag do, what would the if return?
whats tyhe parser command?
Tag parse results for - if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after[:]:: https://paste.denizenscript.com/View/111777
- if player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID] == ITEM_MAGNET.after[:]:
Had error: Player is not online, but tag 'item_in_hand' requires the player be online, for player: p@460e96b9-7a0e-416d-b2c3-4508164b8b1b (mcmonkey4eva)
Had error: Tag <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> is invalid!
Had error: Unfilled or unrecognized sub-tag(s) 'item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]' for tag <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]>!
Had error: The returned value from initial tag fragment 'player' was: 'p@460e96b9-7a0e-416d-b2c3-4508164b8b1b (mcmonkey4eva)'.
Had error: Almost matched but failed (possibly bad input?): item_in_hand
yeah it wont work because the parser's linked player not only is not holding an item, but it wouldnt have the same nbt as yourd
try it on your server
a test localhost, preferrably
I can figure out the NBT via trail and error once i get the mechanic to add items
im going to use teleport
type: world
events:
on delta time secondly every:5:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after[:]:
- foreach <player.location.find_entities[dropped_item].within[10]> as:player:
- teleport <context.item> <context.player>
that if will never be true
delta time doesnt have a player
you'll need a foreach loop through all online players
ok 1 sec
- foreach <server.online_players> as:__player: and it'll automatically change the linked player for you
I was about to
just like duct tape, slap it on and it works
yeah but the as:__player that matters
type: world
events:
on delta time secondly every:5:
- foreach <server.online_players.find_entities[dropped_item].within[10]> as:__player:
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID]> == ITEM_MAGNET:
- teleport <context.item> <context.player>
not only that
man i just outright gave you the code line exactly as it should be
Makes it look like this entity (usually a player) has picked up another entity (item, arrow, or XP orb).
This technically also works with any entity type.
Note that the original entity doesn't actually get picked up, it's still there, just invisible now.
EntityTag
EntityTag
Oh
I see @candid oxide
dudes dropping end solution while we're still at the start kek
i didnt erealize you meant literally
[06:50:28 INFO]: Comparing if player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID] EQUALS ITEM_MAGNET ... false
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after[:]:```
both return false
isee
<>
i thought i put an extra x
i did
they both return false
i tried with get as well
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> == ITEM_MAGNET].after[:]:
also returns false
you're still ignoring me
this is why i asked about ==?
<player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]>
this tag, returns:
string:ITEM_MAGNET
we want to get rid of the "string:" part
that was an example, im sorry if it confused you
yea
so, .after[:]
that would make it just ITEM_MAGNET
which is what i was doing here
nope
- if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == ITEM_MAGNET:
closer
- if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == [ITEM_MAGNET]:
- if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after:
- if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == [ITEM_MAGNET].after:
what does this return
ITEM_MAGNET
string:ITEM_MAGNET
ITEM_MAGNET
I dont know.
you told me b4 so i did what i understod
and it eneded up wrong
so im 2nd guessing what i did to begin with
yeah what you did before was wrong, we're trying to correct it now
but i need you to follow me
what is the tag that would split them and get only the relevant part?
then i actually have no idea
type: world
events:
on delta time secondly every:5:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get.after[MMOITEMS_ITEM_ID]> == [ITEM_MAGNET]:
- foreach <server.online_players.find_entities[dropped_item].within[10]> as:player:
- teleport <context.item> <context.player>
- adjust <context.player> fake_pickup:<context.item>```
do you put it in the tag, or in the plaintext value you're comparing it to?
again, i gave you the tag as it should be
I dont understand then.
look at this, this is what the tag does
it took string:item_magnet, and returned only item_magnet
ok i think i see
if this isnst it im 100% lost
type: world
events:
on delta time secondly every:5:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after> == [ITEM_MAGNET]:
- foreach <server.online_players.find_entities[dropped_item].within[10]> as:player:
- teleport <context.item> <context.player>
- adjust <context.player> fake_pickup:<context.item>
you're THIS close
type: world
events:
on delta time secondly every:5:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <server.online_players.find_entities[dropped_item].within[10]> as:player:
- teleport <context.item> <context.player>
- adjust <context.player> fake_pickup:<context.item>```
again, the tag is exactly as it should be
3 characters more and it's done
you forgot something after the .after
YES
im glad you understood it by yourself
now that i see the end product i can read back and understand it
now, to the rest of it
it'll be quick
your 2nd foreach is wrong, you've already looped through all online players
just change server.online_players to player
and there's no context.player, just player
btw the if command is still returning false
shouldn't
i see
only if you're not holding the right item or smth
item nbt matched buut is inva;lid for the object
i changed it to a world script
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!
instructions
Content of Server Log Paste #111778: Denizen Debug Logs From A Minecraft Server... pasted 2023/06/30 22:13:23 UTC-07:00, Paste length: 14151 characters across 120 lines, Content: Java Version: 17.0.3Up-time: 2d
maybe put a wildcard
I tried that too. ill submit that next
not .raw_nbt[blahblahblah]
also returned false
hm
Content of Server Log Paste #111779: Denizen Debug Logs From A Minecraft Server... pasted 2023/06/30 22:15:59 UTC-07:00, Paste length: 46396 characters across 387 lines, Content: Java Version: 17.0.3Up-time: 2d
Ok i see
I made a typo last time
It is returning true now
Yea.
I just need to figure out which entity tag to use
hold on
Content of Server Log Paste #111784: Denizen Debug Logs From A Minecraft Server... pasted 2023/06/30 22:25:14 UTC-07:00, Paste length: 42960 characters across 364 lines, Content: Java Version: 17.0.3Up-time: 2d 1h
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.find_entities[dropped_item].within[10]> as:player:
- teleport <dropped_item> <player.location>
- adjust <player> fake_pickup:<dropped_item>```
the paste has an internal error with denizen
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.find_entities[dropped_item].within[10]> as:player:
- teleport <dropped_item> <player.location>
- adjust <player> fake_pickup:<entity.[dropped_item]>```
what entity tag should i use for fake pickup and teleport?
Ive tried a binch of stuff inclding
<entity.[dropped_item]> | <context.entity> | <entity.item>
etc
look at your foreach
its using as:
switch that as to like
ent
and thats your variable
Ok
for dropped item
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.find_entities[dropped_item].within[10]> as:entity:
- teleport <context.entity> <player.location>
- adjust <player> fake_pickup:<context.entity>```
<context.entity> is invalid it is saying
i also tried <entity>
entity.item
also invalid
@hybrid moat https://paste.denizenscript.com/View/111785
Content of Server Log Paste #111785: Denizen Debug Logs From A Minecraft Server... pasted 2023/06/30 22:54:20 UTC-07:00, Paste length: 41588 characters across 335 lines, Content: Java Version: 17.0.3Up-time: 21m
cannot interpret <entity.[dropped_item]> as entity tag
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.location.find_entities[dropped_item].within[10]> as:entity:
- teleport <entity> <player.location>```
im so confused
what do i need to put here?
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.location.find_entities[dropped_item].within[10]> as:player:
- teleport %SOMETHING% <player.location>```
I need to fix %SOMTHING% with something referencing the items froun in the 10 block radius
I also tried
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.location.find_entities[dropped_item].within[10]> as:entity:
- teleport %SOMETHING% <player.location>```
with no success
/parse itemmagnet:
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.location.find_entities[dropped_item].within[10]> as:entity:
- teleport %SOMETHING% <player.location>
Tag parse results for (Spam): https://paste.denizenscript.com/View/111786
Input too long, refused.```
Tag parse results for - foreach <player.location.find_entities[dropped_item].within[10]> as:player: - teleport <entity.[dropped_item]> <player.location>: https://paste.denizenscript.com/View/111787
- foreach player.location.find_entities[dropped_item].within[10] as:player: - teleport entity.[dropped_item] [email protected],70,239.77639493281197,26.400015,173.992081,world
Had internal exception: IllegalStateException-Asynchronous getNearbyEntities!
Had error: Tag-base 'player' returned null.
Had error: Tag <player.location.find_entities[dropped_item].within[10]> is invalid!
Had error: Unfilled or unrecognized sub-tag(s) 'within[10]' for tag <player.location.find_entities[dropped_item].within[10]>!
Had error: The returned value from initial tag fragment 'player.location.find_entities[dropped_item]' was: '[email protected], 70, 239.77639493281197, 26.400015, 173.992081, world'.
Had error: Tag-base 'entity' returned null.
Had error: Tag <entity.[dropped_item]> is invalid!
Had error: Unfilled or unrecognized sub-tag(s) 'entity.[dropped_item]' for tag <entity.[dropped_item]>!
Tag parse results for - foreach <player.location.find_entities.within[10]> as:player: - teleport <entity.[dropped_item]> <player.location>: https://paste.denizenscript.com/View/111788
- foreach player.location.find_entities.within[10] as:player: - teleport entity.[dropped_item] [email protected],70,239.77639493281197,26.400015,173.992081,world
Had internal exception: IllegalStateException-Asynchronous getNearbyEntities!
Had error: Tag-base 'player' returned null.
Had error: Tag <player.location.find_entities.within[10]> is invalid!
Had error: Unfilled or unrecognized sub-tag(s) 'within[10]' for tag <player.location.find_entities.within[10]>!
Had error: The returned value from initial tag fragment 'player.location.find_entities' was: '[email protected], 70, 239.77639493281197, 26.400015, 173.992081, world'.
Had error: Tag-base 'entity' returned null.
Had error: Tag <entity.[dropped_item]> is invalid!
Had error: Unfilled or unrecognized sub-tag(s) 'entity.[dropped_item]' for tag <entity.[dropped_item]>!
It parses tags, not run scripts
But based on earlier in this thread, please try stopping, taking a step back, and thinking about what each bit does it figure out the proper syntax
- foreach <player.location.find_entities[dropped_item].within[10]> as:entity:
- teleport %SOMETHING% <player.location>
You know <player.location.find_entities[dropped_item].within[10]> returns a ListTag of entities, and you want to teleport each one
Generally you'd need to loop over them yeah, but in this case
!c teleport
entity
teleport (<entity>|...) [<location>] (cause:<cause>) (entity_options:<option>|...) (relative) (relative_axes:<axis>|...)
Teleports the entity(s) to a new location.
Teleports the entity or entities to the new location.
Entities can be teleported between worlds using this command.
You may optionally specify a teleport cause for player entities, allowing proper teleport event handling. When not specified, this is "PLUGIN". See !language teleport cause for causes.
Instead of a valid entity, an unspawned NPC or an offline player may also be used.
Optionally specify "relative" to use relative teleportation (Paper only). This is primarily useful only for...
(<entity>|...) it takes a ListTag of entities, not just a single one
So you can feed your list in directly instead of looping over it
And also <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> that's valid, but what if the player's item in hand doesn't have that NBT at all? that would cause it to error
The easier way to fix that would be a fallback
!l tag fallbacks
Tag fallbacks (AKA "tag alternatives") are a system designed to allow scripters to automatically handle tag errors.
Fallbacks are implemented as special "magic tags" that look like any other tag-part, but override the error handler. These are "if_null", "exists", and "is_truthy".
A tag without a fallback might look like "<player.name>".
This tag works fine as long as there's a linked player, but what if a player isn't always available?
Normally, this situation would display an error in the console debug logs, and return plaintext "player.name" in the script.
A fallback can help us handle the problem more gracefully.
That same tag with a fallback would look like "<player.name.if_null[Steve]>".
Now, when there isn't a player available, there will not be an error, and the tag will simply re...
Tag System
If you make it fallback to something that isn't ITEM_MAGNET, then the tag would return that if the item doesn't have the NBT, compare that to ITEM_MAGNET, and not pass since it isn't equal
could not interpret object '...)' as an entity tag
and (<entity>) says unrecognized sub tags
- teleport (<entity[dropped_item]>) <player.location>
cannot interpreet e@dropped_item as entity tag
<context.entity> is invalid
!l command syntax
Almost every Denizen command and requirement has arguments after the command itself.
These arguments are just snippets of text showing what exactly the command should do,
like what the chat command should say, or where the look command should point.
But how do you know what to put in the arguments?
You merely need to look at the command's usage/syntax info.
Let's take for example:
- animatechest [<location>] ({open}/close) (sound:{true}/false)
Obviously, the command is 'animatechest'... but what does the rest of it mean?
Anything in [brackets] is required... you MUST put it there.
Anything in (parenthesis) is optional... you only need to put it there if you want to.
Anything in {braces} is default... the command will just assume this if no argument is actually typed.
Anyth...
Script Command System
It's not literal things you'd include, it's the syntax
i dont know what to put for the entity tag
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- foreach <player.location.find_entities[dropped_item].within[10]> as:player:
- teleport (<entity.uuid>) <player.location>```
etc
It takes in a list of entity tags, that's what you already have
i have tried various things
.
You're just guessing, take a step back for a minute, read the responses so far carefully, and try seeing what's the correct solution
i did. i really have no idea
list tag?
but again
I dont know which one
theres no listtag.entity
<ListTag.find_all[<element>]>?
I see its likley list tag
So you can feed your list in directly instead of looping over it
instead of looping over itI.e. you don't need a loop, can just feed your list directly
!l command syntax
I pulled up a page explaining the syntax ^, which saysLastly, input that ends with "|..." (EG, [<entity>|...] ) can take a list of the input indicated before it (In that example, a list of entities), and also explains that the()bits and all aren't literal, but mean that the argument is optionalAnything in (parenthesis) is optional... you only need to put it there if you want to.
It takes in a list of entity tags, that's what you already have
You already have a tag in your code that returns the list of entities you want to teleport, which you are currently looping over, but can just feed directly into theteleportcommand instead
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>
Like so?
Yeah :D
its working now thanks
Ill use an else statement else do nothign
if the nbt doesnt match
It will do nothing by default, you only need an else if you want it to do something
Ok
I turn debug off so im not worried about a fallback in this instance
it doesnt need anything to be handled
Errors still appear with debug: false - but either way, you shouldn't be trying to suppress errors, you should be fixing them
this is a rough idea of the code
debug: false
type: world
events:
on delta time secondly every:1:
- define fallback nomagnet:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>
- if <[fallback]> != ITEM_MAGNET
- stop```
i got it working
debug: false
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].exists[NO_MAGNET]>:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>```
but if_null works too
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].exists[NO_MAGNET]>:
This line should also be erroring
it isnt
!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!
Can you proof that via debug
Content of Server Log Paste #111815: Denizen Debug Logs From A Minecraft Server... pasted 2023/07/01 11:33:24 UTC-07:00, Paste length: 3447 characters across 41 lines, Content: Java Version: 17.0.3Up-time: 12h 10m
Content of Server Log Paste #111816: Denizen Debug Logs From A Minecraft Server... pasted 2023/07/01 11:33:49 UTC-07:00, Paste length: 3447 characters across 41 lines, Content: Java Version: 17.0.3Up-time: 12h 10m
Can you turn on debug for that script
ok
Content of Server Log Paste #111817: Denizen Debug Logs From A Minecraft Server... pasted 2023/07/01 11:34:34 UTC-07:00, Paste length: 10466 characters across 98 lines, Content: Java Version: 17.0.3Up-time: 12h 11m
and the magnet works
ill send a snippet of me holdingf that
wtf
Content of Server Log Paste #111818: Denizen Debug Logs From A Minecraft Server... pasted 2023/07/01 11:35:44 UTC-07:00, Paste length: 12893 characters across 116 lines, Content: Java Version: 17.0.3Up-time: 12h 12m
Tag parse results for <map[a=1;b=2;c=3].{: https://paste.denizenscript.com/View/111819
<map[a=1;b=2;c=3].{
Tag parse results for <map[a=1;b=2;c=3].[2]>: https://paste.denizenscript.com/View/111820
map[a=1;b=2;c=3].[2]
Had error: Tag <map[a=1;b=2;c=3].[2]> is invalid!
Had error: Unfilled or unrecognized sub-tag(s) '[2]' for tag <map[a=1;b=2;c=3].[2]>!
Had error: The returned value from initial tag fragment 'map[a=1;b=2;c=3]' was: 'map@[a = 1; b = 2; c = 3]'.
Had error: Almost matched but failed (possibly bad input?):
thats the nbt tag its checking for
It's not erroring because it has a fallback on it lol
Tag parse results for <map[a=1;b=2;c=3].[b]>: https://paste.denizenscript.com/View/111821
2
YIKES
Oh yeah, that as well, forgot MapTags had that
Yeah so that's valid right
this:
debug: true
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].exists[NO_MAGNET]>:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>```
works as intended
Technically? I don't think it's documented anywhere/recommended
No I mean Denizenlike, not !itworks
But either way, should probably prefer if_null there, it will both greatly simplify the code and avoid reading the item's entire NBT twice
I wonder if that's a side effect of submapping in definitions
But I think it's some legacy undocumented util thing? monkey would probably know, I only know about it from looking through that code earlier
or actual a thing
^ it's explicitly registered, it's not an accident or anything
anyways thanks.
debug: false
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].if_null[NO_MAGNET]> or <player.item_in_offhand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].if_null[NO_MAGNET]>:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> or <player.item_in_offhandhand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>```
heres the finished product
If the object is null (or the tag errors), this will return the input object.
If the object isn't null, the input won't be parsed, and the original object will be returned.
For example, "<player.if_null[<npc>]>" will return the player if there is a player, and otherwise will return the NPC.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.
ObjectTag
If the object is null (or the tag errors), this will return the input object.
You can't just put it directly in an if like that, as if expects a boolean (true/false)
You only ever need once check in here, if <get the NBT value> == MAGENT
The only problem is that the <get the NBT value> part can error if there isn't an NBT value
So all you'd want to do is add a fallback on that
Its simpler to do exists then
which is what i hd in the st place
No, because exists would mean you need to have the tag twice
<NBT.if_null[null]> == magent, <NBT.exists> && <NBT> == MAGENT
debug: false
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].if_null[NO_MAGNET]> or <player.item_in_offhand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].if_null[NO_MAGNET]>:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> or <player.item_in_offhandhand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>```
this works 100% fine
wtf
that looks so wrong
First of all, x or y == someting isn't what you think it is, it's whether x is true or y is equal to something
Again, please read our responses ^
All you need is if <NBT value> == MAGENT, the only problem with that is that <NBT value> can error, so you add a fallback - if <NBT value.if_null[null]> == MAGENT; that way if it errors it will return null, which isn't equal to MAGENT so it won't pass
yea ive fixed that. I noticed
debug: false
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].exists[NO_MAGNET]> or <player.item_in_offhand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].exists[NO_MAGNET]>:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET or <player.item_in_offhandhand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>```
i did x == 1 or y == 1
i didnt notice at first that all mmoitems were acting as magnets. i looked at the file ahd made the chanes i posted and its fixed
i understand that i can do it with is_null
I just already have it working
I mean, sure, it's just a bad practice and makes your code messier
And technically makes it 2x less performance, as it's doing everything twice
Also
!t exists
the or is to check in hand or offhand
.exists[NO_MAGNET] ^ it doesn't take a param
Yeah, but you do the checks twice - once for the exists and once for the actual check
!t ObjectTag.exists
Returns true if the object exists (is non-null). Returns false if the object doesn't exist, is null, or the tag errored.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.
ElementTag(Boolean)
debug: false
type: world
events:
on delta time secondly every:1:
- foreach <server.online_players> as:__player:
- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:].is_null[null]> == ITEM_MAGNET or <player.item_in_offhandhand.raw_nbt.get[MMOITEMS_ITEM_ID].after[:].is_null[null]> == ITEM_MAGNET:
- teleport <player.location.find_entities[dropped_item].within[10]> <player.location>```
like this?
And that (your older one) can still break, as your first if checks if the main or off hand have that NBT, but your next if checks both
no?
Yep, that looks better
Was commenting on that one ^
ah
Probably just a typo, but you have is_null instead of if_null there
yea
want paying attention
didnt make sure i had it correct
this was written by one of our other admins btw
type: task
definitions: range|particles
script:
- if !<[range].exists>:
- define range 10
- attack <player.location.find_entities[monster].within[<[range]>]> target:<player>
- playsound <player.location> sound:entity_ender_dragon_growl
- playeffect effect:REDSTONE at:<player.location> special_data:1.9|red quantity:<[particles]> offset:<[range]>
decast_taunt_skill:
type: command
name: decast_taunt
description: Casts taunt
usage: /decast_taunt
permission: server
script:
- if !<context.args.get[1].exists>:
- stop
- if !<context.args.get[1].is_decimal>:
- stop
- if !<context.args.get[2].exists>:
- stop
- if !<context.args.get[2].is_decimal>:
- stop
- run taunt_skill def.range:<context.args.get[1]> def.particles:<context.args.get[2]>``` its an rpg server and taunt makes mobs aggro on the caster instead of their current target
the permission is wrong
But
apart from that
Should probably make a new post if you have any questions about that
I mean, it looks fine at a glance - if you're having any actual issues/specific questions can make a post with that
But for the original question in this thread, just noticed it wasn't mentioned - is there any reason you're not using a Denizen item script for this?
Unless you have any specific reason to make it with MMO, using a Denizen script will make it a lot easier to integrate within other Denizen scripts
(As simple as <item> matches my_script, in your case)
I use mmoitems as my main items plugin. i need these items to be accessible through mmoitems, mythic mobs drop tables and such
most functionality is within mmoitems
there are a few edge cases where i need custom functions
mythicmobs allows some skill casting too
Depenizen has MM integration, so could request support for Denizen items in MM drop tables if you'd like
Either way if this is resolved then
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.)
@ripe sapphire
what i would like is depenizen to have a dirrect mmoitems check
mmocore stuff can be done via placeholder api
That's not possible sadly, as it's premium and forbids redestrbuting jar files
Which makes it impossible for Depenizen to support it
no
they have an API
depenizen can check for when these api events and stuff are called
I know, but Depenizen requires a Jar to be included in it's dependencies
For both dependency reasons (I.e. with such a massive amount of dependencies, especially with some more obscure plugins, it not unlikely that some repo goes down), and also contributing reasons, I.e. anyone trying to contribute should be able to access a jar for testing
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.)
@ripe sapphire