Administrators Enyby Posted July 17, 2017 Author Administrators Posted July 17, 2017 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
Backlift Posted July 17, 2017 Posted July 17, 2017 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.
Administrators Enyby Posted July 17, 2017 Author Administrators Posted July 17, 2017 Not bad script from one chinese user: Can be used as example for make automated group search with edit values.
Backlift Posted July 18, 2017 Posted July 18, 2017 @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
Backlift Posted July 18, 2017 Posted July 18, 2017 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
Administrators Enyby Posted July 18, 2017 Author Administrators Posted July 18, 2017 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.
Backlift Posted July 18, 2017 Posted July 18, 2017 1 minute ago, Enyby said: 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. I read that on Lua manual that it send true or false: os.exit (]) Calls the ISO C function exit to terminate the host program. If code is true, the returned status isEXIT_SUCCESS; if code is false, the returned status is EXIT_FAILURE; if code is a number, the returned status is this number. The default value for codeis true. If the optional second argument closeis true, closes the Lua state before exiting. 1 minute ago, Enyby said: Usually this thing named `label`. Thanks I will fix it. 1 minute ago, Enyby said: 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. The code is working fine. I thought, making it a word, may make it more simple to understand for others.
Administrators Enyby Posted July 18, 2017 Author Administrators Posted July 18, 2017 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
Backlift Posted July 18, 2017 Posted July 18, 2017 @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?
Administrators Enyby Posted July 18, 2017 Author Administrators Posted July 18, 2017 All look like ok.
Backlift Posted July 18, 2017 Posted July 18, 2017 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?
Administrators Enyby Posted July 18, 2017 Author Administrators Posted July 18, 2017 @BackliftBetter create separate topic for this. I talk with d2dyno for separate section for all LUA script topics.
Administrators Sysadmin Posted July 18, 2017 Administrators Posted July 18, 2017 @Backlift Upload LUA scripts here: https://gameguardian.net/forum/files/category/6-lua-scripts/ 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now