SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.08k stars 370 forks source link

Better data storing #7074

Open MissingReports opened 2 months ago

MissingReports commented 2 months ago

Suggestion

I feel like it would be nice for a way to store multiple data as one element in a list, since you can't store a list inside of a list E.g:

set {_eventDataStructure} to an empty data structure
set element "Type" of {_eventDataStructure} to "Global Booster"
set element "EndDate" of {_eventDataStructure} to 10 minutes later
set element "Amount" of {_eventDataStructure} to 100
add {_eventDataStructure} to {events::*}

# Retrieving
loop {events::*}:
    set {_eventDataStructure} to loop-value
    set {_type} to element "Type" of {_eventDataStructure}
    # And so on

Another option is using SkReflect's array, or making it so you can store lists inside of lists

Why?

It's pretty hard to store multiple values in a list as one element

Other

No response

Agreement

Asleeepp commented 2 months ago

I like this idea

Pikachu920 commented 2 months ago

why not {events::1::type} and so on

MissingReports commented 2 months ago

It'd be hard to add an event and reidentify it later

sovdeeth commented 2 months ago

You may enjoy #7064

Pikachu920 commented 2 months ago

It'd be hard to add an event and reidentify it later

what do you mean?

erenkarakal commented 2 months ago

it really depends on the end goal but I had the same issue on my minigame framework while creating instances of games.

the way i solved it is creating a random id for the game and storing that id in the player

ex.

function start(p: player):
  set {_instance} to random uuid
  set {var::%{_instance}%::end.date} to now
  set {current.instance::%{_p}'s uuid%} to {_instance}

on jump:
  set {_instance} to {current.instance::%player's uuid%}
  broadcast {var::%{_instance}%::end.date}

you can take inspiration from this if applicable