Jump to content

LUA scripting


Enyby
 Share

Recommended Posts

Hi Enyby I did not know how to share these functionalities for the lua scripts: if you have to move them to another post, do it without problems.

Get Filename
local p=gg.getFile()
p=p:gsub(".*\/","")

example:
/storage/emulated/0/Pictures/All.lua
return "All.lua"


Get PathName
local p=gg.getFile()
local path=p:sub(1,-string.len(string.gsub(p,".*\/",""))-1)

example:
/storage/emulated/0/Pictures/All.lua
return "/storage/emulated/0/Pictures/"

 

2 functions that can help us all. For now they do not accept "white spaces" in the name of the directory.

"/storage/emulated sd/0/Pictures/" return error o nil

Edited by ksaor88
if you have an error try this: local path=p:sub(2,-string.len(string.gsub(p,".*\/",""))-1)
Link to comment
Share on other sites

"Use lua io for work with files. Read lua reference manual." Thanks Enyby I  read the tutorial it's very good.  
The functions that I wrote are to obtain the directory where the script is being executed (current directory), I give an example of what I am using in case one of them serves:
this is the principal file "All.lua":

local p=gg.getFile()
local path=p:sub(2,-string.len(string.gsub(p,".*\/",""))-1)
gg.toast('First Character CHANGES',true)
dofile(path .. "Character1.lua")
gg.toast('Second Character CHANGES',true)
dofile(path .. "Character2.lua")

The file Character1.lua it is in the same directory and contains (this is an extract of the file) :

gg.setVisible(false)

gg.clearResults()
gg.toast('Defenses',true)
gg.searchNumber ('9012D;159F::32', gg.TYPE_FLOAT)
gg.searchNumber ('159', gg.TYPE_FLOAT)
gg.getResults(gg.getResultCount())
gg.editAll('999999', gg.TYPE_FLOAT)

[... more changes etc...]

gg.clearResults()

***( The second file changes the search number for the 2 character)

In this way we can place the script in any directory and can find the files that have to execute and be able to have the most ordered and shortest code. Dividing, in my case by characters, so when I upload the level and the values change I just have to open the corresponding character file and do the changes.

I hope I explained well. Sorry for my English 

 

Link to comment
Share on other sites

46 minutes ago, ksaor88 said:

I hope I explained well. Sorry for my English 

If the problem is about the Lua scripts finding each other, you should also remember that Game guardian takes root privileges, so the same when you are in Linux, when you elevate from USER to ROOT you are changing your home directory as well, so using default path variables will also change, so for your script you may want to be specific with the locations when trying to use multiple scripts, and/or create a prompt asking for directories before executing the script fully. If I'm wrong, well I hope this helps someone else.

Link to comment
Share on other sites

  • Administrators

Script not work as root. Only as user for gg app.

Ok, i understand you need relative path to folder of script.

I think about that. But from gg.getFile() you can get all of this. Maybe need write your some helper funcs.

Split path by / and use last part - this get you filename.

Or unset last part - it is get you path.

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

_______________________________________________
added 1 minute later

Do not think about gg as bunch of ready for use funcs. If you need some funcs - write it on lua.

Link to comment
Share on other sites

10 hours ago, Enyby said:

Script not work as root. Only as user for gg app.

Just for discussion and understanding;

Wouldn't the script be running as root since the Parent application is running as root? Or is it different when it comes to Android?

Link to comment
Share on other sites

  • Administrators

No one app can not be run from the root. GG too. From root can be run native app like GG daemon. Client side is just usual Android app. Script run on client side, so it not run from the root user.

Link to comment
Share on other sites

  • 3 weeks later...

hey i am new to this lua stuff and still learning it,

 i have already checked several scripts in this forum.

but it confused me when it comes to find the range of value.

such an example i found a scripts for aimbot

gg.searchNumber('2;3D;2.25::200',gg.TYPE_FLOAT,false,gg.SIGN_EQUAL,0,-1)

gg.getResults(100)

gg.editAll('2.4e35',gg.TYPE_FLOAT)

gg.toast('aimbot enable')

goto START

 

ok based on these code i dont understand where the value of 

2;3D;2.25::200 and 2.4e35 came from.

and i also dont understand about type of integer. how to know what type of int we should use? 

i hope you can give me some ideas

Link to comment
Share on other sites

  • Administrators
1 hour ago, n00bieS said:

i dont understand where the value of 

2;3D;2.25::200 and 2.4e35 came from.

and i also dont understand about type of integer. how to know what type of int we should use? 

You must know how to hack game before start write script.

Script only automated list of actions. It is not magic.

If you know how to hack game manually then you can write script for this.

If not - you can not write script.

Link to comment
Share on other sites

  • 2 weeks later...
::gold::
a = gg.prompt({A='Your Gold'},{A='number'}) 
goto gold1

::gold1::
gg.clearResults()
gg.searchNumber(a.A';327680~327699::5', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.searchNumber(a.A, gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(900)
goto gold2

::gold2::
b = gg.prompt({B='Change Gold To'},{B='number'}) 
goto gold3

::gold3::
gg.editAll('b.B', gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.clearResults()
gg.toast('Gold Hacked Successfully')
goto Choice

Hey this is my some part of the script. This is my first script.

I want the code to be run like this :

When user enters the input A, gg should search for group value e.g. a.A;327780~327699::5. 

But if i enter the code like 'a.A;27680~327699::5' , gg ignores it.

And if i enter it like a.A';327680~327691::5' (because i want ';327680~327699::5' in front of the input) , gg shows error "attempt to call string" .

Can u please tell me the solution.

I want to do group search with the input A. (i.e. I want ;327680~327699::5 in front of the input a.A)

Link to comment
Share on other sites

16 minutes ago, Enyby said:

You need learn lua and how to concatenete string in it.

Ok. Thank you so much. I figured it out. I will definitely learn lua when my exams are finished :D Thanks for your assistance. You are one of the best coders.

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.