#(JustinS) Storing and editing data ingame

105 messages · Page 1 of 1 (latest)

left cove
#

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)

native pawnBOT
#

(JustinS) Storing and editing data ingame

native pawnBOT
#

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.

left cove
#

Example: - flag <server> weapons.dualsword.damage:5

robust wolfBOT
late gate
#

Server flags defintely not

#

Are the items from Denizen?

left cove
#

Though Ill need to be able to access those stored variables quite easily bcs theyre in used in a lot of scripts

late gate
#

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.

left cove
late gate
#

As I said, you dont. Only via script editor and + /ex reload.

left cove
#

The point is that I want to be able to change it via an ingame gui menu though

late gate
#

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.

left cove
#

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

gusty vigil
#

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

left cove
gusty vigil
#

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

left cove
gusty vigil
#

By flagging the script

#

- flag <script[my_item_script]> my.flag:my_value

#

Then <script[my_item_script].flag[my.flag]>

left cove
gusty vigil
#

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

deep vectorBOT
gusty vigil
#

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

left cove
#

I meant the flags in the itemscript:

itemscript:
    type: item
    base_material: dirt
    flags:
     # the flags here
gusty vigil
#

this will flag the items directly

left cove
#

Ahh

#

So each item has those flags

somber marten
gusty vigil
#

might be ye

left cove
#

Probably

gusty vigil
#

don't know where i got base material

somber marten
#

its in the meta like that backwards :P

gusty vigil
#

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
gusty vigil
#

wrote that from memory

gusty vigil
#

(maybe you can, or maybe you're forced to use inventory flag)

#

(but that's to explain the logic, take this as pseudo code)

left cove
#

So I need to flag the script wirh the base values

#

And then change and use those

gusty vigil
#

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

deep vectorBOT
# gusty vigil !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.

gusty vigil
#

!Language flag system

deep vectorBOT
# gusty vigil !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

left cove
#

👍 alright thanks Ill give it a try. Ill leave this thread open for a bit if I get anotjer question regarding this

gusty vigil
#

almost everything is flaggable so you always have something relevant to flag

left cove
#

Now lets hope someone can help me with my other 50 problems lol

gusty vigil
#

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

left cove
#

basically, how do I initialize them?

gusty vigil
#

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™️

left cove
#

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

gusty vigil
#

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))

left cove
# gusty vigil "global flags" you can easily init them manually or setup a quick temporary task...

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?

wheat cliff
#

<script[script_name].flag[what.ever]>

left cove
#

So... <script[item_force_blinding].flag[variables.base_strength]> ?

#

But what about the rest of the potential issue I mentioned?

wheat cliff
#

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

deep vectorBOT
# wheat cliff !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.

left cove
#

Ill test it out

#

yoo that works

#

thats cool

#

Thanks!