Jump to content
  • 0

Looping issue


WhoKnowsWho
 Share

Question

Recommended Posts

  • 0

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.

Link to comment
Share on other sites

  • 0
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!

Link to comment
Share on other sites

  • 0

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.

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.