what's the proper way to fetch a flag from inside of an item? I know you can establish flags within items but how can I refer to the that specific flag? For additional context, the flag inside of the item is a speed multiplier for the player based off of their health. Then, the grand idea is that inside of the "mechanisms:attribute_modifiers...amount: ?" I would insert the flag (that I know works). The problem isn't the flag, but getting the flag and using it somewhere else.
#(Revolver) How to reference a flag created inside of an item?
54 messages · Page 1 of 1 (latest)
(Revolver) How to reference a flag created inside of an item?
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>
Content of Denizen Script Paste #101974: 'Testing an Alternative modify method'... pasted 2022/10/04 14:38:47 UTC-07:00, Paste length: 584 characters across 20 lines
The flag works, I know that much. I just want to reference the flag inside of the amount
Do you mean an item or an item script?
Because you make it sound like you can already pull information from the flag with this sentence.
Yes, I know the script is working with the /ex narrate <player.item_in_hand> which lets me know that the flag is producing the value I want it to produce. However, what I want to do is take the value from that flag and put it into the amount inside of the attribute modifiers
Itemtags can use the flag tag. So you can do <player.item_in_hand.flag[berserker_speed_multiplier]>
Hmm, what about the flag_map? When I did the narrate, I got "...flag_map=map@[berserker_speed_multiplier]..."
or would I have to do something like <player.equipment_map.get[boots].flag[berserker_speed_multiplier]>
Using flag will pull information from the flag_map. This includes submapping so you can do <player.item_in_hand.flag[my_key.my_second_key.my_third_key]> and such.
As long as item tag has flags on it then flag should pull information from those flags.
This should work. Try it and see.
This didn't work. I'm going to try <player.equipment_map.get[boots].advanced_matches[berserker_boots].flag[berserker_speed_multiplier]>
Huh? That's strange.
!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!
Ima try one more thing then I'll give that a whirl
https://paste.denizenscript.com/View/101976
This didn't really help with anything. I even switched the debug for the boots to debug: true
Content of Server Log Paste #101976: 'Denizen Debug Logs From Terminus'... pasted 2022/10/04 16:10:31 UTC-07:00, Paste length: 3310 characters across 37 lines
!checklogs https://paste.denizenscript.com/View/101976
Content of Server Log Paste #101976: 'Denizen Debug Logs From Terminus'... pasted 2022/10/04 16:10:31 UTC-07:00, Paste length: 3310 characters across 37 lines
Server Version
Paper version git-Paper-"fc9ee65" (MC: 1.18.2)
Plugin Version(s)
Citizens: 2.0.30-SNAPSHOT (build 2709) -- (Outdated build, behind by 1)
Denizen: 1.2.5-SNAPSHOT (build 1777-REL) -- (Current build :white_check_mark:)
Depenizen: 2.0.0 (build 802) -- (Current build :white_check_mark:)
Checked For
@loud estuary
Java Version
17 :white_check_mark:
Other Noteworthy Plugin(s)
WorldGuard: 7.0.7+216b061, MythicMobs: 5.1.4-3aa1b5d2, ProtocolLib: 4.8.0-b547
Possibly Relevant Plugin(s)
TAB: 3.1.1 - This plugin adds Below_Name scoreboards to NPCs.
ViaVersion: 4.4.3-SNAPSHOT - Mixed client vs server versions can sometimes cause packet-related issues.
ModelEngine: R3.0.1 - ModelEngine has Citizens support, but that support is known to be buggy. Issues related to NPCs that use ModelEngine should be reported to ModelEngine support, not Citizens.
Can you narrate the item itself.
I'm also noticing you didn't post the script with the chestplate either.
I only posted the boots because it's the only relevant part I'm trying to tackle. I have my current version which works but there's a exploit that I'd like to get rid of so I've made this separate test version. I can show it off rq but the ultimate problem boiled down to that it worked, however, the buffs granted by the script remained even after the user removed the armor
Content of Denizen Script Paste #101981: 'Berserker_Chestplate_Script (OLD)'... pasted 2022/10/04 16:23:16 UTC-07:00, Paste length: 899 characters across 19 lines
I'm also going to bring up the fact that you're trying to change the attribute modifiers of an item based on a flag that assumes that the player exists, I am unsure of how you plan to give the item to players but I hope you don't have mobs spawning with the item somehow.
Hmm, an excellent point. Perhaps I should change player to <context.entity>? or does the context.* only work for world scripts?
I am unsure if context.entity can be called in an item script.
I am specifying this about your item script.
Good point. However, the flag does work cuz it returns the appropriate value. The only problem is trying to apply said value into the attribute modifier.
The armor will be a mythic reward item for a future event in the server so it's not going to be something worn by anything other than a player
When the item is created it will assume the player exists with that flag in mind, you're wanting to change the attribute modifier based on the players current health and logic. I feel like you should be changing this somewhere else, because you want this to be constantly based on the players health I assume?
Si.
I do have a working script that alters the player's buff every time they are damaged. However, there are still 2 exploits to the old script. There's the fact that if a player drops at say, 1 health, and then heals up without ever taking damage again, they will constantly retain that buff. The second exploit being that if they take the armor off in general, the buff still stays
It sounds like you need to check when the player equips or unequips the item, or the item is dropped onto the floor ( Or even put into a container of sorts. ) There exists events for equip/unequip but it's considered a bit unreliable.
!e equip
Required Plugins or Platforms
Paper
Group
Paper
**WARNING**
This event is not reliable, and may miss some types of equipment changes or fire when equipment hasn't actually changed.
Event Lines
player equips|unequips armor|helmet|chestplate|leggings|boots player equips|unequips <item>
Triggers
when a player (un)equips armor.
Has Player
Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
Context
<context.new_item> returns the ItemTag that is now in the slot.
<context.old_item> returns the ItemTag that used to be in the slot.
<context.slot> returns the name of the slot.
I can certainly try this. I'll see what I can do
!e entity drops item
Group
Entity
Event Lines
<entity> drops <item>
Triggers
when an entity drops an item.
Has Player
When the entity dropping an item is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
Context
<context.item> returns the ItemTag.
<context.entity> returns a EntityTag of the item.
<context.dropped_by> returns the EntityTag that dropped the item.
<context.location> returns a LocationTag of the item's location.
Has Known Location
True - this adds switches in:<area> + location_flagged:<flag name>.
Cancellable
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
You could adjust the item mechanism of the context.entity when the specific armor is dropped, and then change the modifier. Setting it to potentially a default value. But since you're only allowing the modifier to be changed on the players current health when equipped, maybe you don't need to change the values at all on drop, unequip, and only on equip and damaged?
https://paste.denizenscript.com/View/101983
Does this look right for the most part?
Content of Denizen Script Paste #101983: 'Berserker Boots Equip Script (Experiment)'... pasted 2022/10/04 16:48:19 UTC-07:00, Paste length: 504 characters across 10 lines
Okay, so, this works. NOW, the new problem is just updating the stats. lemme think
I got it, it's finally perfected
Thank you so much!!
oh wait, I celebrated a bit fast, it's 85% there rofl
Okay, so I eliminated one of the problems. The buff now goes away when you unequip the armor. Now the only problem is that when you get low and then heal and never take damage again, you'll chill at that heightened state until you either take damage again or take the armor off
Okay, nevermind, NOW I got it for real.