Jump to content
Sign in to follow this  
Shuaiouke

How to edit value by address via lua script

Recommended Posts


1. Start fuzzy search limited specified range. Edit all found result to desired value.

2. Or. Build table with need values in loop and use setValues.

Share this post


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

1. Start fuzzy search limited specified range. Edit all found result to desired value.

2. Or. Build table with need values in loop and use setValues.

emm, is there other ways to do it? if not, how to use loop to edit value by address

Share this post


Link to post
Share on other sites

Other ways similar. But first is most easy.

Read API help and make 3 calls for it. clearResults, startFuzzy, editAll.

Share this post


Link to post
Share on other sites

Emm you misunderstanded me I know the address I’m editing it just there’s 500 vars to change I’m not doing a fuzzy search not even a search just edit addresses

Share this post


Link to post
Share on other sites
5 hours ago, Shuaiouke said:

emm, is there other ways to do it? if not, how to use loop to edit value by address

local t = {}
t[1] = {}
t[1].address = 0x18004030
t[1].flags = gg.TYPE_DWORD
t[2] = {}
t[2].address = 0x18004034
t[2].flags = gg.TYPE_DWORD
t[3] = {}
t[3].address = 0x18004038
t[3].flags = gg.TYPE_DWORD

gg.loadResults(t)
yourTable = gg.getResults(3)

 for i,v in ipairs(yourTable) do
     yourTable.value = 10000
     yourTable.flags = gg.TYPE_DWORD
 end
 gg.setValues(yourTable)

Share this post


Link to post
Share on other sites

@Shuaiouke No. I understand you right. You need search your 500 address and change it.

But you can use long way with loop if you want.

Share this post


Link to post
Share on other sites

So first, that's not efficient, since there are over 500 addresses to edit, and second, anyone knows how to use a loop to edit addresses progressively.

Share this post


Link to post
Share on other sites

You choose not only worst possible way, you try it make more worst. Progressive edit is much worst in performance terms.

Share this post


Link to post
Share on other sites

So just give me a sec, I want a loop to edit the addresses one by one, that's what I mean by progressively since I don't even know there's soemthing called progressive edit, want a loop like

for(int i = 0, i < Number of the addresses, i++)

{

string t =" address";

t.value = 1;

}

at least that's how u write it in Java

Share this post


Link to post
Share on other sites
50 minutes ago, Shuaiouke said:

that's not efficient

Have you tried it at least? I highly doubt that searching for 500 consecutive addresses and editing all of them to one value can noticeably slow down your script. So are you sure that it does not suffice because of performance reasons?

1 hour ago, Shuaiouke said:

anyone knows how to use a loop to edit addresses progressively

As pointed out above, editing values one-by-one in a loop is very inefficient. This approach should be used instead, if simple one with fuzzy search does not suffice:

On 2/3/2019 at 4:33 AM, Enyby said:

2. Or. Build table with need values in loop and use setValues.

Example of implementing it:

local startAddress = 0x12340000
local count = 500
local editValue = '555444'
local values = {}
for i = 1, count do
  values[i] = {address = startAddress; flags = gg.TYPE_DWORD; value = editValue}
  startAddress = startAddress + 4
end
gg.setValues(values)
  

 

Share this post


Link to post
Share on other sites

first, I don't care about time since it's editing like characters u have so it's in the menu and it's singleplayer, and second, how do I make the script u made to fit what I need

first wat does editValue does and wat does values list do

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
Sign in to follow this  

×
×
  • Create New...