Jump to content
Enyby

LUA scripting

Recommended Posts

You can specify type of input fields. This allow show something useful around it. For example button for select dir, path or some converter.

Also this switch internal keyboard to external if you need input text or file path.

print('prompt 1: ', gg.prompt(
	{any='ask any',num='ask num',text='ask text', path='ask path',file='ask file',set='ask set',speed='ask speed'}, 
	{any='any val',speed=123,set=-0.34}, 
	{num='number',text='text',path='path',file='file',set='setting',speed='speed'}
))
print('prompt 2: ', gg.prompt(
	{[0]='ask any',[1]='ask num',[2]='ask text',[3]='ask path',[4]='ask file',[5]='ask set',[6]='ask speed'}, 
	{[0]='any val',[6]=123,[5]=-0.34}, 
	{[1]='number',[2]='text', [3]='path',[4]='file',[5]='setting',[6]='speed'}
))

scr_1500298624.jpgscr_1500298639.jpgscr_1500298655.jpgscr_1500298662.jpg

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

i found goto command more convinient for myself.

You can use goto. But for big scripts it can be hell. For you or for anyone who try understand how it works. Even for you from few months.

Share this post


Link to post
Share on other sites

I think if specfied by comments it won't make it that confusing. 

Well, i have read something somewhere that there are a thousand different coding ways to do the exact same job. 

It's all about how someone feels it's convinient for him/her.

Share this post


Link to post
Share on other sites

@Enyby

2 things: 

1_What does "local" do in this line? :

local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})

2_ by implementing this code my script crashes: 

 

if d == nil then
			gg.alert('Script canceled')
			break
		end
_______________________________________________
added 4 minutes later

Looks like "break" not working well for me. 

I used this: 

if d == nil 
then    gg.alert('Script canceled')             
goto c
end

Share this post


Link to post
Share on other sites

1. Define local variable. Without it be in global scope. Read lua manual.

All things except gg.* is usual lua code. Then you if you see something unknown you need read reference manual for lua. Or type 'lua local' into google, for example.

https://www.lua.org/pil/4.2.html

Quote

4.2 – Local Variables and Blocks

Besides global variables, Lua supports local variables. We create local variables with the local statement:


    j = 10         -- global variable
    local i = 1    -- local variable

Unlike global variables, local variables have their scope limited to the block where they are declared. A block is the body of a control structure, the body of a function, or a chunk (the file or string with the code where the variable is declared).

2. You need remove break. Break is exit from loop. You do not have loop. So you need jump to exit or call os.exit() for stop script execution.

Share this post


Link to post
Share on other sites
Quote

4 - Libraries

Standard Libraries

Libraries are coded to closely match the behavior specified in See standard lua documentation for details on the library API's

The following libraries are loaded by both JsePlatform.standardGlobals() and JmePlatform.standardGlobals():


	base
	bit32
	coroutine
	io
	math
	os
	package
	string
	table

http://www.luaj.org/luaj/3.0/README.html

Most of them exists in gg scripts. Except coroutine and some calls in os (popen, execute) for security reasons.

You can use print for describe their content:

