#(zephies) First Time Denizen User

292 messages · Page 1 of 1 (latest)

dusky vessel
#

Hi, I'm currently developing a server and I want to include custom features into it through Denizen, but I have just started using Denizen.

I've read over the "tutorial" that is up on the website, and I understand how to get started but how to continue is a bit of a hassle for me as I'm not too knowledgeable with the ins and outs of the plugin.

Currently, I am trying to write a "Carrier Bird" script that will allow players to send messages to other players via "messenger birds" if they have a piece of paper in their inventory, as well as have a delay of x amount of blocks (it depends on how far the players are from one another, and how far I'd like for the delay to be (ex. every 5 blocks is travelled in 1 second via messenger bird)). This is to eliminate /msg and add more of a roleplay vibe to messaging.

I've tried to follow the "Handling Player Arguments" part of the "The Basics" on the website while trying to fit it with what I need, but I am stumped on what to do next.

I'm hoping somebody could help me out here, or if you're interested I'd love to have a sort of "Denizen Mentor" to help me through all my scripts I want to create in the future.

azure tapirBOT
#

(zephies) First Time Denizen User

azure tapirBOT
#

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>

dusky vessel
#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
    - choose <context.args.first>:
        - case player:
            - define playerName <context.args.get[2]>```
#

My current script

restive igloo
#

You will have to validate context.args.first sometime, as players may not provide a first argument and it could error.

#

!t objecttag.exists

ebon nacelleBOT
# restive igloo !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)

restive igloo
#

Or

#

!t objecttag.if_null

ebon nacelleBOT
# restive igloo !t objecttag.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

ruby topaz
#

!g handling player commands

ruby topaz
#

this guide page will help you on this

#

oh oop you already read it. well then follow it's instructions

molten falcon
#

!guide common mistakes - Don't trust players

dusky vessel
#

Oh

#

It'd be <player.exists>

#

Right?

#

But where do I put that in

molten falcon
#

no and no

dusky vessel
#

😅 okay

molten falcon
#

<context.args.first> will break, always if a user does not use an argument

#

ie: /command

dusky vessel
#

Right

molten falcon
# ebon nacelle

what you should do instead, is explained on the guide page above^

dusky vessel
molten falcon
#

!paste

ebon nacelleBOT
molten falcon
#

Could you post the script again?

dusky vessel
#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
    - choose <context.args.first>:
        - case player:
            - define playerName <context.args.get[2]>```
molten falcon
#

Did you really read the guide page I've linked you?

#

It has a perfect example and explanations on how to verify user input

dusky vessel
#

Sorry, ping

molten falcon
#

remove the choose start simple

#

The usage of the command should be /m Zeph Hi Zeph right

#

Or do you want /m player Zeph Hi Zeph

dusky vessel
#

I want it to be /m (user) (msg)
So /m Zeph hey!

molten falcon
#

Ye so

#

start verifying the first argument

#

or like

#

start with the minimum amount of arguments

#

which is two right?

dusky vessel
#

Yes

#

Just to get this right

#

An argument is anything following the command, right?

#

So (user) (message)

#

Is two arguments

#

If it was like a faction system where you want to set a colour and coordinates to home to a new faction it'd be /f create (name) (colour) (coordinates) making it 3 arguments, right? (this is an example, I don't wanna do this)

#

And args = arguments

#

So args[2] is 2 arguments right?

#

But if there are less than 2 arguments, it's < 2

#

So that means that

#
    - narrate "<red>/m [player] [message]"``` 

Will give the player a message in chat advising them that they didn't write enough arguments,  because they wrote less than 2 arguments
#

Am I getting this right?

molten falcon
molten falcon
#

Sorry for the amount of pings lol

dusky vessel
#

Please ping me

#

Cause I have 937 servers, this one at the very top so I see it first

#

Sorry for those 2 pings

molten falcon
#

Isn't the max amount 100?

orchid vortex
#

200 with nitro

#

:P

dusky vessel
#

It was an overstatement haha

#

Wait 100?

#

I don't have nitro

#

But

molten falcon
dusky vessel
#

How have I not hit my max yet

dusky vessel
molten falcon
#

In your command script put - narrate <context.args.get[2]> at the very beginning reload scripts and then run

  1. /m first_argument second_argument
  2. /m

and watch your servers console

molten falcon
#

I linked a guide page where all this is explained

#

And you can also test these examples on the guide

#

and watch your console

#

to see how things run

dusky vessel
molten falcon
#

Yep, that's what happens when a user don't provide arguments

#

To prevent that you have to verify that the second argument exists when you need it

dusky vessel
#

okay I see

#

I think

#

Anyhoo

#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
     - if <context.args.size> < 2:
         - narrate "<red>/m [player] [message]"
     - stop```
#

Like that?

#

alright awesome

#

So how do I make it functional now 😅

molten falcon
#

I dont know why you come up with that

dusky vessel
#

Cause I don't want to copy Denizen's code haha
I also want to make it so that a player needs to have a piece of a paper in their inv to send the message

molten falcon
#

Cause I don't want to copy Denizen's code haha
Thats not "Denizens code", that's the optimal way to handle these kind of things

