Jump to content
WhoKnowsWho

Looping issue

Recommended Posts

Just as @MonkeySAN mentioned, you don't need to guess whether anything was found and replaced. Instead it is enough to add logging to the code to find that out: 

loop = 0.1
for i = 0, 98 do
  print(string.format("Searching: %.15f", loop))
  gg.searchNumber(loop, gg.TYPE_DOUBLE)
  local found = gg.getResultsCount()
  print(string.format("Found: %d", found))
  gg.getResults(found)
  local edited = gg.editAll(500, gg.TYPE_DOUBLE)
  print(string.format("Edited: %d", edited))
  gg.clearResults()
  
  loop = loop + 0.1
end

This way you would see how many results were found and edited and it wouldn't be needed to guess anything.

Share this post


Link to post
Share on other sites
Posted (edited)

so i changed 

loop = loop + 0.1

to

loop = string.format("%.15f", loop + 0.1)

not sure if its the correct solution..

but got this results.

777340261_Screenshot_20210314-081056_ParallelSpace.thumb.jpg.c8e49899de2b7d7796230a265aff1737.jpg

 

 

Edited by MonkeySAN

Share this post


Link to post
Share on other sites
6 hours ago, Enyby said:

In general, nothing is clear.
The script does not have to show you at all that he found something there. This is not an animation to show anything.
The fact that the values can be changed you have not shown. That they existed at the time of the search too.
In general, it's not about anything at all.

To assert something, you must prepare a reasoned justification and clear evidence that it happens this way, and not otherwise. This is not the case now.

Until that happens, there will be no conversation.

In the mean time a lot of answers here.

[added 3 minutes later]
3 hours ago, CmP said:

Just as @MonkeySAN mentioned, you don't need to guess whether anything was found and replaced. Instead it is enough to add logging to the code to find that out: 


loop = 0.1
for i = 0, 98 do
  print(string.format("Searching: %.15f", loop))
  gg.searchNumber(loop, gg.TYPE_DOUBLE)
  local found = gg.getResultsCount()
  print(string.format("Found: %d", found))
  gg.getResults(found)
  local edited = gg.editAll(500, gg.TYPE_DOUBLE)
  print(string.format("Edited: %d", edited))
  gg.clearResults()
  
  loop = loop + 0.1
end

This way you would see how many results were found and edited and it wouldn't be needed to guess anything.

Yes, it saves a lot of time. Very handfull!

Share this post


Link to post
Share on other sites

Since "searchNumber" function expects a string as it's first argument, numeric value is converted to string before it is used to determine what to search for.

Test code for your case from the video: 

local value = 0.1
for i = 1, 9 do
  print(value)
  value = value + 0.1
end

Code execution result: 

Spoiler

image.thumb.png.5985328d4358c4d62c04c40cb7da0b5b.png

The problem should be obvious now. The solution is to not rely on automatic number to string conversion unless you are sure that it's result will be equal to what you expect.

Share this post


Link to post
Share on other sites

Yes, problem is very clear. Thank you all!

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