print('base =', base)
print('bit32 =', bit32)
print('coroutine =', coroutine)
print('io =', io)
print('os =', os)
print('package =', package)
print('string =', string)
print('table =', table)
base = nil
bit32 =        table(537f0fa4): {
       [arshift] = arshift
       [band] = band
       [bnot] = bnot
       [bor] = bor
       [btest] = btest
       [bxor] = bxor
       [extract] = extract
       [lrotate] = lrotate
       [lshift] = lshift
       [replace] = replace
       [rrotate] = rrotate
       [rshift] = rshift
}
coroutine =    nil
io =   table(537f85ac): {
       [close] = close
       [flush] = flush
       [input] = input
       [lines] = lines
       [open] = open
       [output] = output
       [read] = read
       [tmpfile] = tmpfile
       [type] = type
       [write] = write
}
os =   table(537f9ae4): {
       [clock] = clock
       [date] = date
       [difftime] = difftime
       [exit] = function: exit
       [getenv] = getenv
       [remove] = remove
       [rename] = rename
       [setlocale] = setlocale
       [time] = time
       [tmpname] = tmpname
}
package =      table(537f043c): {
       [loaded] = table(537f044c): {
       [bit32] = table(537f0fa4): {
       [arshift] = arshift
       [band] = band
       [bnot] = bnot
       [bor] = bor
       [btest] = btest
       [bxor] = bxor
       [extract] = extract
       [lrotate] = lrotate
       [lshift] = lshift
       [replace] = replace
       [rrotate] = rrotate
       [rshift] = rshift
}
       [gg] = table(537fa8a8): {
       [BUILD] = 5523
       [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_INEQUAL] = 268435456
       [SIGN_LARGER] = 67108864
       [SIGN_SMALLER] = 134217728
       [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.28.0
       [VERSION_INT] = 82800
       [alert] = function: alert /* gg.alert(string text[, string positive[, string negative[, string neutral]]]) -> int: 0 = cancel, 1 = positive, 2 = negative, 3 = neutral */
       [clearResults] = function: clearResults /* gg.clearResults() -> nil */
       [copyMemory] = function: copyMemory /* gg.copyMemory(long from, long to, int bytes) -> true || string with error */
       [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 */
       [getRanges] = function: getRanges /* gg.getRanges() -> int */
       [getResultCount] = function: getResultCount /* gg.getResultCount() -> long */
       [getResults] = function: getResults /* gg.getResults(int count) -> array || string with error */
       [getSelectedPackage] = function: getSelectedPackage /* gg.getSelectedPackage() -> string || nil */
       [getSpeed] = function: getSpeed /* gg.getSpeed() -> double */
       [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 */
       [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, 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 */
       [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, long memoryFrom, long memoryTo) -> true || string with error */
       [timeJump] = function: timeJump /* gg.timeJump(string time) -> true || string with error */
       [toast] = function: toast /* gg.toast(string text[, bool fast]) -> nil */
}
       [io] = table(537f85ac): {
       [close] = close
       [flush] = flush
       [input] = input
       [lines] = lines
       [open] = open
       [output] = output
       [read] = read
       [tmpfile] = tmpfile
       [type] = type
       [write] = write
}
       [math] = table(537f473c): {
       [abs] = function: abs
       [acos] = function: acos
       [asin] = function: asin
       [atan2] = function: atan2
       [atan] = function: atan
       [ceil] = function: ceil
       [cos] = function: cos
       [cosh] = function: cosh
       [deg] = function: deg
       [exp] = function: exp
       [floor] = function: floor
       [fmod] = function: fmod
       [frexp] = function: frexp
       [huge] = inf
       [ldexp] = function: ldexp
       [log] = function: log
       [max] = function: max
       [min] = function: min
       [modf] = function: modf
       [pi] = 3.1415927
       [pow] = function: pow
       [rad] = function: rad
       [random] = function: random
       [randomseed] = function: randomseed
       [sin] = function: sin
       [sinh] = function: sinh
       [sqrt] = function: sqrt
       [tan] = function: tan
       [tanh] = function: tanh
}
       [os] = table(537f9ae4): {
       [clock] = clock
       [date] = date
       [difftime] = difftime
       [exit] = function: exit
       [getenv] = getenv
       [remove] = remove
       [rename] = rename
       [setlocale] = setlocale
       [time] = time
       [tmpname] = tmpname
}
       [package] = table(537f043c): *** RECURSION ***
       [string] = table(537f2b4c): {
       [byte] = function: byte_
       [char] = function: char_
       [dump] = function: dump
       [find] = function: find
       [format] = function: format
       [gmatch] = function: gmatch
       [gsub] = function: gsub
       [len] = function: len
       [lower] = function: lower
       [match] = function: match
       [rep] = function: rep
       [reverse] = function: reverse
       [sub] = function: sub
       [upper] = function: upper
}
       [table] = table(537f1ad0): {
       [concat] = function: concat
       [insert] = function: insert
       [pack] = function: pack
       [remove] = function: remove
       [sort] = function: sort
       [unpack] = function: unpack
}
}
       [loadlib] = function: loadlib
       [path] = ?.lua
       [preload] = table(537f04bc): {
}
       [searchers] = table(537f08b8): {
       [1] = function: preload_searcher
       [2] = function: lua_searcher
       [3] = function: java_searcher
}
       [searchpath] = function: searchpath
}
string =       table(537f2b4c): {
       [byte] = function: byte_
       [char] = function: char_
       [dump] = function: dump
       [find] = function: find
       [format] = function: format
       [gmatch] = function: gmatch
       [gsub] = function: gsub
       [len] = function: len
       [lower] = function: lower
       [match] = function: match
       [rep] = function: rep
       [reverse] = function: reverse
       [sub] = function: sub
       [upper] = function: upper
}
table =        table(537f1ad0): {
       [concat] = function: concat
       [insert] = function: insert
       [pack] = function: pack
       [remove] = function: remove
       [sort] = function: sort
       [unpack] = function: unpack
}

 

GameGuardian.git_signed.apk

Share this post


Link to post
Share on other sites

You guys are really working fast! 

A lot of commands are added, tommorow I will learn them through manual and make good examples of them :)

I'm really loving this.. 😂 

 

My example v1.3:

-Fixed some typos 

-removed goto c and checkpoint c to. "os. Exit()" to make it less confusing 

-removed unneccesary code line for hiding GameGuardian UI after searching 

-better explanation of "gg. Sleep()" code 

-fixed script made the game a crash (only 1 value may be changed)

--v1.3

--#1 lines that start with "--" are comments, they won't be executed by script executer

--#2 you can execute "print(gg)" command to see a short help and available options for commands, it's also available at first post of Lua scripts by Enyby at gameguardian forum: https://gameguardian.net/forum/topic/17447-lua-scripting/

--#3 this is a simple example for lua scripts, provided by backlift at gameguardian forum: https://gameguardian.net/forum/profile/563312-backlift/

--#4 some functions of this script may conflict with gameguardian search helper function, recommend to disable it before running this script

--#5 each comment is related to the code above it

--#6 this is an example of an effective and functional lua script with nearly full descriptional comments

if gg.BUILD < 5511 then 	gg.alert('You need a newer version of GameGuardian to run this script. At least build 5511.') 
	os.exit() 
	end

--if gameguardian build number is below 5511, means the script will not work,so it aborts the script and exits

gg.clearResults()

-- this function clears the current search results so the script starts a new scan

::a::  

-- checkpoint "a" to restart the script if there are a lot of values found

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

-- hides the gameguardian UI after script started

d = gg.prompt 

-- "d" is a value and = means its equal to value got from "gg.prompt"

-- "gg.prompt" shows a window and requires an input from user

({A='Number of Orbs Or Dooblins'}, 

-- title of the required value, we named the value as "A" here, We could even use "Dooblins or orbs" but that makes the functional part of the code a bit long and it may bring some mistakes.

 {A='0',}) 

 -- default input of the value "A"

if d == nil 

-- if no value defined for "d"

then gg.alert('Script canceled') 			

-- show message that script is canceled 

os.exit()

-- exit the script 

end

-- mandatory argument to end the "if" command above

gg.toast 

-- toasts a message, for reminding credits, helps, warnings or etc...

('Quadropus 2.0.48 Hack by Backlift') 

-- text of the toast message

gg.setRanges 

-- set the search region

( gg.REGION_C_ALLOC) 

-- the region of the value, for comlplete list of regions, check comment #2

gg.searchNumber 

-- starts a search

(d['A'], 

-- searchs for value "d" that has the input of "A" from "gg.prompt"
 
 gg.TYPE_DOUBLE, 

 -- type of the value, for comlplete list of types, check comment #2

 true, 

 -- define wether the value is encrypted (true), or NOT encrypted (false)

 gg.SIGN_EQUAL, 

 -- define if it is equal, inequal, bigger or smaller than input value "A", see comment #2 for more info

 0, 
 
 -- starting position of memory for scanning

 -1) 

 -- ending position of memory for scanning

if gg.getResultCount() == 1

-- this is an "if" command to make the script do commands based on situation.

-- "gg.getResultCount()" will get the number of results found from search

-- this commands checks that "gg.getResultCount" is equal to 4 or less, or not, if it is equal or less, it goes to "then" command, if Not, it goes to "else" command

then gg.editAll('100000000', 

-- edits all values and set them to '100000000'

 gg.TYPE_DOUBLE) 

 -- type of the values to edit, see comment #2 for more info

gg.alert 

-- show a window with Ok button
('Hacking Done, Enjoy') 

-- text of the "gg.alert" window

print 

-- shows a text at the script end window

('Quadropus 2.0.48 Hack by Backlift') 

-- text for the "print" function

os.exit()

-- ends the script because hacking is done

gg.alert

-- show the user a message, this is to inform the user there are currently too much values found, the user may go in the game and change the value then open the gameguardian window again by tapping on it's floating icon

('Too much values found, Go to game and change the value, then open gameguardian window again')

end 

-- end of if statement, it is mandatory

::b:: 

-- checkpoint "b" for gameguardian to sleep untill user has changed the value

gg.sleep(100) 

-- sets code ro halt or sleep at current state for a certain ammount of time in milliseconds brfore continuing to next line

-- sleep 0.1 second until next command, so it will not continiously be running, or it supposed to be

if not gg.isVisible() then	goto b 

-- if gameguardian not visible, goto checkpoint "b" and rest 0.1 second then check again, user must change the value and then tap on gameguardian icon again so the code will pass this section and continue

else goto a 

-- if gameguardian is visible, means user has opened it because it changed the value, go to checkpoint "a" to start the process again

end 

-- end of if command, its mandatory

-- example made by backlift with extreme help of enyby for fixing many issues around it

-- you may edit this example and make it for other games.

-- hit the thanks if you used it :)

 

Share this post


Link to post
Share on other sites

Few tips for code style:

1. better use indentation.

2. Do not break single command with comments.

3. Single command better place on one line.

But you can code in any style. Even if anyone else hard to read it.

Now for me very hard read your script.

 

Also on paste code on forum you can select type of code for highlight. lua present in this list. By default selected Html. I think select lua produce better results.

Share this post


Link to post
Share on other sites
12 minutes ago, Enyby said:

Few tips for code style:

1. better use indentation.

Mmm... Didn't understanded, can give an example? 

Quote

2. Do not break single command with comments.

I did it to tell what ever piece of code does so others would understand better

Quote

3. Single command better place on one line.

Ok I will do that tommorow, seems better, yeah

Quote

But you can code in any style. Even if anyone else hard to read it.

Now for me very hard read your script.

Why very hard? 

I have an idea. 

How about this: 

First put all codes, no comments, then after code ends, describe what happened with comments. 

This nice? 

Quote

Also on paste code on forum you can select type of code for highlight. lua present in this list. By default selected Html. I think select lua produce better results.

I selected lua evertime. It is lua now. 

Edited by Backlift

Share this post


Link to post
Share on other sites
40 minutes ago, Backlift said:

can give an example? 

Good:

while true do
	if gg.isVisible() then
		gg.setVisible(false)
		local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})
		if d == nil then
			gg.alert('Script canceled')
			break
		end
		gg.searchNumber (d.A, gg.TYPE_DOUBLE, true, gg.SIGN_EQUAL, 0, -1)
		cnt = gg.getResultCount()
		if cnt == 0 then 
			gg.alert('Search failed')
			break
		end
		
		if cnt <= 4 then 
			gg.editAll('100000000', gg.TYPE_DOUBLE)
			gg.alert('Hacking Done, Enjoy')
			break
		end 
		
		gg.alert ('Go to game and change the value, then click on gg icon to continue')		
	end
	gg.sleep(100)
