Jump to content
Sign in to follow this  
Maddin

Lua Script edit one value

Recommended Posts

Hy,

i use following simple script

gg.searchNumber ('123;4567;8901', gg.TYPE_DWORD)
gg.getResults (100)
gg.editAll ('545454', gg.TYPE_DWORD)

How can i solve my problem. I have to search by group to find the correct 123 value. But i only want to change 123 into 545454, the other two values should be as they are.

And what i have to do, that gameguardian will go back to the game. It always come up the Message - Script ended.... - Copy - Restart - OK.

After the run of the script. Gameguardian should go back to the game.

 

Sorry i'm new in Lua, and try my first steps.... ;-)

Share this post


Link to post
Share on other sites

46 minutes ago, Maddin said:

But i only want to change 123 into 545454, the other two values should be as they are.

Then you simply need to search it right after performing group search.

50 minutes ago, Maddin said:

And what i have to do, that gameguardian will go back to the game.

There is a function called "gg.setVisible" for this purpose.
See API docs.
https://gameguardian.net/help/classgg.html#a4ad04f38598e00a393edc274e38b2009

Here is the example of applying these things to your script:

gg.setVisible (false)
gg.searchNumber ('123;4567;8901', gg.TYPE_DWORD)
gg.searchNumber ('123', gg.TYPE_DWORD)
gg.getResults (100)
gg.editAll ('545454', gg.TYPE_DWORD)

 

Share this post


Link to post
Share on other sites

OK,

and how can i solve the next situation?

gg.setVisible (false)
gg.searchNumber ('123;4567;8901', gg.TYPE_DWORD)
gg.searchNumber ('123', gg.TYPE_DWORD)
gg.getResults (100)
gg.editAll ('545454', gg.TYPE_DWORD)

 

123 ist now changed to 545454, and in the second step i want to change 4567 to 998877 for example.

I have to clear the result and search again? Or can i solve this with an other rule?

 

And with 

gg.setVisible (false)

it run the script, but at the end it push the message again: Message - Script ended.... - Copy - Restart - OK.

But this Message i don't like

Edited by Maddin

Share this post


Link to post
Share on other sites
gg.setVisible(false)
gg.searchNumber('123;4567;8901', gg.TYPE_DWORD)
local results = gg.getResults(100) -- may return a string with error in some cases

for i, v in ipairs(results) do
  if v.value == '123' then
    v.value = '545454'
  elseif v.value == '4567' then
    v.value = '998877'
end

gg.setValues(results) -- may return a string with error in some cases

-- script will be ended when user opens GG interface by clicking on the floating icon
while true do 
  if gg.isVisible() then
      break
    else
      gg.sleep(100);
    end
end

os.exit()

 

Share this post


Link to post
Share on other sites

@Maddin Add "end" after

25 minutes ago, CmP said:

v.value = '998877'

 

Share this post


Link to post
Share on other sites

Thanks CmP and Enyby.

 

Now it works, and i can try next things.... 

 

Topic closed

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...