Jump to content
SurikenTSD

How to freeze value in lua script?

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites
7 minutes ago, ItsSC said:

Add list before set the value.

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
12 hours ago, ItsSC said:

Alright, wrong order again. Thanks pointing out.

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

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Alright, thanks guys

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

×
×
  • Create New...