#(paintsplat) Looking to make an item magnet

1 messages · Page 1 of 1 (latest)

ripe sapphire
#

I dont know where to begin with this one.

I can figure out how to do it. But which mechanisms should i use to pull in nearby dropped items to a player?

silent compassBOT
#

(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>

ripe sapphire
#

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

hybrid moat
#

this might help

hybrid moat
ripe sapphire
#

becuase my server uses mmoitems

latent parrotBOT
hybrid moat
#

ah i see

ripe sapphire
#

I wan it to be able to be called throughmmoitems api

hybrid moat
#

!t locationtag.find_entities

dark jackalBOT
ripe sapphire
#

Ok thanks

hybrid moat
#

you can set matcher as item

ripe sapphire
#

btw

hybrid moat
#

?

ripe sapphire
#

what switch do i use o check if item has X nbt

hybrid moat
#

youll have to check via if statements

ripe sapphire
#

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

hybrid moat
#

!t nbt

dark jackalBOT
# hybrid moat !t nbt
Cannot Specify Searched Tag

Multiple possible tags: <ItemTag.raw_nbt>, <BinaryTag.nbt_to_map>, <MapTag.map_to_nbt>, <ItemTag.all_raw_nbt>, <server.nbt_attribute_types>.

hybrid moat
#

!t <ItemTag.raw_nbt>

dark jackalBOT
hybrid moat
#

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

ripe sapphire
#

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

candid oxide
#

can you show us what .raw_nbt outputs?

opal dome
#

I just nabbed the showcase magnet and did some modifications lol. I need to look over it tho cuz it's not perfect.

candid oxide
ripe sapphire
#
    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?

candid oxide
# ripe sapphire

alright, try <[item].raw_nbt.get[MMOITEMS_ITEM_ID]> for me please

ripe sapphire
#

ok

candid oxide
#

you'll want to use the internal id instead of the item name

#

!g display text vs data

dark jackalBOT
#
Possible Confusion

Did you mean to search for common mistakes - display text vs. data?

candid oxide
#

this guide page talks more about that

candid oxide
#

@ripe sapphire i wrote it wrong mb xD

ripe sapphire
#

what command should irun?

#

invalid definition name item

candid oxide
#

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

ripe sapphire
#

tag <[player.item_in_hand].raw_nbt.get[MMOITEMS_ITEM_ID]> is invalid

candid oxide
#

forgot to take out the []

ripe sapphire
#

ok

candid oxide
#

just the first 2

ripe sapphire
#

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:
        - ```?
candid oxide
#

nope

#

you have both the tag and it's output

ripe sapphire
#

how?

#

oih

candid oxide
#

you just narrated it

ripe sapphire
#
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:
        - ```
candid oxide
#

hey i just noticed something

ripe sapphire
#

?

candid oxide
#

have you read the guide?

ripe sapphire
#

yes. I understand the basic idea Im referencing it

candid oxide
#

youre doing some common beginner mistakes that are covered in the guide

ripe sapphire
#

I remember reading it before

#

I learn best by practicing rather than just reading

candid oxide
#

then go read it again, internalize it really well

#

but here you're not practicing

ripe sapphire
#

im familar with world scripts moreso

candid oxide
#

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

ripe sapphire
#

Im understanding it

#

I see why what is there now works

candid oxide
#

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

ripe sapphire
#

so that means your stopping this one?

#

theres only 1 more piece missing

candid oxide
#

are you sure

ripe sapphire
#

the mechanic used to add a matching item

candid oxide
#

the script is not meant to be working

#

if it is i'll be surprised

ripe sapphire
#

i can get it working ive written others

candid oxide
#

then get it working

ripe sapphire
#

Im getting together a sloppy version rn

candid oxide
#

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

ripe sapphire
#

the forall lists all dropped items nearvy. i want to add that list to the players inventory if there is space

candid oxide
#

can you paste your whole current script pls

ripe sapphire
#

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

candid oxide
#

is the console not screaming at you?

ripe sapphire
#

1 sec

candid oxide
#

actually

ripe sapphire
#

No it isnt

candid oxide
#

are you using the vsc editor WITH the plugin?

ripe sapphire
#

yes

candid oxide
#

it would highlight and tell you these errors

candid oxide
#

!debug

dark jackalBOT
# candid oxide !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!

ripe sapphire
#

the only error it says is on the last line

candid oxide
#

yeyea thats expected

#

but debug pls

ripe sapphire
#

its on

#

what do i do before i submit?

#

i

#

Im gettig no errors

candid oxide
#

start recording
run the script
submit
send link

ripe sapphire
#

done

candid oxide
#

oh

ripe sapphire
#

and yes debugging is on in config.yml

candid oxide
#

oh what i was going to say that right now

#

damn man i've got no clue whats causing this

ripe sapphire
#

Im not totally new to this type of stuff.

candid oxide
#

we'll have to wait for a helper

ripe sapphire
#

Ive been running my server for almost 10 years

#

denizen is just unfamilar syntax

candid oxide
#

gg ye

ripe sapphire
#

you assumed i was a newbie xD

#

what do you mean its not working tho?

candid oxide
#

at least in denizen :P

ripe sapphire
#

It has no action its trying to perform

candid oxide
ripe sapphire
#

does this need to be w world script?

candid oxide
#

not exactly, depends on what you'll use it for

ripe sapphire
#

if a player is holding this item i need it to bring dropped items from X radius to the player

candid oxide
#

event scripts run on, yeah, events
tasks run only when called

ripe sapphire
#

Is there a timer trigger?

#

to call X task on timer?

candid oxide
#

!e delta time

dark jackalBOT
# candid oxide !e delta time
Group

Core

Event Lines

delta time hourly|minutely|secondly

Switches

every:<count> to only run the event every *count* times (like "on delta time secondly every:5" for every 5 seconds).

Triggers

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

<context.second> returns the exact delta time since system start.

ripe sapphire
#

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

candid oxide
#

its just dropped_item iirc

#

but you're naming it as a definition

#

should be plain text

#

the 10 too

ripe sapphire
#
    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:```\
candid oxide
#

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

ripe sapphire
#

ok

candid oxide
#

i,, dont think matches item_magnet would work in that if?

#

lemme try smth rq

ripe sapphire
#

item magnet was the output of that string tag

candid oxide
#

yeah i remember

#

but it outputs string:item_magnet

#

i'll test it

ripe sapphire
#

Ok

candid oxide
#

does not work

#

@main comet <element[string:ITEM_MAGNET].advanced_matches[item_magnet]>

main cometBOT
candid oxide
#

(advanced_matches is the tag equivalent to if's matches)

#

@main comet <element[string:ITEM_MAGNET].after[:]>

main cometBOT
candid oxide
#

you'll use this

ripe sapphire
#

yea

#

thats what i already hgad

candid oxide
#

so, the whole raw_nbt tag and whatnot

#
  • .after[:]
#

== item_magnet

ripe sapphire
#

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?

candid oxide
#

you wont use matches, you'll use == (equivalent to equals)

ripe sapphire
#

ok

#

- if <player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after[:]:

candid oxide
#

read your own code

#

do you think thats good? would that break? what would each tag do, what would the if return?

ripe sapphire
#

whats tyhe parser command?

main cometBOT
#

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
candid oxide
#

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

ripe sapphire
#

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>
candid oxide
#

that if will never be true

ripe sapphire
#

I see hold on

#

its missing player now

#

hold on

candid oxide
#

delta time doesnt have a player

#

you'll need a foreach loop through all online players

ripe sapphire
#

ok 1 sec

candid oxide
#

- foreach <server.online_players> as:__player: and it'll automatically change the linked player for you

ripe sapphire
#

I was about to

candid oxide
#

just like duct tape, slap it on and it works

ripe sapphire
#

I had the first

#

it was the __

#

cat the as:__

#

that i wouldnt have caught

candid oxide
#

yeah but the as:__player that matters

ripe sapphire
#
    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>
candid oxide
#

that a closer look to that

#

you just butchered it completely

ripe sapphire
#

i forgot after[:]:

#

i think

candid oxide
#

not only that

ripe sapphire
#

hol don

#

ill add a 2nd for foreach

candid oxide
#

man i just outright gave you the code line exactly as it should be

hybrid moat
#

use the

#

!m fake_pickup

dark jackalBOT
# hybrid moat !m fake_pickup

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.

Object

EntityTag

Input

EntityTag

ripe sapphire
#

Oh

hybrid moat
#

might look better

#

in combination w teleport

ripe sapphire
#

I see @candid oxide

candid oxide
#

dudes dropping end solution while we're still at the start kek

ripe sapphire
#

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

#

<>

candid oxide
#

nah

#

i told you before where to put that .after

#

you just ignored me

ripe sapphire
#

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
candid oxide
#

you're still ignoring me

ripe sapphire
#

i dont understand what you mean then

#

you told me to put .after

#

[:]

candid oxide
#

yeaaaahhhhh, but where?

#

lets take a step back

ripe sapphire
#

this is why i asked about ==?

candid oxide
#

<player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]>
this tag, returns:
string:ITEM_MAGNET

candid oxide
#

we want to get rid of the "string:" part

candid oxide
ripe sapphire
#

yea

candid oxide
#

that would make it just ITEM_MAGNET

ripe sapphire
#

I also did that

#

returned false

candid oxide
candid oxide
ripe sapphire
#
  • if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == ITEM_MAGNET:
candid oxide
#

closer

ripe sapphire
#
  • if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == [ITEM_MAGNET]:
candid oxide
#

just have to put that .after in there

#

backtracked

ripe sapphire
#
  • if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == ITEM_MAGNET.after:
candid oxide
#

AAAAAAHH

#

cmon think with me

#

<player.item_in_hand.raw_nbt.get[MMOITEMS_ITEM_ID]>

ripe sapphire
#
  • if <player.item_in_hand.raw_nbt[MMOITEMS_ITEM_ID]> == [ITEM_MAGNET].after:
candid oxide
#

what does this return

ripe sapphire
#

ITEM_MAGNET

candid oxide
#

what does that tag give

#

no

#

try it again, see what it gives

ripe sapphire
#

string:ITEM_MAGNET

candid oxide
#

yes

#

what's the relevant part of that value

ripe sapphire
#

ITEM_MAGNET

candid oxide
#

yes

#

so, what do you do to separate these, and get only the relevant part?

ripe sapphire
#

I dont know.

candid oxide
#

ive shown and said it to you multiple times

#

read up

ripe sapphire
#

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

candid oxide
#

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?

ripe sapphire
#

lemme go check

#

<nbt.get[MMOITEMS_ITEM_ID]>

candid oxide
#

nope, that returns string:item_magnet

#

and the relevant part is only item_magnet

ripe sapphire
#

then i actually have no idea

candid oxide
#

.after[:]

#

now, where do you put that?

ripe sapphire
#
    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>```
latent parrotBOT
candid oxide
#

do you put it in the tag, or in the plaintext value you're comparing it to?

candid oxide
ripe sapphire
#

I dont understand then.

candid oxide
#

it took string:item_magnet, and returned only item_magnet

ripe sapphire
#

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>
candid oxide
#

you're THIS close

ripe sapphire
#
    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>```
candid oxide
#

again, the tag is exactly as it should be

#

3 characters more and it's done

#

you forgot something after the .after

#

YES

ripe sapphire
#

ok i understand now

#

thank you

candid oxide
#

im glad you understood it by yourself

ripe sapphire
#

now that i see the end product i can read back and understand it

candid oxide
#

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

ripe sapphire
#

btw the if command is still returning false

candid oxide
#

shouldn't

ripe sapphire
#

i see

candid oxide
#

only if you're not holding the right item or smth

ripe sapphire
#

item nbt matched buut is inva;lid for the object

candid oxide
#

oh btw how are you reading these debugs if your debug doesnt show up

#

im intrigued

ripe sapphire
#

i changed it to a world script

candid oxide
#

oh so it works now

#

damn

#

alrighty so debug time

#

!debug

dark jackalBOT
# candid oxide !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!

candid oxide
#

instructions

ripe sapphire
#

maybe put a wildcard

candid oxide
#

oh, got it

#

you got rid of the .get

#

its .raw_nbt.get[blahblahblah]

ripe sapphire
#

I tried that too. ill submit that next

candid oxide
#

not .raw_nbt[blahblahblah]

ripe sapphire
#

also returned false

candid oxide
#

hm

ripe sapphire
#

Ok i see

#

I made a typo last time

#

It is returning true now

candid oxide
#

sweet then

#

any other issues? im alr too tired

ripe sapphire
#

Yea.

#

I just need to figure out which entity tag to use

#

hold on

#
    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

ripe sapphire
# hybrid moat use the
    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

hybrid moat
#

its using as:

#

switch that as to like

#

ent

#

and thats your variable

ripe sapphire
#

Ok

hybrid moat
#

for dropped item

ripe sapphire
#

what entity tag now?yea

#

entity.[dropped_item}?

#

invalid entity tag

ripe sapphire
# hybrid moat 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

#

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>

main cometBOT
#

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]>!
strong pewter
#

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

dark jackalBOT
# strong pewter !c teleport
Group

entity

Syntax

teleport (<entity>|...) [<location>] (cause:<cause>) (entity_options:<option>|...) (relative) (relative_axes:<axis>|...)

Short Description

Teleports the entity(s) to a new location.

Description

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...

strong pewter
#

(<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

dark jackalBOT
# strong pewter !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...

Group

Tag System

strong pewter
#

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

ripe sapphire
#

and (<entity>) says unrecognized sub tags

#
  • teleport (<entity[dropped_item]>) <player.location>
#

cannot interpreet e@dropped_item as entity tag

#

<context.entity> is invalid

strong pewter
#

!l command syntax

dark jackalBOT
# strong pewter !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...

Group

Script Command System

strong pewter
#

It's not literal things you'd include, it's the syntax

ripe sapphire
#

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

strong pewter
#

It takes in a list of entity tags, that's what you already have

ripe sapphire
#

i have tried various things

strong pewter
#

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

ripe sapphire
#

i did. i really have no idea

#

list tag?

#

but again

#

I dont know which one

#

theres no listtag.entity

#

<ListTag.find_all[<element>]>?

strong pewter
#

So you can feed your list in directly instead of looping over it
instead of looping over it I.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 says Lastly, 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 optional Anything 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 the teleport command instead

ripe sapphire
#
    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?

strong pewter
#

Yeah :D

ripe sapphire
#

its working now thanks

#

Ill use an else statement else do nothign

#

if the nbt doesnt match

strong pewter
#

It will do nothing by default, you only need an else if you want it to do something

ripe sapphire
#

Ok

#

I turn debug off so im not worried about a fallback in this instance

#

it doesnt need anything to be handled

strong pewter
#

Errors still appear with debug: false - but either way, you shouldn't be trying to suppress errors, you should be fixing them

ripe sapphire
#

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```
strong pewter
#

(In this case you'll probably want the if_null fallback)

ripe sapphire
#

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

stiff grail
#
  • if <player.item_in_hand.raw_nbt.[MMOITEMS_ITEM_ID].after[:].exists[NO_MAGNET]>:
#

This line should also be erroring

ripe sapphire
#

it isnt

stiff grail
#

!debug

dark jackalBOT
# stiff grail !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!

stiff grail
#

Can you proof that via debug

ripe sapphire
#

its working as intended

#

i see no errors in console

stiff grail
#

There's a syntax error

#

It should error

ripe sapphire
stiff grail
#

Can you turn on debug for that script

ripe sapphire
#

ok

#

and the magnet works

#

ill send a snippet of me holdingf that

stiff grail
#

wtf

ripe sapphire
main cometBOT
#

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?): 
ripe sapphire
#

the .[:] has to do with raw nbt

#

and matching string type

stiff grail
#

No i mean like raw_nbt.[MMOITEMS_ITEM_ID]

#

that part

ripe sapphire
#

thats the nbt tag its checking for

strong pewter
#

It's not erroring because it has a fallback on it lol

main cometBOT
stiff grail
#

YIKES

strong pewter
#

Oh yeah, that as well, forgot MapTags had that

stiff grail
#

Yeah so that's valid right

ripe sapphire
#

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

strong pewter
#

Technically? I don't think it's documented anywhere/recommended

stiff grail
strong pewter
#

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

stiff grail
#

I wonder if that's a side effect of submapping in definitions

strong pewter
#

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

stiff grail
#

or actual a thing

strong pewter
ripe sapphire
#

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

strong pewter
#

Again, try thinking about what exactly is your script doing

#

!t if_null

dark jackalBOT
# strong pewter !t if_null

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.

Returns

ObjectTag

strong pewter
#

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

ripe sapphire
#

which is what i hd in the st place

strong pewter
#

No, because exists would mean you need to have the tag twice

#

<NBT.if_null[null]> == magent, <NBT.exists> && <NBT> == MAGENT

ripe sapphire
#
    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

strong pewter
#

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

strong pewter
#

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

ripe sapphire
#
    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

strong pewter
#

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

dark jackalBOT
# strong pewter !t exists
Cannot Specify Searched Tag

Multiple possible tags: <schematic[<name>].exists>, <ObjectTag.exists>, <server.scoreboard[<board>].exists>.

ripe sapphire
#

the or is to check in hand or offhand

strong pewter
#

.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

ripe sapphire
#

denizen metadoc said diff

#

i think

strong pewter
#

!t ObjectTag.exists

dark jackalBOT
# strong pewter !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.

Returns

ElementTag(Boolean)

ripe sapphire
#
    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?

strong pewter
#

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

ripe sapphire
#

no?

strong pewter
strong pewter
strong pewter
#

Probably just a typo, but you have is_null instead of if_null there

ripe sapphire
#

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

strong pewter
#

Should probably make a new post if you have any questions about that

ripe sapphire
#

just quickly asking you if theres anything obviously wrong

#

I mean the skill works

strong pewter
#

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)

ripe sapphire
#

most functionality is within mmoitems

#

there are a few edge cases where i need custom functions

#

mythicmobs allows some skill casting too

strong pewter
#

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

sand hillBOT
#
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.)

#

@ripe sapphire

ripe sapphire
#

what i would like is depenizen to have a dirrect mmoitems check

#

mmocore stuff can be done via placeholder api

strong pewter
#

That's not possible sadly, as it's premium and forbids redestrbuting jar files

#

Which makes it impossible for Depenizen to support it

ripe sapphire
#

no

#

they have an API

#

depenizen can check for when these api events and stuff are called

strong pewter
#

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

sand hillBOT
#
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.)

#

@ripe sapphire