Jump to content
  • 0

Make lua script


AhmadAlkatiri

Question

I'm newbe in gg lua script. I want to ask some questions to make my first script.I want when the script loads, the menu appears options to change the gold value or change the value of ruby. Then when I choose one of them, the script popped up a search box to fill current value of gold / ruby. And how do I write value 2 in the search box so that it automatically find the value for "2000 ~ 3000" and if I write value 3 in the search box then automatically finds a value for "3000 ~ 4000" (sometimes some games only write 18k in the amount of money and I don't know the exact value of it, then it will be very troublesome to type "18000 ~ 19000" in the search box if I just can type "18" to look for it), and also how to keep my script popping out the search box until finally there are at least a minimum of 12 addresses and then stop popping out the search box?, This is my script record, can you please modify this like I mean ? and explain it one by one (if you have a lot of time) otherwise I will try to understand it myself. Thanks...

 

-- Script generated by GameGuardian 8.68.0 (12536) at 2018-11-09 20:57:04 for Hill Climb Racing [com.fingersoft.hillclimb 1.38.1 (209)]
-- Lua help: http://gameguardian.net/help/

-- options
local scriptName = [=====[Script for Hill Climb Racing 1.38.1]=====]
local scriptVersion = '1.0.0'
local scriptAuthor = 'User'
local startToast = ''
-- 0 - no check; 1 - check package only, 2 - check package and build
local checkTarget = 0

local targetName = [=====[Hill Climb Racing]=====]
local targetPkg = 'com.fingersoft.hillclimb'
local targetVersion = [=====[1.38.1]=====]
local targetBuild = 209

-- functions

-- init
gg.require('8.68.0', 12536)

if startToast ~= '' then startToast = '\n'..startToast end
gg.toast(scriptName..' v'..scriptVersion..' by '..scriptAuthor..startToast)

if checkTarget ~= 0 then
    local info = gg.getTargetInfo()
    local check = false
    local current = false
    if checkTarget >= 1 then
        check = targetPkg
        current = info.packageName
    end
    if checkTarget >= 2 then
        check = check..' '..targetVersion..' ('..targetBuild..')'
        current = current..' '..info.versionName..' ('..info.versionCode..')'
    end
    if check ~= current then
        gg.alert('This script for "'..targetName..'" ['..check..'].\nYou select "'..info.label..'" ['..current..'].\nNow script exit.')
        os.exit()
    end
end
local revert = nil

-- main code
gg.searchNumber("2000~3000", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.processResume()
gg.searchNumber("3000~4000", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.processResume()

gg.clearList()

local t = gg.getResults(100, nil, nil, nil, nil, nil, nil, nil, nil)
gg.addListItems(t)
t = nil

gg.processResume()

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

U wrong write.. this gg.search("2000"~"3000")

 

U can use this. 

val = gg.prompt({'val1','val2', 'val3'},{[1] = 0,[2] = 0,[3] = 100},{"0","0","100"})
if val == nil then os.exit()
elseif val then 
gsearch = val[1]..'~'..val[2]
gg.searchNumber(gsearch, gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.searchNumber(val[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(100)
gg.editAll(val[3], gg.TYPE_DWORD)
end
gg.clearResults()
gg.processResume()
gg.toast('Hack Success By GoldenKaramel')

 

Link to comment
Share on other sites

5 hours ago, goldenkaramel said:

U wrong write.. this gg.search("2000"~"3000")

 

U can use this. 


val = gg.prompt({'val1','val2', 'val3'},{[1] = 0,[2] = 0,[3] = 100},{"0","0","100"})
if val == nil then os.exit()
elseif val then 
gsearch = val[1]..'~'..val[2]
gg.searchNumber(gsearch, gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.searchNumber(val[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(100)
gg.editAll(val[3], gg.TYPE_DWORD)
end
gg.clearResults()
gg.processResume()
gg.toast('Hack Success By GoldenKaramel')

 

Thanks, very helpfull... ?

Link to comment
Share on other sites

How about this?, it still provides error reporting when run.

Thanks also to BadCase, I learn and copy some line from his script

 

function home()
if searchingcoins == 'yes' then
    refinecoins()
else
    h = gg.choice({'Add Coins','Exit'},nil, 'Tom Gold Run')


    if h == nil then else
        if h == 1 then addcoins() end
        if h == 2 then os.exit() end
    end
    farm = -1
    

end

end


function addcoins()
gg.clearResults()
data = gg.prompt({[1] = 'Enter the number of coins you spent'}, {[1] = '0'})
gg.setRanges(gg.REGION_C_ALLOC)
gg.searchNumber(data[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.toast(gg.getResultCount())
searchingcoins = 'yes'
end
function refinecoins()
    data2 = gg.prompt({[2] = 'Enter the number of coins you spent'}, {[2] = '0'})
    gg.searchNumber(data2[2], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
    currentresults = gg.getResultCount()
    if currentresults <= 2 then
        coinsearchresults = gg.getResults(2)
            for i, v in ipairs(coinsearchresults) do
            end    -- (it gives different error if I don't use it)
else
                    h2 = gg.choice({'Add 1000 Gold','Add 2000 Gold'},nil, 'Tom Gold Run')
                    

    if h2 == nil then else
        if h2 == 1 then add1000() end
        if h2 == 2 then add2000() end
    end
    farm = -1
    
end

end
                function add1000()
                coinsearchresults.value = coinsearchresults.value + '1000'
                coinsearchresults.flags = gg.TYPE_DWORD
                end
                
                function add2000()
                coinsearchresults.value = coinsearchresults.value + '2000'
                coinsearchresults.flags = gg.TYPE_DWORD
                end
            
        gg.setValues(coinsearchresults)
        searchingcoins = 'no'
            farm = 1

        gg.alert('Success!!! Spend or earn some coins to see the change in your coin amount.')

    else

    gg.alert('Spend some more coins then click on the GameGuardian button and enter the amount you spent')
    farm = -1
    searchingcoins = 'yes'
    end
    
end

while true do
    if gg.isVisible(true) then
        farm = 1
        gg.setVisible(false)
    end
    if farm == 1 then home() end
end

 

Link to comment
Share on other sites

9 hours ago, AhmadAlkatiri said:

How about this?, it still provides error reporting when run.

Thanks also to BadCase, I learn and copy some line from his script 

 

function home()
if searchingcoins == 'yes' then
    refinecoins()
else
    h = gg.choice({'Add Coins','Exit'},nil, 'Tom Gold Run')


    if h == nil then else
        if h == 1 then addcoins() end
        if h == 2 then os.exit() end
    end
    farm = -1
    

end

end


function addcoins()
gg.clearResults()
data = gg.prompt({[1] = 'Enter the number of coins you spent'}, {[1] = '0'})
gg.setRanges(gg.REGION_C_ALLOC)
gg.searchNumber(data[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
gg.toast(gg.getResultCount())
searchingcoins = 'yes'
end
function refinecoins()
    data2 = gg.prompt({[2] = 'Enter the number of coins you spent'}, {[2] = '0'})
    gg.searchNumber(data2[2], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
    currentresults = gg.getResultCount()
    if currentresults <= 2 then
        coinsearchresults = gg.getResults(2)
            for i, v in ipairs(coinsearchresults) do
            end    -- (it gives different error if I don't use it)
else
                    h2 = gg.choice({'Add 1000 Gold','Add 2000 Gold'},nil, 'Tom Gold Run')
                    

    if h2 == nil then else
        if h2 == 1 then add1000() end
        if h2 == 2 then add2000() end
    end
    farm = -1
    
end

end
                function add1000()
                coinsearchresults.value = coinsearchresults.value + '1000'
                coinsearchresults.flags = gg.TYPE_DWORD
                end
                
                function add2000()
                coinsearchresults.value = coinsearchresults.value + '2000'
                coinsearchresults.flags = gg.TYPE_DWORD
                end
            
        gg.setValues(coinsearchresults)
        searchingcoins = 'no'
            farm = 1

        gg.alert('Success!!! Spend or earn some coins to see the change in your coin amount.')

    else

    gg.alert('Spend some more coins then click on the GameGuardian button and enter the amount you spent')
    farm = -1
    searchingcoins = 'yes'
    end
    
end

while true do
    if gg.isVisible(true) then
        farm = 1
        gg.setVisible(false)
    end
    if farm == 1 then home() end
end

 

 

Try this :

function home()
  if searchingcoins == 'yes' then
	refinecoins()
  else
	local h = gg.choice({'Add Coins','Exit'},nil, 'Tom Gold Run')
	if h == nil then
	else
	  if h == 1 then refinecoins() end
	  if h == 2 then os.exit() end
	end
	farm = -1
  end
end

function refinecoins()
  searchingcoins = 'yes'
  local data = gg.prompt({'Enter the number of coins you spent'}, {'0'}, {'number'})
  if not data then os.exit()
  elseif not tonumber(data[1]) then
	gg.alert('Wrong value')
  else
	gg.setRanges(gg.REGION_C_ALLOC)
	gg.searchNumber(data[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
	gg.toast(gg.getResultCount())
	if gg.getResultCount() > 2 or gg.getResultCount() == 0 then
	  gg.alert('Spend some more coins then click on the GameGuardian button and enter the amount you spent')
	else
	  searchingcoins = 'no'
	  addcoins()
	end
  end
  farm = -1
end

function addcoins()
  local add = gg.choice({'Add 1000 Gold','Add 2000 Gold'}, nil, 'Tom Gold Run')
  if not add then os.exit()
  else
	local coin = gg.getResults(2)[1]['value']
	if add == 1 then gg.editAll(coin + 1000, gg.TYPE_DWORD) end
	if add == 2 then gg.editAll(coin + 2000, gg.TYPE_DWORD) end
	gg.clearResults()
	gg.alert('Success!!! Spend or earn some coins to see the change in your coin amount.')
  end
  farm = -1
end

while true do
  if gg.isVisible(true) then
	farm = 1
    gg.setVisible(false)
  end
  if farm == 1 then home() end
end 

 

Link to comment
Share on other sites

3 hours ago, Revoxtical said:

 

Try this :


function home()
  if searchingcoins == 'yes' then
	refinecoins()
  else
	local h = gg.choice({'Add Coins','Exit'},nil, 'Tom Gold Run')
	if h == nil then
	else
	  if h == 1 then refinecoins() end
	  if h == 2 then os.exit() end
	end
	farm = -1
  end
end

function refinecoins()
  searchingcoins = 'yes'
  local data = gg.prompt({'Enter the number of coins you spent'}, {'0'}, {'number'})
  if not data then os.exit()
  elseif not tonumber(data[1]) then
	gg.alert('Wrong value')
  else
	gg.setRanges(gg.REGION_C_ALLOC)
	gg.searchNumber(data[1], gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
	gg.toast(gg.getResultCount())
	if gg.getResultCount() > 2 or gg.getResultCount() == 0 then
	  gg.alert('Spend some more coins then click on the GameGuardian button and enter the amount you spent')
	else
	  searchingcoins = 'no'
	  addcoins()
	end
  end
  farm = -1
end

function addcoins()
  local add = gg.choice({'Add 1000 Gold','Add 2000 Gold'}, nil, 'Tom Gold Run')
  if not add then os.exit()
  else
	local coin = gg.getResults(2)[1]['value']
	if add == 1 then gg.editAll(coin + 1000, gg.TYPE_DWORD) end
	if add == 2 then gg.editAll(coin + 2000, gg.TYPE_DWORD) end
	gg.clearResults()
	gg.alert('Success!!! Spend or earn some coins to see the change in your coin amount.')
  end
  farm = -1
end

while true do
  if gg.isVisible(true) then
	farm = 1
    gg.setVisible(false)
  end
  if farm == 1 then home() end
end 

 

edit :

thank you very much, missing apostrophe in edit value

 

function addcoins()
  local add = gg.choice({'Add 1000 Gold','Add 2000 Gold'}, nil, 'Tom Gold Run')
  if not add then os.exit()
  else
	local coin = gg.getResults(2)[1]['value']
	if add == 1 then gg.editAll(coin + '1000', gg.TYPE_DWORD) end
	if add == 2 then gg.editAll(coin + '2000', gg.TYPE_DWORD) end
	gg.clearResults()
	gg.alert('Success!!! Spend or earn some coins to see the change in your coin amount.')
  end
  farm = -1
end
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.