Jump to content
Enyby

LUA scripting

Recommended Posts

47 minutes ago, circleous said:

Any documentation to GG script library yet?

Will be in future. Now only short help in first post and button help in execute script dialog in latest test builds/ next releases.

Share this post


Link to post
Share on other sites

Please add somehthing like Kill the script process. I got into infinite loop by mistake while debug the script.

Share this post


Link to post
Share on other sites
Spoiler

--[[
  MIT License

  Copyright (c) 2017 Kyra Sierra

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
]]--

gg.alert('Grand Prix Story 2 stats changer hack by [circleous]')

local origData = gg.prompt(
  {'ID', 'Strength', 'Agility', 'Tech', 'IQ', 'Anlys', 'Appl'},
  {[1]='PUT UNIQUE ID'},
  {[1]='text'}
)

if origData[1] ~= nil then
  local file = io.open(gg.EXT_FILES_DIR..'/GPS2_stats_backup.lua', 'w')
  io.output(file)
  for i,data in pairs(origData) do
    io.write(data..'\n')
  end
  io.close(file)
  gg.alert('Backup stats data saved to '..gg.EXT_FILES_DIR..'/GPS2_stats_backup.lua')
end

local replaceData = gg.prompt({ 'Replace All' })

gg.toast('Finding eggs...')

gg.setRanges(gg.REGION_ANONYMOUS)

if replaceData[1] then -- REPLACE ALL -- TODO: Replace by data ID
	gg.toast('Crushing the eggs...')
	gg.editAll(''..replaceData[1]..'', gg.TYPE_DWORD)
else
	gg.toast('ERROR: No value given in Replace All')
end

gg.alert('Woot! SUCCESS.')

 


$ cat /sdcard/Android/data/com.wxgrgyjnzvqbddnjcqwf/files/GPS2_stats_backup.lua
ANNE
875
872
869
867
867
869
Spoiler

zb61K.jpg

OAgDC.jpg

i6Jkf.jpg

An example for File I/O operation still primitive, but you could use your own wrapper for that. since GG will add lua import in future so that table.save and table.load can be used thus the complex File I/O wrapper somewhat not needed.

Edited by circleous

Share this post


Link to post
Share on other sites
3 hours ago, circleous said:

Please add somehthing like Kill the script process.

Already present if UI open. Stop button at left top corner.

 

scr_1500498032.jpg

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

since GG will add lua import in future so that table.save and table.load can be used thus the complex File I/O wrapper somewhat not needed.

Do not make sense. Format of file can be any.

Share this post


Link to post
Share on other sites
gg.clearResults()
if gg.isVisible(true) then 
  
   gg.setVisible(false) 
  --[===[ is gg.isvisible and gg.setVisible supported in GG ?
end 
::novalue::
gg.toast('Candy Crush Soda Lua Script By Ankit007')
data = gg.prompt({[1]='Enter Your Score'}, {[1]''})
if data == nil then
   gg.toast ('Please enter a value')
   goto novalue
end 
gg.searchNumber(data[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
if gg.getResultCount() < 6 then
	data = gg.editAll('2117483647', gg.TYPE_DWORD))
	gg.toast (' Enjoy the game')
else
gg.toast( 'to many values found update the value and try  again')
end

As i am new in lua scripting just started yesterday, and after understanding the lua first i started with Candy Crush Soda Score Increase Script

I want this script to hide the main gg and show only the script screen and

also 2 if conditions one to check that user should not enter the a null value and second that if to many values found then it should say that update the value

but to update and search again the user should close the script, i tried t add the sleep function but don't know much about it

Any thing required to be changed in the code ?

new 1.lua

Share this post


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

Do not make sense. Format of file can be any.

:/ I just started learning LUA this morning. Community Documentation said File format was .lua. dont bully plox. Thanks for info tho.

But the table.load and table.save isn't usable right? Tried it many times, but seems like its just an empty function (nil)

Edited by circleous
grammad fix

Share this post


Link to post
Share on other sites
Just now, ankit007 said:

data = gg.prompt({[1]='Enter Your Score'}, {[1]''})

prompt(table, [table, [table]])

Default value for input table is nil, you don't need to add [1]''

Share this post


Link to post
Share on other sites
3 minutes ago, circleous said:

prompt(table, [table, [table]])

Default value for input table is nil, you don't need to add [1]''

thx but still it will be nil as i didn't passed any value to it

anyway thanks , don't know much about lua, still in learning stage

Edited by ankit007

Share this post


Link to post
Share on other sites
3 hours ago, ankit007 said:

--[===[ is gg.isvisible and gg.setVisible supported in GG ?

 

17 hours ago, Enyby said:

Build 5559:

GameGuardian.5559.apk

 

_______________________________________________
added 0 minutes later
3 hours ago, ankit007 said:

{[1]''})

error. Skipped '='.

_______________________________________________
added 2 minutes later
3 hours ago, ankit007 said:

I want this script to hide the main gg and show only the script screen and

use isVisible, setVisible.

_______________________________________________
added 2 minutes later
4 hours ago, ankit007 said:

to check that user should not enter the a null value

Make check in your code.

_______________________________________________
added 3 minutes later
4 hours ago, ankit007 said:

if to many values found then it should say that update the value

getResultCount() and do anything with this number.

Share this post


Link to post
Share on other sites
4 hours ago, ankit007 said:

to update and search again the user should close the script, i tried t add the sleep function but don't know much about it

Use loop like I do in my scripts: https://gameguardian.net/forum/topic/17447-lua-scripting/?do=findComment&comment=58903

 

_______________________________________________
added 2 minutes later
4 hours ago, circleous said:

Community Documentation said File format was .lua.

It is not format. It is only extension.

Hat can be red. but it doesn't say anything useful about people below it. Same with file. extension of file and file internal structure AKA format not connected. You can rename .txt to .exe but this not make text file executable.

_______________________________________________
added 2 minutes later
4 hours ago, circleous said:

But the table.load and table.save isn't usable right? Tried it many times, but seems like its just an empty function (nil)

This functions not exists.

Share this post


Link to post
Share on other sites

 

Just now, Enyby said:

Hat can be red. but it doesn't say anything useful about people below it. Same with file. extension of file and file internal structure AKA format not connected. You can rename .txt to .exe but this not make text file executable.

I know about this file format thingy, while I'm reversing a crackme, need to dump some memory region and analyze it, you can't see file name but only structure, yep. Well, I've dealt with a silly C library enforcing the full path name and file format to follow the docs style. Thats where my faithful to example in docs begin, lol.

Share this post


Link to post
Share on other sites

If you fear 5 lines of code - I have bad news to you.

open
for
write
end
close

Is typical for any lang. Nothing complicated.

Share this post


Link to post
Share on other sites

@Enyby can we have the ability to make buttons using "button" command?

I tried it, no errors but no button shows up either.

 

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

×
×
  • Create New...