Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List Variable Is Empty Suggestion #6608

Open
1 task done
MissingReports opened this issue Apr 25, 2024 · 5 comments
Open
1 task done

List Variable Is Empty Suggestion #6608

MissingReports opened this issue Apr 25, 2024 · 5 comments
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).

Comments

@MissingReports
Copy link

MissingReports commented Apr 25, 2024

Suggestion

List variables are abit weird, you can't create an empty list since "empty" lists are just non existing lists. You check if a list is empty by using if {_list::*} is set, I feel like it should be if {_list::*} is empty which wouldn't error but it will always fail or succeed, I can't remember

List variables also can be a list or a map (key-value pair), something like this add "Hello" to {_list::*} <-- list and set {_list::hello} <-- map
This creates alot of confusion since {_list::hello} and {_list::*} are both one but one value is a list and the other is a map

add "test" to {_list::*}
set {_list::blah} to "blah"
loop {_list::*}:
    broadcast loop-value

There should be a way to identify lists from maps or at least separate both

This one isn't really needed but it'd be nice to have which is streams to filter (this one exists), map (edit a list without loops), etc

There should be a proper way to insert in a list, maybe something like this insert %objects% in[to] %objects% at %integer%

All of that isn't really needed but it'd be nice to have. And maybe make it so you can old list mechanics through the config to not break code

Why?

This would make lists not confusing to new skripters

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this suggestion.
@sovdeeth
Copy link
Member

sovdeeth commented Apr 25, 2024

I think you're a little confused on how lists work. When you say they're sometimes a list and sometimes a map, they're really just always maps. {_list::hello} and {_list::*} are both variables, but one is a single element ({_list::hello}) and the other is multiple elements ({_list::*}, which is all the values in the _list list.)
So there's no difference between lists and "maps", they're the same. add "test" to {_list::*} when {_list::*} is empty is exactly the same as set {_list::1} to "test".

As far as "insert", you can use some math to do that pretty easily, assuming you're using numeric indices. If you're not, then insertion is a bit useless anyway.

is empty is for checking if inventories, slots, or strings are empty. I'm not sure if it would be feasible to extend that to lists, and I don't think it needs to be done since is set works quite well.

@Moderocky
Copy link
Member

I think it might be nice to have is empty for lists, I was always disappointed when that didn't work how I wanted it to.

@NotSoDelayed
Copy link
Contributor

I had made such suggestion in #5435

@Moderocky
Copy link
Member

I had made such suggestion in #5435

Your issue doesn't mention list emptiness, just strings. If it did I could close this in favour of yours.

@NotSoDelayed
Copy link
Contributor

Oh, I was taking the consideration of the condition as both holds a somewhat identical keypoint, so ooops disregard.

@AyhamAl-Ali AyhamAl-Ali changed the title List Variable Suggestions List Variable Is Empty Suggestions Apr 29, 2024
@AyhamAl-Ali AyhamAl-Ali changed the title List Variable Is Empty Suggestions List Variable Is Empty Suggestion Apr 29, 2024
@AyhamAl-Ali AyhamAl-Ali added enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements). labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).
Projects
None yet
Development

No branches or pull requests

5 participants