Jump to content

Recommended Posts

Posted (edited)

Your_Table gg.getResults(gg.getResultsCount()) ---> this function returns a table contains a key/index that contain address , value , and flags etc
if you want to refresh values u need to type :

Your_Table = gg.getValues(Your_Table)
if you want to change it's values(if u have more than 2) then you need to make a loop and type : 

for key,values in pairs(Your_Table) do 
Your_Table[key].value = AnyValueYouWant
end

gg.setValues(Your_Table)

to avoid writing this every time if you have many values/functions etc you can make a function that does that with less writing and You just need to declaire it one time on your script
and since in lua we can insert a function inside a table and call it we can do it like so :

function UP()

function temp_table.update(self)

local  temp_table = {} -- empty temp table
temp_table.results = gg.getResults(gg.getResultsCount()) -- results
temp_table.update = function(self,setvalue) -- update function

-------------------------------------> Updates the values
 for key,values in pairs(self.results) do
  self.results = gg.getValues(self.results)
 end

end
------------------------------------> the self parametre allow us to call the function and make it act on its self and since it self is a table that mean it will update it self(the function call look like thistable= update(thistable) but we instead call it like this thistable:update()

return temp_table

end
--------------------------------------------------------------------------------------------------------------
we can add if then else or any loop/conditions/
we can also add an explicit parametre to the update function like gg.setValues(Your_Table) and the final function will look like this : 

 

function UP()

  local  temp_table = {}

    temp_table.results = gg.getResults(gg.getResultsCount())

    temp_table.update = function(self,setvalue)

        for key,values in pairs(self.results) do

                if setvalue ~= nil then setvalue = tostring(setvalue)

                    self.results[key].value = setvalue

                    gg.setValues(self.results)

                end

                self.results= gg.getValues(self.results)

                gg.alert(tostring(self.results[key].value)..' Updated')

        end

     end

     return temp_table

end


note : you can also use assert for type(key) == 'table' so the function update rest intact
--------------------------------------------------------------------------------------------------------------

Finally after You use gg.SearchValue() 
instead of writing : Your_Table = gg.getResults(gg.getResultsCounts())
just type Your_Table = UP()

and inside the while true do
add Your_Table:update()

and if you want to set values just type Your_Table:update(1598)

code example : 



Capture.thumb.PNG.bdd8126d0154f446bf915a828e880b35.PNG

LIVE code:

You can use this method to toggle ON/OFF menu  and to check if specifc value met requirement for example postions like if u have X,Y values u can make a condition if X == 15 then .. etc (inside update function) 
I hope you get the point Enjoy

Edited by XEKEX
add colors to make it easy to understand /prevent lost , deleted a mistake
  • 1 month later...
Posted
On 1/18/2023 at 11:33 AM, lalakay said:

How to Freeze value using your script

You can try to save the the result to a table and use for loop to freeze the values then add update function to that table and it will keep he values freezed : 
for index,values in pairs(your_table) do 
your_table[index].freeze = FREEZE_NORMAL (or true idk x) )
end
your_table:update = function(self)
-- body
end

  • 10 months later...
Posted

@XEKEX can you tell what is wrong in this script, every code address is accurate but still this script edits wrong values.

gg.setVisible(false)

 

gg.clearResults()

gg.setRanges(gg.REGION_C_ALLOC)

gg.searchNumber('0.6;120::', 16)

gg.refineNumber('0.6', 16)

t = gg.getResults(1)

gg.clearResults()

 

e = {1}

c = {}

for i, v in ipairs(e) do

table.insert(c, {address = t[1].address + 20; flags = 16; value = '99999'})

end

gg.setValues(c)

 

c = {}

for i, v in ipairs(e) do

table.insert(c, {address = t[1].address + B0; flags = 16; value = '99999'})

end

gg.setValues(c)

 

c = {}

for i, v in ipairs(e) do

table.insert(c, {address = t[1].address - 40; flags = 16; value = '1'})

end

gg.setValues(c)

 

c = {}

for i, v in ipairs(e) do

table.insert(c, {address = t[1].address - B0; flags = 16; value = '0'})

end

gg.setValues(c)

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.