end

Bad:

while true do
if gg.isVisible() then
gg.setVisible(false)
local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})
if d == nil then
gg.alert('Script canceled')
break
end
gg.searchNumber (d.A, gg.TYPE_DOUBLE, true, gg.SIGN_EQUAL, 0, -1)
cnt = gg.getResultCount()
if cnt == 0 then 
gg.alert('Search failed')
break
end

if cnt <= 4 then 
gg.editAll('100000000', gg.TYPE_DOUBLE)
gg.alert('Hacking Done, Enjoy')
break
end 

gg.alert ('Go to game and change the value, then click on gg icon to continue')
end
gg.sleep(100)
end

 

41 minutes ago, Backlift said:

I did it to tell what ever piece of code does so others would understand better

As for me this make code very difficult to read.

42 minutes ago, Backlift said:

First put all codes, no comments, then after code ends, describe what happened with comments. 

This nice? 

Good:

-- local defines local variable, prompt show prompt with fields, A - name of index in table, '0' - default value
local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})

Bad:

-- local defines local variable
local d = 
-- prompt show prompt with fields
gg.prompt({
-- A - name of index in table
A='Number of Orbs Or Dooblins'}, {A=
--'0' - default value
'0'})

 

_______________________________________________
added 1 minute later

In last case very hard assembly full command in the mind.

