Jump to content

LUA scripting


Enyby
 Share

Recommended Posts

  • Administrators

Difference can be set nil. It assumed as '0'.

For unchanged you can search gg.searchFuzzy(nil, gg.TYPE_DWORD, gg.SIGN_EQUAL).

For changed same but SIGN_INEQUAL.

You can set first param as '0', all be same.

Link to comment
Share on other sites

  • Administrators

Logic is next:

You set rules for new value. New value = Old value + difference.

Search run as (new value) sign (old value + difference).

If sign is EQUAL, then it is mean test for unchanged. If INEQUAL - for changed.

_______________________________________________
added 2 minutes later

For example old value id 5, difference is 0, new value is X. And if you search (X == 5 + 0) then this mean value unchanged and stay 5. If you search (X ~= 5 + 0) then this mean value changed and can be any but not 5.

Link to comment
Share on other sites

  • Administrators

No. You must save data in script and restore if you want.

For example:

local saved = gg.getResults(100) -- load first 100 results
gg.editAll('123', gg.TYPE_DWORD) -- edit loaded values
gg.setValues(saved) -- set values to saved (revert back)

 

Link to comment
Share on other sites

  • Administrators

@Aufar_R You have two option - or make your script with loop. And user do not work with gg while loop worked. Or save your data to file and load it from this file on revert.

Ypu can use same script for revert and choice on start. Or use another script for revert all back.

In your case you can run same search. But with changed numbers.

And you must avoid  thousand separator or your script not work on different locale.

Revert like this:

