#(ctr) get specific value from effects_data
87 messages · Page 1 of 1 (latest)
(ctr) get specific value from effects_data
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>
wut
<player.effects_data> returns ListTag(MapTag)
so you would filter with
!t maptag.contains
Returns whether the map contains the specified key.
If a list is given as input, returns whether the map contains all of the specified keys.
ElementTag(Boolean)
- if <map[a=1;b=2].contains[a]>:
- narrate "Yep it sure does have 'a' as a key!"
- if <map[a=1;b=2].contains[c]>:
- narrate "This won't show"
- else:
- narrate "No it doesn't have 'c'"
# Narrates 'true'
- narrate <map[a=1;b=2].contains[a|b]>
# Narrates 'false'
- narrate <map[a=1;b=2].contains[a|b|c]>
wait actually, here, you would check for the type
so it would be like
!t maptag.get
Returns the object value at the specified key.
If a list is given as input, returns a list of values.
ObjectTag
# Narrates '2'
- narrate <map[a=1;b=2;c=3].get[b]>
# Demonstrates that list input gives list output - narrates '2' then '3'
- foreach <map[a=1;b=2;c=3].get[b|c]> as:value:
- narrate "One of the values is <[value]>"
!t elementtag.equals
Returns whether the element is equal to another element.
Equivalent to if comparison: ==
You should never ever use this tag inside any 'if', 'while', etc. command.
comparison
ElementTag(Boolean)
so <player.effects_data.filter[get[type].equals[luck]]>
Doesn't seem to work, i get an empty list every time...
Only thing i can get it to filter correctly is by using <player.effects_data.filter[contains_text[type=LUCK;amplifier=0]].get[1].exists>
but i don't want a true i just want the value narrated.. equals would return a true aswell... and just .get[key]doesn't work for me, not sure where i'm going wrong
!guide object hacking
View the guide page 'Common Mistakes - Object Hacking Is A Bad Idea' at: https://guide.denizenscript.com/guides/troubleshooting/common-mistakes.html#object-hacking-is-a-bad-idea
you're object hacking here
one thing you can do is try /ex narrate <player.effects_data>
I don't think so, thats something ice gave me a while ago
well it is object hacking
what does this narrate?
i mean that works fine yeah, but it would get all effects instead of only luck
the map with all active effects
Sure, back on pc in ~3-5 mins
https://paste.denizenscript.com/View/104404
So that narrates the whole effect list... but all i want is the value of the luck amplifier
alright so /ex narrate <player.effects_data.filter[get[type].equals[luck]]> narrates an empty list?
No, that just narrates the list with Luck, but that also worked with <player.effects_data.filter[contains_text[type=LUCK]]> which i used before
wellt hats great then!
now to get the amplifier you can do
!t listtag.parse
Returns a copy of the list with all its contents parsed through the given tag.
One should generally prefer !tag ListTag.parse_tag.
ListTag
# Narrates a list of 'ONE|TWO'
- narrate "<list[one|two].parse[to_uppercase]>
so <player.effects_data.filter[get[type].equals[luck]].parse[get[amplifier]]>
and then
!t listtag.max
Returns the higher number: this element or the specified one.
For example: <element[5].max[10]> returns 10.
math
ElementTag(Decimal)
Returns the highest value in a list of decimal numbers.
Optionally specify a tag to run on each list entry that returns the numeric value for that entry.
ObjectTag
# Narrates '10'
- narrate "<list[3|2|1|10].highest>
# Narrates the name of the player with the most money currently online
- narrate <server.online_players.highest[money].name>
so <player.effects_data.filter[get[type].equals[luck]]> returns the ListTag of MapTags of luck effects
<player.effects_data.filter[get[type].equals[luck]].parse[get[amplifier]]> returns all the amplifiers
<player.effects_data.filter[get[type].equals[luck]].parse[get[amplifier]].highest> returns the highest amplifier
maybe stupid question but an effect can't have multiple amplifiers or?
don't think so
if you have one though, it will probably appear as multiple maps in the list
also... can i put something like.. if there's no LUCK effect then continue without in the same line? with something like .if_null[null] or would i have to make a seperate if line for that?
neat, thanks :)
so if someone searching for the same issue -> /ex narrate <player.effects_data.filter[get[type].equals[luck]].parse[get[amplifier].add[1]].if_null[null]>
Thread closed as resolved.
why not the .highest?
still not sure what that would provide for me, there's only 1 value possible
i mean there can't be a lower one then the highest
well the current tag you put returns a list
so you would have to get one of the values
the safest one being obviously highest
but there's always only one value? don't want to discuss i just don't get it i think lol
sure, it seems like theres always going to be just one value, but in order to do anything with the value you gotta make it an elementtag first
i mean it's meant to be a definition
what are you going to do with the definition
i want to implement luck as a multiplier for some droprates
hmm
then you will have to use something like a .mul tag, which requires elementtags, not listtags
you can't multiply by a list
alright, so /ex narrate <player.effects_data.filter[get[type].equals[luck]].parse[get[amplifier]].highest.add[1].if_null[null]>
add 1 to actually show the level of luck instead of amplifier
if you only use it in a .mul, you can also have the .if_null fallback to 1 instead of null
just to save some time
yeah, that's the next thing i would've tried. thanks alot :)
/ex narrate <player.effects_data.filter[get[type].equals[luck]].parse[get[amplifier]].highest.add[2].if_null[0]> seems perfect
👍
Thread was manually reopened by @shell epoch.