_______________________________________________
added 3 minutes later

About good formatting code written lot of articles. Google "lua code style". For example on wiki: http://lua-users.org/wiki/LuaStyleGuide

Quote

Formatting

Indentation - Indenting often uses two spaces. This is followed in Programming in Lua, the Lua Reference Manual, Beginning Lua Programming, and the Lua users wiki. (Why this is the case, I don't know, but perhaps it is because Lua statements can tend to be deeply nested, even in a LISP or functional manner, or perhaps it is affected by the fact that the code in these examples is small and pedagogical.) You'll see other common conventions (e.g. 3-4 spaces or tabs).

 

 

for i,v in ipairs(t) do
  if type(v) == "string" then
    print(v)
  end
end

 

Share this post


Link to post
Share on other sites
1 hour ago, Enyby said:

Good:


while true do
	if gg.isVisible() then
		gg.setVisible(false)
		local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})
		if d == nil then
			gg.alert('Script canceled')
			break
		end
		gg.searchNumber (d.A, gg.TYPE_DOUBLE, true, gg.SIGN_EQUAL, 0, -1)
		cnt = gg.getResultCount()
		if cnt == 0 then 
			gg.alert('Search failed')
			break
		end
		
		if cnt <= 4 then 
			gg.editAll('100000000', gg.TYPE_DOUBLE)
			gg.alert('Hacking Done, Enjoy')
			break
		end 
		
		gg.alert ('Go to game and change the value, then click on gg icon to continue')		
	end
	gg.sleep(100)
