Jump to content
  • 0

How to delete one of the values ​​in the save tab?


Question

Posted

I have problems when creating a command to delete the value 0 on the save tab, if I may ask what commands need to be added to the contents of the script and can you help me by giving an example of the script? Thank You

 

4 answers to this question

Recommended Posts

  • 0
Posted

To remove items from saved list GG API has removeListItems function. Below is an example of how to use it to remove all items with value 0 from the list.

local savedItems = gg.getListItems()
local itemsForRemove = {}
for i, v in ipairs(savedItems) do
  if v.value == 0 then
    itemsForRemove[#itemsForRemove + 1] = v
  end
end
gg.removeListItems(itemsForRemove)
  • 0
Posted
On 11/8/2024 at 6:13 AM, CmP said:

To remove items from saved list GG API has removeListItems function. Below is an example of how to use it to remove all items with value 0 from the list.

local savedItems = gg.getListItems()
local itemsForRemove = {}
for i, v in ipairs(savedItems) do
  if v.value == 0 then
    itemsForRemove[#itemsForRemove + 1] = v
  end
end
gg.removeListItems(itemsForRemove)

Thank you, the script works but after running it, not only the value 0 is deleted... but several other codes are also deleted. Is there something wrong with the way I write the contents of my script? Here I use the QuickEdit application to create the script

2024_11_10_14.47.03.jpg

  • 0
Posted

You can insert code for logging amount of items in saved list before and after fragments of code to see where it works not as expected: 

local items = gg.getListItems()
print("Amount of items in saved list is " .. #items)
  • 0
Posted (edited)

[ @Edi04 ]
---

Quote

 Is there something wrong with the way I write the contents of my script?

I'm not quite sure since I don't have the script myself, but there's part that pique my attention. So the breakdown:
You're getting only one result on "t" variable -> clearing result -> saving "t" to lists -> saving the lists into "tb" variable -> clearing the lists -> and change the "t" value into 0 (The "t" here only contains 1 from getResults(1))
---
So the possible problem is:

  • 1) You keep unnecessarily use addListItem() and getListItem() over and over, while you're already clearing the lists using clearList() (For example: line 59). Thus the "tb" lists only contain 1 from the result of "t" variable.
  • 2) If you want to summon back all other codes, just use addListItem() again on where you're storing the lists as variable.
  • 3) Is your wanted code exist on 't' variable? Because you're using the same name as variable. Naming them different will allow you to load the previous lists.
Edited by kiynox

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.