#

There aren't many other ways to handle it

#

!t player.inventory.contains_item

ebon nacelleBOT
#
Possible Confusion

Did you mean to search for inventorytag.contains_item?

ebon nacelleBOT
molten falcon
#

!t entity.inventory

ebon nacelleBOT
dusky vessel
molten falcon
#

Yes

dusky vessel
#

!guide Don't Trust Players

dusky vessel
#

That's not 1:1, that's a /pay command

molten falcon
#

please read this example

dusky vessel
#

Okay

#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
     - if <context.args.size> < 2:
         - narrate "<red>/m [player] [message]"
         - stop
    # fallback for if player doesn't exist
     - define target <server.match_player[<context.args.get[1]>].if_null[null]>
    # if incorrect name, tell user and stop
     - if <[target]> == null:
        - narrate "<yellow><context.args.get[1]><red> can not be found. Make sure you write the name correctly."
        - stop```
#

I have this

#

But

#

The first - stop prevents the rest of the script from going

#

But if I remove it, it returns <context.args.get[1] in the game

#

It returns the first narration and the tag of the second part

#

It's only when I write in a name that the tag doesn't show

molten falcon
#

Could you record a debug real quick

#

!debug

ebon nacelleBOT
# molten falcon !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!

dusky vessel
#

Done

molten falcon
#

Last reload: 14m ago

#

You probably forgot to /ex reload your scripts?

dusky vessel
#

No I fid?

molten falcon
#

Debug doesn't match the script you've posted.

dusky vessel
molten falcon
#

Did you forget to save the script?

dusky vessel
#

No it's saved

molten falcon
#

Odd enough.

#

Local server?

dusky vessel
#

Yes

molten falcon
#

Wanna post that script again on

#

!paste

ebon nacelleBOT
molten falcon
#

? :P

dusky vessel
molten falcon
#

Do you see the issue?

#

I mean like

#

You removed the - stop from line 10

#

That's the reason context.args.get[1] may return null and errors

dusky vessel
#

I know, but if I keep - stop there, it won't run the - if <[target]> == null: - narrate "<yellow><context.args.get[1]><red> can not be found. Make sure you write the name correctly." - stop

dusky vessel
#

What I said here

molten falcon
#

Add it back

#

with the correct intend

#

You moved it outside earlier

#

therefor it will always stop

dusky vessel
#
molten falcon
#

This looks good

dusky vessel
molten falcon
#

It used to be before stop

#

but now it's correct

#

So what's the issue? Your script works as intended

#

If you run /m nothing will happen, because you forgot to set up the user and message

dusky vessel
#

It doesn't though, it doesn't show up "<yellow><context.args.get[1]><red> can not be found. Make sure you write the name correctly." when I write something in after /m

molten falcon
#

Could you provide a debug that indicates that

dusky vessel
#

Sure

molten falcon
#

Put a - narrate <context.args> at the beginning of your command script

dusky vessel
#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
     - narrate <context.args>
     - if <context.args.size> < 2:
         - narrate "<red>/m [player] [message]"
         - stop
    # fallback for if player doesn't exist
     - define target <server.match_player[<context.args.get[1]>].if_null[null]>
    # if incorrect name, tell user and stop
     - if <[target]> == null:
        - narrate "<yellow><context.args.get[1]><red> can not be found. Make sure you write the name correctly."
        - stop```
#

Like this?

molten falcon
#

Ye

dusky vessel
#

Okay wait

#

What's this telling me now haha

#

So it's passing through but it isn't at the same time?

molten falcon
#

?

dusky vessel
#

Oh I see

#

I fell for the player trap 😐

#

I wasn't putting in 2 args

#

I just kept writing /m (user)

molten falcon
#

In the first command you only specified 1 argument -> It's smaller then 2 -> so the first stop runs
In the second command you specified 2 arguments -> the first argument is not a valid player -> so the second stop runs

dusky vessel
#

Without the (message)

#

Yes

#

Omg I'm so dumb

#

🤦

#

Okay

#

Now I get this

#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
     - if <context.args.size> < 2:
         - narrate "<red>/m [player] [message]"
         - stop
    # Let sender know if recipient doesn't exist
     - define target <server.match_player[<context.args.get[1]>].if_null[null]>
    # If incorrect name, tell user and stop
     - if <[target]> == null:
        - narrate "<yellow><context.args.get[1]><red> can not be found. Make sure you write the name correctly."
        - stop
    # Defining the message argument (2)
     - define message <context.args.get[2]>```

How do I make it so that the message is actually read by the code? Cause rn I'm only defining that the second argument is the message
molten falcon
#

Well on a technical level, each word separated by space is it's own argument.

#

Denizen provides <context.args> which is a ListTag you can use to modify the list of arguments.

#

!t ListTag.remove

ebon nacelleBOT
molten falcon
#

!t ListTag.space_separated

ebon nacelleBOT
molten falcon
#

You can remove the first argument from the list of arguments and then separated it by space.

dusky vessel
#

What

#

I do not get that

molten falcon
#

What exactly?

dusky vessel
#

With what you said and how it applies

molten falcon
#

^ there are examples on meta you can try

#

Maybe that help?

dusky vessel
#

No I looked at those, I'm still confused

#

Like, what do I do with this

molten falcon
#

What tag provides the list of arguments?

dusky vessel
#

<context.args>?

molten falcon
#

correct

#

and how do you remove an entry from that list?

dusky vessel
#

<context.args.remove>?

molten falcon
#

close

molten falcon
#

It's a tag that requires input

dusky vessel
#

<context.args.remove[?]> substitute ? with whichever argument

molten falcon
#

ye

#

the index, not the argument itself

dusky vessel
#

what's the index again?

molten falcon
#

The index is the place of that list where an argument is located.

#

<list[1|2|3|4]>

dusky vessel
#

oH OK

#

So whatever is in the [] is the index

molten falcon
#

ye

dusky vessel
#

gotcha

#

- define message <context.args.remove[2]>

#

So this?

molten falcon
#

!tias

ebon nacelleBOT
# molten falcon !tias
Info: tias

Try it and see!

If somebody pulled this up for you, you're probably asking a question of the public channel that's easier and faster to figure out by just attempting your idea in-game and looking at the result of that attempt.

dusky vessel
#

Okay I did

#

That's the debug log

molten falcon
#

You haven't specified a valid player

#

Don't you read your own error messages? kekwcry

dusky vessel
#

ahwgeabgwhewabegawbvegwae

#

SHUSH

molten falcon
#

So you used the define command to define your message nice

#

You probably want to send it to a specific player right

#

!c narrate

dusky vessel
#

Yes

ebon nacelleBOT
# molten falcon !c narrate
Group

player

Syntax

narrate [<text>] (targets:<player>|...) (format:<script>) (per_player) (from:<uuid>)

Short Description

Shows some text to the player.

Description

Prints some text into the target's chat area. If no target is specified it will default to the attached player or the console.

Accepts the 'format:<script>' argument, which will reformat the text according to the specified format script. See !language Format Script Containers.

Optionally use 'per_player' with a list of player targets, to have the tags in the text input be reparsed for each and every player.
So, for example, "- narrate 'hello <player.name>' targets:<server.online_players...

molten falcon
#

^

dusky vessel
#

hm okay lemme... tias 😉

#
    type: command
    name: m
    description: Sends a carrier bird message to another player!
    usage: /m player|message
    permission: dscript.m
    script:
     - if <context.args.size> < 2:
         - narrate "<red>/m [player] [message]"
         - stop
    # Let sender know if recipient doesn't exist
     - define target <server.match_player[<context.args.get[1]>].if_null[null]>
    # If incorrect name, tell user and stop
     - if <[target]> == null:
        - narrate "<yellow><context.args.get[1]><red> can not be found. Make sure you write the name correctly."
        - stop
    # Defining the message argument (2)
     - define message <context.args.remove[2]>
     - narrate <[message]> (targets:<[target]>|...) (format:<script>) (per_player) (from:<player.uuid>)```
#

Idk if I did this right

#

Prolly not

molten falcon
#

Don't just copy paste, read...

dusky vessel
#

Okay but

#

Idk what the format and what per_player is

molten falcon
# ebon nacelle

(click the blueish Command: Narrate), to get the full page

#

at the top left corner

dusky vessel
#

Okay

#

Okay okay

#

I think

#

I'm onto something here

#

Omg

#

Awesome I did it

#

Now just to figure out:

  1. How to set it so that the sender gets a narration that says "Sent to x" (which shouldn't be hard) ✅
  2. How to set it so that only if you have a piece of paper you can send (which may be a bit tricky)
dusky vessel
#

I have this rn

#

But

#

line 1, carrier_bird:

#

There is a red squiggly line under

#

nvm

#

It was a syntax error

#

Alright, disregard everything from above

#

My issue now is setting up the "must have a piece of paper in inventory"

#

I'll upload a debug

dusky vessel
#

Okay I fixed it. Just add to change my if statement to - if !<player.inventory.contains_item[paper]>:

dusky vessel
#

Now however I'm trying to be extra and create a custom item that the recipient will receive, named "Letter" and the lore is to be the message sent to them

#

But Idk what to write for the item type

#

Like how command has "name" "description" "usage" etc.

#

Idk what to write for item

#

Okay I found it out

#

Disregard everything from above

#

I'm trying to create a "letter" item within the same script, just as a different task at the end.
However when I'm trying to write the displayname as "Letter from <[sender]> it gives me the error Definition tag points to non-existent definition (typo, or bad copypaste?).Denizen Script Checker(def_of_nothing)

#

How can I include the [sender] definition into my displayname

#

I want it to show up as "Letter from xZeph" for example

#

Okay nvm! All good! Figured it out haha

dusky vessel
#

Okay

exotic lindenBOT
dusky vessel
#

New issue now lmao

#

Oh thank you bot

#

My new issue is when I import it into my actual server

#

And I try to run the commands

#

(I try to do it with another player to)

#

Nothing shows up in chat, and my piece of paper stays in my hand, and the player doesn't receive anything

mossy stag
#

user opened a seperate thread, closing this one