flag shenannegins

TIL you can set the flags key on a document to whatever you want to (e.g. a string). This is a sure fire way to completely ruin someone else's day, or your own day when another module un-does this by setting a flag 'correctly'.
game.actors.getName('A Character').update({
['flags']: 'A value'
})

game.actors.getName('A Character').data.flags // 'A value'

game.actors.getName('A Character').setFlag('world', 'someKey', 'some string value')

game.actors.getName('A Character').data.flags // { world: { someKey: 'some string value' }}
game.actors.getName('A Character').update({
['flags']: 'A value'
})

game.actors.getName('A Character').data.flags // 'A value'

game.actors.getName('A Character').setFlag('world', 'someKey', 'some string value')

game.actors.getName('A Character').data.flags // { world: { someKey: 'some string value' }}
21 Replies
Calego
CalegoOP•4y ago
dnd5e for instance gets big mad when its flags disappear from an actor.
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
It seems that core doesn't care
Calego
CalegoOP•4y ago
No description
Calego
CalegoOP•4y ago
this falls squarely under "play stupid games win stupid prizes" lol
Calego
CalegoOP•4y ago
No description
Calego
CalegoOP•4y ago
speaking of... I want to try this with items or like data itself, but am too scared
Calego
CalegoOP•4y ago
omg lol
No description
Calego
CalegoOP•4y ago
Alright well. TIL update has great power and thus comes with great responsibility.
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
[removed gif] oo no that looks like it actually hurt no more of that gif thanks
Calego
CalegoOP•4y ago
much better
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
lol
LukeAbby
LukeAbby•4y ago
I feel like this is a prime example of Javascript loose casting LOL and the unfortunate effects
arcanistzed
arcanistzed•4y ago
Is this a "bug"?
Calego
CalegoOP•4y ago
I would not categorize it as such. If I got sent a bug with this at work, my reply to it would be "... don't" and I'd WONTFIX it.
arcanistzed
arcanistzed•4y ago
Makes sense, thanks
Calego
CalegoOP•4y ago
if I couldn't get away with telling them to "just don't" I'd say something like:
The amount of complexity and performance overhead that would be introduced by adding validations to this low-level API do not outweight being able to prevent the edge case described by this issue.
šŸ˜›
LukeAbby
LukeAbby•4y ago
in all fairness setFlag isn't that low level. but yes the edge case is small and the validation is probably a WONTFIX it's a pretty expected result of Javascript casting imo

Did you find this page helpful?