Jump to content
AjYouTube

Lua scripting (Freezing/unFreezing Values and other editing results in even and odd order) using FOR LOOP

Recommended Posts

Basic search

gg.searchNumber('0Q;0F;0F;0D~~0D;8,589,934,592Q;2D;73,014,444,032Q::33',gg.TYPE_FLOAT)

gg.searchNumber('0',gg.TYPE_FLOAT)

————————————

Freeze and unfreeze(code)

local x = gg.getResults(200)




for  i , v in ipairs(x) do
  v.value = '1'
  v.freeze = true

-- here we freezing the values

  end
gg.addListItems(x)


for  i , v in ipairs(x) do
  v.value = '1'
  v.freeze = false 

  -- unfreezing optional

  end
gg.addListItems(x)

If you know how the for loop works then you can understand above

————————————

Odd number order results editing

local x = gg.getResults(60)


n = gg.getResultsCount()


for i=1,n,2 do

x[i].value = '1'

x[i].freeze = true
  
  end
gg.addListItems(x)


for i=1,n,2 do

x[i].value = '1'


x[i].freeze = false
  
  end
gg.addListItems(x)

Why this is becouse 

I find in help section  less options to get results

So you can edit any result u want by loop

 

————————————

 

Even number order results editing

same like odd but here i = 2 

————————————

 

If you find any wrong code or 

Anything ....

 

reply

 

 

Edited by AjYouTube

Share this post


Link to post
Share on other sites

1 hour ago, AjYouTube said:

gg.addListItems(x)

Use slow calls in loop usually bad idea. Add all items to one table and add it in one call.

Even if performance do not matter for you, It is freeze your values all at once. Your variant freeze value one-by-one so it can be cause of inconsistent game memory, crash, or game errors. oR can be visible for defense algorithms.

Share this post


Link to post
Share on other sites

Instead of using numerical for loop to traverse a table, you may want to use the generic for loop. This way suits better when all elements from a table need to be processed. Also you won't need to care about size of the table.

Example of freezing values using generic for and "ipairs" iterator function:

local x = gg.getResults(100)
for i, v in ipairs(x) do
  v.value = '1'
  v.freeze = true
end
gg.addListItems(x)

Another thing is that for

4 hours ago, AjYouTube said:

results editing

you would better use "setValues" function, unless you really need to add items to saved list.

Share this post


Link to post
Share on other sites

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

×