What storage type do you guys recommend for serverwide settings, and for individual player settings? I was thinking of flags but am not sure if theres better ways. With settings I mean stuff such as the stats of a custom weapon, such as dmg, durability, etc. that can all be changed serverwide via a gui menu (simply by increasing a decimal value)
#(JustinS) Storing and editing data ingame
105 messages · Page 1 of 1 (latest)
(JustinS) Storing and editing data ingame
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.
Example: - flag <server> weapons.dualsword.damage:5
Some of them could be custom denizen items yes
Though Ill need to be able to access those stored variables quite easily bcs theyre in used in a lot of scripts
what does it mean "some"
this is a very important part
I'd go with fully Denizen and store BASE stats into a data key of that item. Item upgrades and bonuses would go into item flags.
When you go the non vanilla way ofcourse and making your own damage calculations and wotnot.
If you store things in data keys and change them, they'll be changed everywhere, when referencing the items script.
You can only change them via script editor.
Flags on the other hand are dynamic, they can be changed from ingame and events. But you can not change them for all existing items easily.
If I'd go such way I would not go the fucky route tinkering with other items from other plugins.
How do I change the data keys of all items of 1 itemtype in-game though?
As I said, you dont. Only via script editor and + /ex reload.
The point is that I want to be able to change it via an ingame gui menu though
That would include checking every item in players inventories whenever they open them, search for the items, and adjust them to your needs.
If you do it via flags.
I might have given a bad example. Give me a second
Im making a spinoff of spells/magic. Basically, the player can select a spell and cast it on themselves or another player. Things such as strength, duration, cooldown and levelup-multiplier are all different for each spell, and I want a gui menu for the server owner to easily change those for each spell. The only times those values get used is when a spell is cast: the script gets the target, and does the appropriate action, using the variables for duration, cooldown, levelup multiplier and strength
My question is, whats the best way to store those variables, that make them changable in game and usable in script
you can flag a script tho
which means you can achieve the same kind of global config as a data key by using a flag on an item script
that's still referencing the script globally, but you can dynamically update it
however I have no clue what happens if you rename the script (if the flag is retrievable at all) so you better be consistent with your script names so you never have to rename it
But how would that be more performant than assigning flags to the server for the base stats of each spell, and individual tags for each player?
I understood you wanted to assign the different spells to items, I.e. you get X spell by clicking a player with Y item
It that’s indeed the case, that each spell is tied to an item, in that case the best place to store the data is the item script itself
But then how do I change the data in the iten script?
By flagging the script
- flag <script[my_item_script]> my.flag:my_value
Then <script[my_item_script].flag[my.flag]>
And that would change the flags I set in the itemscript?
that would change the flag you set on the item script yes
but not on the items generated by the script
i.e.:
my_item:
type: item
material: dirt
my_task:
type: task
script:
# this gives you a reference to the *script itself*
- define item_script <script[my_item]>
# this creates a new item instance
- define item_from_script <item[my_item]>
# now, the item *script* has a flag named foo
- flag <[item_script]> foo:bar
- narrate <script[my_item].flag[foo]> # "bar"
- narrate <[item_from_script].flag[foo]> # Error! because the *item instance* has no flag
!t itemtag.script
Returns the script of the item if it was created by an item script.
Group
scripts
Returns
ScriptTag
you can use this ^ to access an item's script if it has been generated using a script
i.e. <[item_from_script].script.flag[foo]> -> bar
I meant the flags in the itemscript:
itemscript:
type: item
base_material: dirt
flags:
# the flags here
this will flag the items directly
did you mean material instead of base_material here as well?
might be ye
Probably
don't know where i got base material
its in the meta like that backwards :P
this
itemscript:
type: item
material: dirt
flags:
foo: bar
meep: moop
----
- define item <item[itemscript]>
is more or less equal to
itemscript:
type: item
material: dirt
----
- define item <item[itemscript]>
- flag <[item]> foo:bar
- flag <[item]> meep:moop
ah ye that's where i got the confusion
wrote that from memory
tho take this with a mountain of salt because i don't think you can flag an item just like that
(maybe you can, or maybe you're forced to use inventory flag)
(but that's to explain the logic, take this as pseudo code)
if you want the config to apply per-item, flag to the items
if you want the config to apply to all items of the same kind, flag the script
if you want the config to apply to all items at all, flag the server
!s flaggable
Search Results
[Partial Name Match] !ObjectType flaggableobject, !Tag flaggableobject.flag, !Tag flaggableobject.has_flag, !Tag flaggableobject.flag_map, !Tag flaggableobject.list_flags, !Mechanism flaggableobject.clean_flags, !Tag flaggableobject.flag_expiration,
[Semi-Strong Match] !Command flag,
[Semi-Decent Match] !Language flag system, !ObjectType playertag, !ObjectType plugintag, !ObjectType towntag, !ObjectType itemtag, !ObjectType npctag, !ObjectType polygontag, !ObjectType timetag, !ObjectType nationtag, !ObjectType biometag, !ObjectType chunktag, !ObjectType cuboidtag, !ObjectType entitytag, !ObjectType worldtag, !ObjectType queuetag, !ObjectType scripttag, !Tag server.flag, !ObjectType locationtag, !ObjectType materialtag, !ObjectType ellipsoidtag, !Tag server.flag_map, !ObjectType discordbottag, !ObjectType discordroletag, !ObjectType inventorytag, !Tag server.has_flag, !ObjectType discordusertag, !ObjectType enchantmenttag, !ObjectType discordgrouptag, !Tag server.list_flags, !ObjectType discordchanneltag, !Mechanism server.clean_flags, !ObjectType discordcommandtag, !ObjectType discordmessagetag, !Tag server.flag_expiration, !ObjectType discordreactiontag, !ObjectType discordinteractiontag, !ObjectType griefpreventionclaimtag,
[Just Barely Matched] !Mechanism itemtag.flag.
!Language flag system
The flag system is a core feature of Denizen, that allows for persistent data storage linked to objects.
"Persistent" means the data is still around even after a server restart or anything else, and is only removed when you choose for it to be removed.
"Linked to objects" means rather than purely global values, flags are associated with a player, or an NPC, or a block, or whatever else.
See also the guide page at https://guide.denizenscript.com/guides/basics/flags.html.
For non-persistent temporary memory, see instead !command define.
For more generic memory options, see !command yaml or !command sql.
Flags can be sub-mapped with the '.' character, meaning a flag named 'x.y.z' is actually a flag 'x' as a MapTag with key 'y' as a MapTag with key 'z' as t...
Group
Denizen Scripting Language
👍 alright thanks Ill give it a try. Ill leave this thread open for a bit if I get anotjer question regarding this
almost everything is flaggable so you always have something relevant to flag
Now lets hope someone can help me with my other 50 problems lol
i.e. flagging the server for specific things is most of the time not the best choice
flag stores information for a player -> flag the player
flag stores information for an item -> flag the item
flag stores information for a location -> flag the location
you name it
How can I make sure the flags exist and have a base value without re-setting those flags every time something happens
basically, how do I initialize them?
by setting them
- flag <[whatever]> some.super.deep.flag.that.was.definitely.never.set.before:foobar
it will recursively create nested maps
will basically create that
some:
super:
deep:
flag:
that:
was:
definitely:
never:
set:
before: foobar
then you can do
- flag <[whatever]> "some.super.deep.flag.at:another path"
and the flag object becomes
some:
super:
deep:
flag:
at: another path
that:
was:
definitely:
never:
set:
before: foobar
then you can do <[whatever].flag[some.super.flag.that.was]>
and you get back a nested map of
definitely:
never:
set:
before: foobar
pretty convenient there, it Just Works™️
Where do I set that though
I cant set it in the itemscript right? If I set it in one of the spell casting scripts, it will be set to the same value each time that spell is run
Which is a bit inefficient
I can set it when it gets changed, but that wont set it initially before I ever change it
if you're setting a flag once that'll be used forever you can just /ex flag as an ingame command
"global flags" you can easily init them manually or setup a quick temporary task script you run once (i.e. server flags, script flags and other things that are "deterministic and final" (vs. entities and item that are created and deleted on the fly for exemple))
Right now Im making a script that I advice the owner to only run once (unless they want to reset all the variables) though it just came to me that it might not work: - define blind <script[item_force_blinding]> - flag <[blind]> variables.base_strength:1
If I do this, don't I only flag an instance of that script called blind? This way I don't flag the script itself for future references do I?
So, <item_force_blinding.flag[variables.base_strength]> wouldnt work
Or am I mistaken and does it work as it's supposed to?
You need to construct the script object first before reading the flag off of it
<script[script_name].flag[what.ever]>
So... <script[item_force_blinding].flag[variables.base_strength]> ?
But what about the rest of the potential issue I mentioned?
What issue
don't I only flag an instance of that script called blind?
this?
Once you flag the script object the flag is stored to it, you can create any instance again and read off of it I'm pretty sure?
Though
!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.