end

Bad:


while true do
if gg.isVisible() then
gg.setVisible(false)
local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})
if d == nil then
gg.alert('Script canceled')
break
end
gg.searchNumber (d.A, gg.TYPE_DOUBLE, true, gg.SIGN_EQUAL, 0, -1)
cnt = gg.getResultCount()
if cnt == 0 then 
gg.alert('Search failed')
break
end

if cnt <= 4 then 
gg.editAll('100000000', gg.TYPE_DOUBLE)
gg.alert('Hacking Done, Enjoy')
break
end 

gg.alert ('Go to game and change the value, then click on gg icon to continue')
end
gg.sleep(100)
end

Well I'm writing these codes on my android phone using a simple text editor, that needs an advanced code editor, I will search for it. 

1 hour ago, Enyby said:

As for me this make code very difficult to read.

Good:


-- local defines local variable, prompt show prompt with fields, A - name of index in table, '0' - default value
local d = gg.prompt({A='Number of Orbs Or Dooblins'}, {A='0'})

Bad:


-- local defines local variable
local d = 
-- prompt show prompt with fields
gg.prompt({
-- A - name of index in table
A='Number of Orbs Or Dooblins'}, {A=
--'0' - default value
'0'})

Your right, that's better, I will do that. 

 

1 hour ago, Enyby said:
_______________________________________________
added 1 minute later

In last case very hard assembly full command in the mind.

It's hard, but I like it. It's like emulating the codes before writing and write-on-the-go at the same time. 

1 hour ago, Enyby said:
_______________________________________________
added 3 minutes later

About good formatting code written lot of articles. Google "lua code style". For example on wiki: http://lua-users.org/wiki/LuaStyleGuide

 

I will also check that thanks for the reply. 

Share this post


Link to post
Share on other sites

Not bad script from one chinese user:

299f7f3c972b82645d3a881b6117d978.jpg

Can be used as example for make automated group search with edit values.

Share this post


Link to post
Share on other sites

@Enyby im doing what i can with my phone, it's a phone anyway, if i just had my pc, i would deffinietly write it better with notepad++.

anyway, i tried to fix as much as i can, whats your opinion?

sample:

-- Quadropus hack script by backlift v1.4 

-- lines that start with "--" are comments, they won't ne executed by script executer, A comment starts with a double hyphen (--) anywhere outside a string

-- you can execute "print(gg)" command to see a short help and available options for commands, it's also available at first post of Lua scripts by Enyby at gameguardian forum: https://gameguardian.net/forum/topic/17447-lua-scripting/

-- this is a simple example for lua scripts, provided by backlift with extreme help from enyby for fixing many issues, backlift at gameguardian forum: https://gameguardian.net/forum/profile/563312-backlift/

-- some functions of this script may conflict with gameguardian search helper function, recommend to disable it before running this script

-- you may use this example for creating your own script, just hit the thanks then :)

-- "if" is a command to make whether a script to be executed or not based on condition defined 

-- "gg.BUILD" will check gameguardian build number and argument "< 5511" makes it respond true to "if" command if game guardian build number is lower than 5511 

-- "then" is a mandatory argument for "if" command to set the action for "if" command if it's condition is true 

-- "gg.alert" will show a message window with an OK button, the text of it must be inside of ('') 

-- "os.exit" will terminate the host program, it can also send a respond to parent process a code written in () 

-- "end" is a mandatory argument to finish an "if" statement

if gg.BUILD < 5511 then 
			gg.alert('You need a newer version of GameGuardian to run this script. At least build 5511.') 
			os.exit() 
			end 

 

Share this post


Link to post
Share on other sites

i made a lot of modifications to it, here it is:( it will get better, still a good source for simple things)

i need feedbacks :)

-- simple hack script by backlift v1.4 

-- lines that start with "--" are comments, they won't be executed by script executer, A comment starts with a double hyphen (--) anywhere outside a string

-- you can execute "print(gg)" command to see a short help and available options for commands, it's also available at first post of Lua scripts by Enyby at gameguardian forum: https://gameguardian.net/forum/topic/17447-lua-scripting/

-- this is a simple example for lua scripts, provided by backlift with extreme help from enyby for fixing many issues, backlift at gameguardian forum: https://gameguardian.net/forum/profile/563312-backlift/

-- some functions of this script may conflict with gameguardian search helper function, i recommend to disable it before running this script

-- you may use this example for creating your own script, just hit the thanks then :)

-- "if" is a command to make whether a script to be executed or not based on condition defined 

-- "gg.BUILD" will check gameguardian build number and argument "< 5511" makes it respond true to "if" command if game guardian build number is lower than 5511 

-- "then" is a mandatory argument for "if" command to set the action for "if" command if it's condition is true 

-- "gg.alert" will show a message window with an OK button, the text of it must be inside of ('') 

-- "os.exit" will terminate the host program, it can also send a respond to parent process a code written in (), while empty, by default it send "true" if host program terminated seccussfully and "false" if script couldn't terminate the host program seccussfully, () is mandatory even if empty

-- "end" is a mandatory argument to finish an "if" statement

if gg.BUILD < 5511 then 
			gg.alert('You need a newer version of GameGuardian app to run this script. At least build 5511.') 
			os.exit() 
			end 

-- "gg.clearResults" will clear the current search results, so the script may start a new scan. ()is mandatory even if empty	

gg.clearResults()

-- "::restart::" is a mark for "goto" function, a mark name can be a number or a word, selecting a meaningful mark is better, as "goto" function is not very recommended for it's confusability, so a meaningful mark may decrease possible errors 

::restart::  

-- "gg.isVisible" checks if gameguardian UI is open or not whether true or false is in () it responds true if statement is true and false if statement is false.

-- "gg.setVisible" will set the visibility of gameguardian UI, true shows the UI and false hides the UI.

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

-- "gg.toast" will toast a message for the user, the text is in ('')

gg.toast('simple hack script by  Backlift') 

--  "Value" is an object, "=" means it's equal to respond of "gg.prompt"

-- "gg.prompt will show a window to user and asks the  user to enter a value 

-- "INPUT" is a name for the value got from user, or simply input of user, the first bracket containing a string after "=" inside of '' is mandatory and it defines the  title for the field that asks the user for an input, and the second bracket containing a string after "=" inside of '' is optional and it defines the initial value for "INPUT"

value = gg.prompt({INPUT='Enter value'}, {INPUT='0'})

-- "nil" whose main property is to be different from any other value; it usually represents the absence of a useful value, Both "nil" and "false" make a condition false, the purpose of the function below is to cancel the script if the user has not entered any value in the field, so the script will not crash

