Jump to content

LUA scripting


Enyby
 Share

Recommended Posts

hi guys, do we have a function for group search for prompt and exact value like on the 2nd line on my script

example:

d = gg.prompt({A='A'}, {A='0'})

gg.searchNumber ('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.searchNumber('d.A',gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.getResults(1)

gg.editAll('99999999',gg.TYPE_DWORD)

 

i always have problem on that 2nd line, heres the error.

Script error: org.luaj.vm2.LuaError: @/storage/emulated/0/Download/lua tests/File.txt:54
`gg.searchNumber('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)`
gg.searchNumber: bad argument #2 (string): number expected, got nil
stack traceback:
    /storage/emulated/0/Download/lua tests/File.txt:54: in main chunk
    [Java]: in ?
    at org.luaj.vm2.Varargs.argerr(Varargs.java:280)
    at org.luaj.vm2.Varargs.optint(Varargs.java:202)
    at android.ext.Script$searchNumber.invokeUi(Script.java:1871)
    at android.ext.Script$ApiFunction.run(Script.java:737)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5120)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
    at dalvik.system.NativeStart.main(Native Method)

or

is there any method to search the offset from the exact values after this 

gg.searchNumber('123;456;789::2000',gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.searchNumber('123',gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.getResults(1)

 

now after the result i want it going into the address value of that single result

then search its offset

then edit that address value from the offset of that single result.

example from the address:

7C40DE78 = d.A

7C40DE7C = 123

7C40DE80 = 456

7C40DE84 = 789

so offset of 7C40DE7C going to 7C40DE78 is -8

while 123;456;789 are constant values

 

i hope i explained right to what i want to happen on my script thanks.

Link to comment
Share on other sites

On 7/17/2017 at 10:08 AM, Enyby said:

Starting from version 8.28.0 GG have support of LUA scripts.

It can be loaded and run.

https://www.lua.org/manual/5.2/manual.html

Scripting Documentation: https://gameguardian.net/help/

  Reveal hidden contents

 

GG function stored in table named gg.

You can print it for get short help.



print(gg)


gg =   table(5393242c): {
       [BUILD] = 6147
       [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.31.0
       [VERSION_INT] = 83100
       [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 */
       [getLocale] = function: getLocale /* gg.getLocale() -> string */
       [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 */
       [skipRestoreState] = function: skipRestoreState /* gg.skipRestoreState() -> 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 */
}

In future we add help with examples.

 

 

Nice but are can Gameguardian can working on android 7.1.1 No Root. I just

Link to comment
Share on other sites

  • Administrators

@absolutenothing You need concatenate string for search if you want use something from your input.

5 hours ago, absolutenothing said:

gg.searchNumber ('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

Must work (in some sense - search is bad and must fail). Maybe you erase gg.TYPE_DWORD in your previous code and set it to nil.

This code run for me. It is work not as intended, but compiled and run.

Link to comment
Share on other sites

hi guys, do we have a function for group search for prompt and exact value like on the 2nd line on my script

example:

d = gg.prompt({A='A'}, {A='0'})

gg.searchNumber ('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.searchNumber('d.A',gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.getResults(1)

gg.editAll('99999999',gg.TYPE_DWORD)

 

i always have problem on that 2nd line, heres the error.

Script error: org.luaj.vm2.LuaError: @/storage/emulated/0/Download/lua tests/File.txt:54
`gg.searchNumber('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)`
gg.searchNumber: bad argument #2 (string): number expected, got nil
stack traceback:
    /storage/emulated/0/Download/lua tests/File.txt:54: in main chunk
    [Java]: in ?
    at org.luaj.vm2.Varargs.argerr(Varargs.java:280)
    at org.luaj.vm2.Varargs.optint(Varargs.java:202)
    at android.ext.Script$searchNumber.invokeUi(Script.java:1871)
    at android.ext.Script$ApiFunction.run(Script.java:737)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5120)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
    at dalvik.system.NativeStart.main(Native Method)

correction when i typed here at site, it should be this

d = gg.prompt({A='A'}, {A='0'})

gg.searchNumber (d.A,'123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.searchNumber('d.A',gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

gg.getResults(1)

gg.editAll('99999999',gg.TYPE_DWORD)

thats why the error popped up on above codes..  when typed the below codes

gg.searchNumber ('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

6 minutes ago, Enyby said:

@absolutenothing You need concatenate string for search if you want use something from your input.

Must work (in some sense - search is bad and must fail). Maybe you erase gg.TYPE_DWORD in your previous code and set it to nil.

This code run for me. It is work not as intended, but compiled and run.

theres no error on gg and does compiled and run like you said--- but heres what i found on search history.

the d = gg.prompt({A='A'}, {A='0'}) do the search on the value "d.A" first, then the gg.searchNumber('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0) is not shown on the search history.

now i tried putting the prompt like this.

d = gg.prompt({A='A',B='B',C='C',E='E'}, {A='0',B='123',C='456',E='789'})

gg.searchNumber ('d.A;123;456;789::2000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)

so the script started searching again,when i looked the search history again, now it do search them individually d.A,789,456,123 respectively.

heres also my whole test code to see

__________________________________________________

Quote

gg.toast('Test by absolutenothing')

print('Test by absolutenothing')

--Game guardian detection

if gg.BUILD < 5511 then

print('You need latest version of GameGuardian to run this script. Minimum GG v.8.30.0.')
goto update

end

if gg.isVisible(true) then
   gg.setVisible(false)
   end
gg.clearResults()

goto START

::START::

menu = gg.choice({'Diamond','EXIT'},nil,'just do it')


if menu == 1 then goto absolutenothingDiamond end

if menu == 2 then goto absolutenothingGold end

if menu == nil then print('error') end

goto noselect

::absolutenothingDiamond::

--d = gg.prompt({a='Number of Diamonds'} , {a='0'})

d = gg.prompt({a='Number of Diamonds', e='16777473', c='5', b='15' }, {a='0',b = '15',c='5', e='16777473' })
--d = gg.prompt({a='Number of Diamonds'}, {a='0',b = '15',c='5', e='16777473' })
--b = 15
--c = 5
--e = 16777473
gg.toast('Test Lua by absolutenothing')
gg.searchNumber('d.a;15;5;16777473::10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)
--gg.searchNumber('d.a;d.b;d.c;d.e:65500', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)
--gg.searchNumber('15;5;16777473::100', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)
gg.searchNumber('d.a', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0)
gg.getResults(1)
goto absolutenothing

goto sdone

::sdone::

print('first time')

gg.toast('do what you want')

os.exit()


::noselect::

print('selected nothing')

::update::

print('update your gameguardian')

gg.toast('GG not support')

::absolutenothing::
gg.toast('Test by absolutenothing')
print('Enjoy')

 

Link to comment
Share on other sites

  • Administrators

Use code tag, not quote.

You need concatenate string.

gg.searchNumber('d.a;15;5;16777473::10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0) -- not work
gg.searchNumber(d.a..';15;5;16777473::10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0) -- work

Register is important. d.a and d.A is not same.

Also if I copy text from forum I get strange char at end of line with searchNumber.

_______________________________________________
added 1 minute later

Script searches do not use input history. Search history not exists in gg.

Link to comment
Share on other sites

1 hour ago, Enyby said:

Use code tag, not quote.

You need concatenate string.


gg.searchNumber('d.a;15;5;16777473::10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0) -- not work
gg.searchNumber(d.a..';15;5;16777473::10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0) -- work

Register is important. d.a and d.A is not same.

Also if I copy text from forum I get strange char at end of line with searchNumber.

_______________________________________________
added 1 minute later

Script searches do not use input history. Search history not exists in gg.

thanks a lot @Enyby problem solved ❤️ ?

Link to comment
Share on other sites

hello again, seems im having trouble with the setValues()


d = gg.prompt({i='MaxZ;LvlupZ;MaxX;LvlupX'}, {i='0;1;5::100'})

--note MaxZ = 123;LvlupZ = 456;MaxX 789;LvlupX = 999

--note wanted to do group search of d['i'] and '0;1;5::100' unlike with previews code gg.searchNumber(d.a..';15;5;16777473::10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0) didn't work the same way/error


gg.searchNumber(d['i'], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(4)
--gg.editAll('100',gg.TYPE_DWORD) testing with freeze
o = gg.getResults(4)
u = {} 
u[1] = {} 
u[1].value = '50'
u[1].flags = gg.TYPE_DWORD
u[1].freeze = true
u[1].freezeType = gg.FREEZE_NORMAL
u[2] = {} 
u[2].value = '100'
u[2].flags = gg.TYPE_DWORD
u[2].freeze = false
u[2].freezeType = gg.FREEZE_NORMAL
print('Replaced:', gg.addListItems(u))
gg.toast('first time freezing') 
goto absolutenothing

 

error popped below

Script ended:
testing by absolutenothing
Replaced:     org.luaj.vm2.LuaError: bad argument: long expected, got nil
Enjoy

Exit.

the code above do search the prompt d['i'] like this

123;456;789;999;0;1;5::100

then getResults(4)

after that it does not edit the u[1] and u[2] then the script ended with error

 

Link to comment
Share on other sites

  • Administrators

@absolutenothing Use code tag if you post code on forum. It is hard to read otherwise.

_______________________________________________
added 2 minutes later
6 minutes ago, absolutenothing said:

o = gg.getResults(4)
u = {} 

You use variable o for save data. After that you created new empty table u and work with it.

You need learn lua. Read books, because you not understand basic things and try combine text as some magic.

Link to comment
Share on other sites

  • Administrators

In short, you must use variable o. And do not recreate table (u[1], u[2]) every time.

o = gg.getResults(2)

o[1].value = '50'
o[1].freeze = true

o[2].value = '100'
o[2].freeze = false

print('Replaced:', gg.addListItems(o))

Your problem - you do not understand what this code do. Nor what is variable, table in lua, how it works and so on. It is like painting from blind.

Link to comment
Share on other sites

47 minutes ago, Enyby said:

In short, you must use variable o. And do not recreate table (u[1], u[2]) every time.


o = gg.getResults(2)

o[1].value = '50'
o[1].freeze = true

o[2].value = '100'
o[2].freeze = false

print('Replaced:', gg.addListItems(o))

Your problem - you do not understand what this code do. Nor what is variable, table in lua, how it works and so on. It is like painting from blind.

yes ive been changing my variables and got mixed a lot, ohh thanks again @Enyby fixed it  ? and ill remember to use code tag in future thanks for understanding ❤️

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.