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

Bug: Storing from data into a score without a scale is impossible #86

Open
PeerHeer opened this issue Oct 13, 2023 · 1 comment
Open

Comments

@PeerHeer
Copy link

Example

In this example, I want to get the length of a list.

from bolt_expressions import Scoreboard, Data

function ./main:
  score = Scoreboard.objective("some_objective")
  data = Data.storage("some_storage")
  
  data.some_list = [1, 2, 3, 4, 5]
  
  score["list_length"] = data.some_list

Generated code:

data modify storage some_storage some_list set value [1, 2, 3, 4, 5]
execute store result score list_length some_objective run data get storage some_storage some_list 1 # <-- This 1 is problematic!

Expected outcome

I expect the score list_length some_objective to be 5.

Actual outcome

The list_length some_objective is 0.

Proposed fix

This bug occurs because the data has a default scale of 1. But the list length is only stored in the score if there is NO scale.
I propose being able to use None as a scale. I realize this is not a trivial fix because if storing a score into data, the scale is required. So we need to make None equal to something (probably 1) if it is used there.

@RitikShah
Copy link
Contributor

Actually, I think None makes sense here. but we were thinking of supporting like len(data.some_list) instead of just directly =.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants