Jump to content
  • 0

How to freeze value in lua script?


SurikenTSD
 Share

Question

Hello! I am trying to write a small script, with lua familiar for the second day and have made some progress.
In this function, I search for values and filter them out until there are exactly two left. Then I change them, but how do I freeze them? I tried to search for the answer using the example of other scripts, but most of them are encrypted, and in those that are not encrypted, I did not find the answer (or did not understand it). How do I use FREEZE_NORMAL correctly? Can someone help me with an example of my script? Thanks.

function Flash()
gg.searchNumber("17~20", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
while gg.getResultsCount() > 2 do
    gg.processResume()
    gg.sleep(1250)
    gg.processPause()
    gg.searchFuzzy("-3~-1", gg.SIGN_FUZZY_EQUAL, gg.TYPE_DWORD, 0, -1)
end
gg.getResults(10)
gg.editAll('-1', gg.TYPE_DWORD)
gg.FREEZE_NORMAL() -- Incorrect usage, but I don't know how to use it correctly. :(
gg.toast('Done!')
gg.setVisible(true)
os.exit()
end

 

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Welcome to learn Lua scripting. Try to use table if you failed this, it's a powerful feature.

https://www.lua.org/pil/2.5.html

function Flash()
gg.searchNumber("17~20", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
while gg.getResultsCount() > 2 do
    gg.processResume()
    gg.sleep(1250)
    gg.processPause()
    gg.searchFuzzy("-3~-1", gg.SIGN_FUZZY_EQUAL, gg.TYPE_DWORD, 0, -1)
end
local table = gg.getResults(10)
for i = 1, #table do
	table[i]["value"] = -1
	table[i]["freeze"] = true
end
gg.setValues(table)
gg.toast('Done!')
gg.setVisible(true)
os.exit()
end
Link to comment
Share on other sites

  • 0
1 hour ago, ItsSC said:

Welcome to learn Lua scripting. Try to use table if you failed this, it's a powerful feature.

https://www.lua.org/pil/2.5.html

I didn't know why, but the values was not frozen. Only changed. If I manually freeze them, everything is OK, if not, the values change immediately. 😞

However, I didn't despair and found a way out of the situation, I found what you missed in your example: I don't know how critical this is, but you didn't specify table ["freezeType"] = gg.FREEZE_NORMAL line and the most important thing is that you forgot about gg.addListItems (table) line.
But the main thing - the direction was set and eventually I was able to figure it out on my own. Thanks a lot!

function Flash()
gg.searchNumber("17~20", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.refineAddress("6??????4", -1, gg.TYPE_DWORD, gg.SIGN_EQUAL, 0, -1)
while gg.getResultsCount() > 2 do
	gg.processResume()
	gg.sleep(2000)
	gg.processPause()
	gg.searchFuzzy("-4~-1", gg.SIGN_FUZZY_EQUAL, gg.TYPE_DWORD, 0, -1)
end
local table = gg.getResults(10)
for i = 1, #table do
	table[i]["value"] = -1
	table[i]["freeze"] = true
	table[i]["freezeType"] = gg.FREEZE_NORMAL
end
gg.setValues(table)
gg.addListItems(table)
gg.toast('Done!')
gg.setVisible(true)
os.exit()
end

 

Link to comment
Share on other sites

  • 0
4 minutes ago, SurikenTSD said:

I don't know how critical this is, but you didn't specify table ["freezeType"] = gg.FREEZE_NORMAL line and the most important thing is that you forgot about gg.addListItems (table) line.

"freezeType" parameter has default value of "gg.FREEZE_NORMAL", so it's not necessary to explicitly specify it. However, you are absolutely correct about missing call to "addListItems" function that is required to save values to saved list.

Link to comment
Share on other sites

  • 0

Oops yes I missed the save value. 
 

function Flash()
gg.searchNumber("17~20", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.refineAddress("6??????4", -1, gg.TYPE_DWORD, gg.SIGN_EQUAL, 0, -1)
while gg.getResultsCount() > 2 do
	gg.processResume()
	gg.sleep(2000)
	gg.processPause()
	gg.searchFuzzy("-4~-1", gg.SIGN_FUZZY_EQUAL, gg.TYPE_DWORD, 0, -1)
end
local table = gg.getResults(10)
for i = 1, #table do
	table[i]["value"] = -1
	table[i]["freeze"] = true
	--table[i]["freezeType"] = gg.FREEZE_NORMAL This is not needed since already declare that freeze = true
end
gg.addListItems(table)
gg.setValues(table)
gg.toast('Done!')
gg.setVisible(true)
os.exit()
end

Add list before set the value.

Edited by ItsSC
Link to comment
Share on other sites

  • 0
3 minutes ago, CmP said:

This way the values won't be frozen. Need to call "addListItems" function after the loop that sets "freeze" field to "true".

Alright, wrong order again. Thanks pointing out.

Link to comment
Share on other sites

  • 0
43 minutes ago, El_dorado said:

So what is the correct code bro? The full code? 

gg.setValues(table)
gg.addListItems(table) <--must add this after set the values not before...otherwise value wont freeze.

just that. 

 

Edited by zam535582
Link to comment
Share on other sites

  • 0
2 hours ago, zam535582 said:

gg.setValues(table)
gg.addListItems(table) <--must add this after set the values not before...otherwise value wont freeze.

just that. 

 

Do it before set value, after defined values.

a= {{address =1 , flags = 1 , value = 1 ,freeze = true}} -- Defined the value

gg.addListItems(a) -- add to save list

gg.setValues(a) -- set the value

Link to comment
Share on other sites

  • 0
On 5/15/2020 at 3:01 PM, ItsSC said:

Do it before set value, after defined values.

a= {{address =1 , flags = 1 , value = 1 ,freeze = true}} -- Defined the value

gg.addListItems(a) -- add to save list

gg.setValues(a) -- set the value

You have many codes to say in this question Are You rlly a coder or you're just guessing?

 

This Is The Simple Way To Freeze A Value

  1. gg.searchNumber('0', gg.TYPE_DWORD)
  2.  
  3. searchResults = gg.getResults(100) -Getting Results From The Prev SearchNum
  4.  
  5. for i, v in ipairs(searchResults) do
  6.   v.value = '1' -Editing Your Desired Value
  7.   v.freeze = true -Will Set The Value Freeze
  8.   v.freezeType = gg.FREEZE_NORMAL -(OPTIONAL) Will Set The Freeze Type
  9. end
  10.  
  11. gg.addListItems(searchResults)

Idk If This Works On Unkown Fuzzy Search But This Helps A Bit 

Edited by NoNameGG
Link to comment
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
 Share

×
×
  • 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.