if value == nil then
   gg.alert ('Script Canceled, No input')
   os.exit(	)
   end

-- "gg.setRanges" is a command to set the region of the search, for the complete list of regions, check the forum.

gg.setRanges (gg.REGION_C_ALLOC)

-- "gg.searchNumber" is a function that sends the search command to the GameGuardian

-- the first string "value['INPUT']" is the data to send to the GameGuardian, in this case we are sending the "value" that it got it's value from "INPUT"

-- second string "gg.TYPE_DOUBLE" is to determine the type of the value, it's double in this case, for the complete list of value types, check the forum.

-- third string is "true" to define whether the value is encrypted or not by "true" or "false"

-- forth value "gg.SIGN_EQUAL" is to define whetherforum the value to search is equal to "INPUT" or inequal, smaller or bigger. for this case it's equal. for more info, check the forum

-- fifth value is to define the start location of search in memory, defined "0" to start from the first, and sixth value is to define the stop location of search, defined "-1" means until the end of memory. it's mostly used to search a certain area of memory.

gg.searchNumber(value['INPUT'], gg.TYPE_DOUBLE, true, gg.SIGN_EQUAL, 0, -1) 

-- "gg.getResultCount" will check the counts of results, the argument "== 1" checks if the counts are exactly 1 number.if the argument is true, the code responds "true" so may the "if" statement run "then" part, if the argument is false, the code responds "false" so may the "if" statement run the "else" part or take no action.

-- "gg.editall" will modify all current values in results, the first string "100000000" is the wanted value, the second string "gg.TYPE_DOUBLE" is to define wich type of values to be modified.

if gg.getResultCount() == 1 then
   gg.editAll('100000000', gg.TYPE_DOUBLE) 
   gg.alert('Hacking Done!, Enjoy') 
   os.exit()
   else gg.alert('Too much values found, Go to game and change the value, then open gameguardian window again')
   end 

::loop::

-- "gg.sleep()" will stop the script at the current line for defined amount of time. the time is in milliseconds, each 1 second is 1000 milliseconds.

gg.sleep(100) 

if not gg.isVisible() then	
   goto loop
   else goto restart
   end

 

Share this post


Link to post
Share on other sites
4 minutes ago, Backlift said:

"os.exit" will terminate the host program, it can also send a respond to parent process a code written in (), while empty, by default it send "true" if host program terminated seccussfully and "false" if script couldn't terminate the host program seccussfully, () is mandatory even if empty

os.exit take integer as param. 0 is usual exit. all another - is unusual. Not boolean, but if you pass it it cast to 0 or 1.

8 minutes ago, Backlift said:

"::restart::" is a mark for "goto" function

Usually this thing named `label`.

10 minutes ago, Backlift said:

"INPUT" is a name for the value got from user

Must be single word and not one from predefined reserved words like `for` or `if`.

If this is not single word - must be used wide way for create table. In lua reference present more information.

 

Share this post


Link to post
Share on other sites
14 minutes ago, Backlift said:

I read that on Lua manual that it send true or false:

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

Quote

os.exit ([_code])

Calls the C function exit, with an optional code, to terminate the host program. The default value for code is the success code.

C function exit take int.

http://lua-users.org/wiki/OsLibraryTutorial

Quote

os.exit([_code])

Calls the C function exit, with an optional code, to terminate the host program. The default value for code is the success code.

 

> os.exit(0)   -- kill the Lua shell we are in and pass 0 back to parent shell

 

14 minutes ago, Backlift said:

I thought, making it a word, may make it more simple to understand for others.

then newbie write something like `{my var='test'}` and get errors.

http://lua-users.org/wiki/TableConstructors

Share this post


Link to post
Share on other sites

@Enyby Ok

1_i will fix the "os.exit" description.

2_will change value and input to V and I.

 

other than these, how is the code?

 

Share this post


Link to post
Share on other sites
16 minutes ago, Enyby said:

All look like ok.

thanks.

when i finished it, should i create a seprate post for it? and develope it further in there?

 

Share this post


Link to post
Share on other sites

@BackliftBetter create separate topic for this. I talk with d2dyno for separate section for all LUA script topics.

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

×