gg.clearResults()
gg.searchNumber('1,110,704,128;2,139,000,000;1,036,831,949', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.searchNumber('2,139,000,000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(850)
print('Replaced: ', gg.editAll('1,008,981,770', gg.TYPE_DWORD))

It is not revert strictly speaking. it is replace with search. But it can consider as revert if no other values found.

 

Full revert must look like this:

gg.toast('Lua script by Aufar_R')
gg.toast('Working on Rebels server!!!')
-- choice here - revert or replace.
-- if replace then
  gg.clearResults()
  gg.searchNumber('1,110,704,128;1,008,981,770;1,036,831,949', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
  gg.searchNumber('1,008,981,770', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
  gg.getResults(850) -- here you need save values to table
	-- save table with value to file
  print('Replaced: ', gg.editAll('2,139,000,000', gg.TYPE_DWORD))
  gg.clearResults()
  gg.toast('Done Fast Reload')
-- replace else
	-- load values table from file from 
	-- set values from table to memory
-- if end

This is draft with comments. You nned learn lua yourself for write full script.

Link to comment
Share on other sites

  • Administrators

@Backlift

gg.searchNumber('100', gg.TYPE_DWORD) -- 1_find a value
local d = gg.getResults(1) -- 2_get its address
d[1].address = d[1].address + 12 -- 3_use the offset on it (for example +12)
d = gg.getValues(d) -- load values 
print(d)
d[1].value = 120 -- set new value in var
gg.setValues(d) -- write to game
gg.getValues(d) -- read from game
print(d)

 

Link to comment
Share on other sites

13 hours ago, Aufar_R said:

I'm sorry but can anyone show me an example if I want to revert back after I use this script:

FastReload.lua

Just save old value to a variable and replace it before ending the script

Link to comment
Share on other sites

Awesome job. This has massive potential. For example, it can save a lot of time for the game I'm currently playing. The startup time to get the game running with all of the needed addresses saved is annoying considering the game crashes randomly when it's minimized and you try to do something else.

The only thing I really want is the ability to manipulate the saved addresses list. An LUA script can completely automate getting and saving the needed addresses and reduce the startup time to a few seconds.

The game I'm playing is an RPG with a party of characters and random enemy encounters. I need to save values for party characters and enemy HP, MP, and agility and a few others. Over 20 addresses in total. The lucky thing is that the offset between these addresses is always the same so I only need to find the first address and the offset calculator will do the rest. Still tedious when it has to be done multiple times a day.

Link to comment
Share on other sites

  • Administrators
gg =   table(53680388): {
       [BUILD] = 5896
       [CACHE_DIR] = /data/data/catch_.me_.if_.you_.can_/cache
       [EXT_CACHE_DIR] = /mnt/sdcard/Android/data/catch_.me_.if_.you_.can_/cache
       [EXT_FILES_DIR] = /mnt/sdcard/Android/data/catch_.me_.if_.you_.can_/files
       [FILES_DIR] = /data/data/catch_.me_.if_.you_.can_/files
       [PACKAGE] = catch_.me_.if_.you_.can_
       [REGION_ANONYMOUS] = 32
       [REGION_ASHMEM] = 524288
       [REGION_BAD] = 131072
       [REGION_CODE_APP] = 16384
       [REGION_CODE_SYS] = 32768
       [REGION_C_ALLOC] = 4
       [REGION_C_BSS] = 16
       [REGION_C_DATA] = 8
       [REGION_C_HEAP] = 1
       [REGION_JAVA] = 65536
       [REGION_JAVA_HEAP] = 2
       [REGION_OTHER] = -1032320
       [REGION_PPSSPP] = 262144
       [REGION_STACK] = 64
       [SIGN_EQUAL] = 536870912
       [SIGN_FUZZY_EQUAL] = 536870912
       [SIGN_FUZZY_GREATER] = 67108864
       [SIGN_FUZZY_LESS] = 134217728
       [SIGN_FUZZY_NOT_EQUAL] = 268435456
       [SIGN_GREATER_OR_EQUAL] = 67108864
       [SIGN_LESS_OR_EQUAL] = 134217728
       [SIGN_NOT_EQUAL] = 268435456
       [TYPE_AUTO] = 127
       [TYPE_BYTE] = 1
       [TYPE_DOUBLE] = 64
       [TYPE_DWORD] = 4
       [TYPE_FLOAT] = 16
       [TYPE_QWORD] = 32
       [TYPE_WORD] = 2
       [TYPE_XOR] = 8
       [VERSION] = 8.30.0
       [VERSION_INT] = 83000
       [alert] = function: alert /* gg.alert(string text [, string positive = 'ok' [, string negative = nil [, string neutral = nil]]]) -> int: 0 = cancel, 1 = positive, 2 = negative, 3 = neutral */
       [choice] = function: choice /* gg.choice(table items [, string selected = nil [, string message = nil]]) -> string || nil */
       [clearResults] = function: clearResults /* gg.clearResults() -> nil */
       [copyMemory] = function: copyMemory /* gg.copyMemory(long from, long to, int bytes) -> true || string with error */
       [copyText] = function: copyText /* gg.copyText(string text [, bool fixLocale = true]) -> nil */
       [dumpMemory] = function: dumpMemory /* gg.dumpMemory(long from, long to, string dir) -> true || string with error */
       [editAll] = function: editAll /* gg.editAll(string value, int type) -> count of changed || string with error */
       [getFile] = function: getFile /* gg.getFile() -> string */
       [getLine] = function: getLine /* gg.getLine() -> int */
       [getRanges] = function: getRanges /* gg.getRanges() -> int */
       [getResultCount] = function: getResultCount /* gg.getResultCount() -> long */
       [getResults] = function: getResults /* gg.getResults(int count) -> array || string with error */
       [getSpeed] = function: getSpeed /* gg.getSpeed() -> double */
       [getTargetInfo] = function: getTargetInfo /* gg.getTargetInfo() -> table || nil */
       [getTargetPackage] = function: getTargetPackage /* gg.getTargetPackage() -> string || nil */
       [getValuesRange] = function: getValuesRange /* gg.getValuesRange(table values) -> table || string with error */
       [getValues] = function: getValues /* gg.getValues(table values) -> table || string with error */
       [gotoAddress] = function: gotoAddress /* gg.gotoAddress(long address) -> nil */
       [isPackageInstalled] = function: isPackageInstalled /* gg.isPackageInstalled(string pkg) -> bool */
       [isProcessPaused] = function: isProcessPaused /* gg.isProcessPaused() -> bool */
       [isVisible] = function: isVisible /* gg.isVisible() -> bool */
       [multiChoice] = function: multiChoice /* gg.multiChoice(table items [, table selection = {} [, string message = nil]]) -> table || nil */
       [processKill] = function: processKill /* gg.processKill() -> bool */
       [processPause] = function: processPause /* gg.processPause() -> bool */
       [processResume] = function: processResume /* gg.processResume() -> bool */
       [processToggle] = function: processToggle /* gg.processToggle() -> bool */
       [prompt] = function: prompt /* gg.prompt(table prompts [, table defaults = {} [, table types = {} ]]) -> nil || table with keys from prompts and values from inputs */
       [removeResults] = function: removeResults /* gg.removeResults(table results) -> true || string with error */
       [searchAddress] = function: searchAddress /* gg.searchAddress(string text [, long mask = -1 [, int type = gg.TYPE_AUTO [, int sign = gg.SIGN_EQUAL [, long memoryFrom = 0 [, long memoryTo = -1]]]]]) -> true || string with error */
       [searchFuzzy] = function: searchFuzzy /* gg.searchFuzzy([string difference = '0' [, int type = gg.TYPE_AUTO [, int sign = gg.SIGN_FUZZY_EQUAL [, long memoryFrom = 0 [, long memoryTo = -1]]]]]) -> true || string with error */
       [searchNumber] = function: searchNumber /* gg.searchNumber(string text [, int type = gg.TYPE_AUTO [, bool encrypted = false [, int sign = gg.TYPE_EQUAL [, longmemoryFrom = 0 [, long memoryTo = -1]]]]]) -> true || string with error */
       [setRanges] = function: setRanges /* gg.setRanges(int ranges) -> nil */
       [setSpeed] = function: setSpeed /* gg.setSpeed(double speed) -> true || string with error */
       [setValues] = function: setValues /* gg.setValues(table values) -> true || string with error */
       [setVisible] = function: setVisible /* gg.setVisible(bool visible) -> nil */
       [sleep] = function: sleep /* gg.sleep(int milliseconds) -> nil */
       [startFuzzy] = function: startFuzzy /* gg.startFuzzy([int type = gg.TYPE_AUTO [, long memoryFrom = 0 [, long memoryTo = -1]]]) -> true || string with error */
       [timeJump] = function: timeJump /* gg.timeJump(string time) -> true || string with error */
       [toast] = function: toast /* gg.toast(string text [, bool fast = false]) -> nil */
}

 

_______________________________________________
added 1 minute later
17 minutes ago, chrifister said:

The only thing I really want is the ability to manipulate the saved addresses list. An LUA script can completely automate getting and saving the needed addresses and reduce the startup time to a few seconds.

We have plans about that.

 

Link to comment
Share on other sites

New features added in V.8.30.0

[copyText] = function: copyText /* gg.copyText(string text [, bool fixLocale = true]) -> nil */
[getFile] = function: getFile /* gg.getFile() -> string */
[getLine] = function: getLine /* gg.getLine() -> int */       
[getTargetInfo] = function: getTargetInfo /* gg.getTargetInfo() -> table || nil */

Re-named in V.30.0

                         From:-version(8.29.0)

[getSelectedPackage] = function: getSelectedPackage /* gg.getSelectedPackage() -> string || nil */

                         To:-version(8.30.0)

[getTargetPackage] = function: getTargetPackage /* gg.getTargetPackage() -> string || nil */

_________________________________________________________________________________________________________________________________________________________

                         From:-version(8.29.0)

 [multiChoice] = function: multiChoice /* gg.choice(table items[, table selection]) -> table || nil */

                         To:-version(8.30.0)

 [multiChoice] = function: multiChoice /* gg.multiChoice(table items [, table selection = {} [, string message = nil]]) -> table || nil */

 

Above info is not complete, There could be some things that i have missed.

Anyways the new update is good.

Edited by ankit007
Link to comment
Share on other sites

  • Administrators

It is same. Just renamed. getSelectedPackage to getTargetPackage.

_______________________________________________
added 2 minutes later

And this is not all list of changes. Some constants new, some - renamed.

Link to comment
Share on other sites

4 hours ago, Enyby said:

It is same. Just renamed. getSelectedPackage to getTargetPackage.

_______________________________________________
added 2 minutes later

And this is not all list of changes. Some constants new, some - renamed.

Thx dude just Updated the info as per you said.?

Link to comment
Share on other sites

  • Administrators

If you want know changes from begin:

-- new
       [choice] = function: choice /* gg.choice(table items[, string selected]) -> string || nil */
       [getValuesRange] = function: getValuesRange /* gg.getValuesRange(table values) -> table || string with error */
       [isVisible] = function: isVisible /* gg.isVisible() -> bool */
       [multiChoice] = function: multiChoice /* gg.choice(table items[, table selection]) -> table || nil */
       [setVisible] = function: setVisible /* gg.setVisible(bool visible) -> nil */
       [sleep] = function: sleep /* gg.sleep(int milliseconds) -> nil */
-- changed
       [searchAddress] = function: searchAddress /* gg.searchAddress(string text[, long mask[, int type[, int sign[, long memoryFrom[, long memoryTo]]]]]) -> true || string with error */
       [searchFuzzy] = function: searchFuzzy /* gg.searchFuzzy([string difference[, int type[, int sign[, long memoryFrom[, long memoryTo]]]]]) -> true || string with error */
       [searchNumber] = function: searchNumber /* gg.searchNumber(string text[, int type[, bool encrypted[, int sign[, long memoryFrom[, long memoryTo]]]]]) -> true || string with error */
       [startFuzzy] = function: startFuzzy /* gg.startFuzzy([int type[, long memoryFrom[, long memoryTo]]]) -> true || string with error */
-- new
       [SIGN_FUZZY_EQUAL] = 536870912
       [SIGN_FUZZY_GREATER] = 67108864
       [SIGN_FUZZY_LESS] = 134217728
       [SIGN_FUZZY_NOT_EQUAL] = 268435456
       [SIGN_GREATER_OR_EQUAL] = 67108864
       [SIGN_LESS_OR_EQUAL] = 134217728
       [SIGN_NOT_EQUAL] = 268435456
       [copyText] = function: copyText /* gg.copyText(string text [, bool fixLocale = true]) -> nil */
       [getFile] = function: getFile /* gg.getFile() -> string */
       [getLine] = function: getLine /* gg.getLine() -> int */
       [getTargetInfo] = function: getTargetInfo /* gg.getTargetInfo() -> table || nil */
       [getTargetPackage] = function: getTargetPackage /* gg.getTargetPackage() -> string || nil */
-- changed
       [choice] = function: choice /* gg.choice(table items [, string selected = nil [, string message = nil]]) -> string || nil */
       [multiChoice] = function: multiChoice /* gg.multiChoice(table items [, table selection = {} [, string message = nil]]) -> table || nil */
-- removed
       [SIGN_INEQUAL] = 268435456
       [SIGN_LARGER] = 67108864
       [SIGN_SMALLER] = 134217728
       [getSelectedPackage] = function: getSelectedPackage /* gg.getSelectedPackage() -> string || nil */

 

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.