Jump to content

if statment


Recommended Posts

small question here.  its a bit weird tough. I'm working on making my script better and stuff.

I have in this script a if statement and I want it to go to "zabissk()" when the result is something else then "3". sbut when I run the script and the results are not 3, then it will go to "zabissk", but afther "zabissk" is done, it will go back to the if statement and will run the rest of that script... this is  the first time I got this.

function mik()

gg.clearResults()
gg.searchNumber('450.0;1.04719758034;-300.0', gg.TYPE_FLOAT)
if gg.getResultCount() ~= 3 then zabissk() end
t = gg.getResults(3) --load items))
t[1].value = '50'
t[1].freeze = true
t[1].freezeType = gg.FREEZE_NORMAL
print('addListItems: ', gg.addListItems(t))
gg.clearResults()
gg.setRanges(gg.REGION_CODE_APP)
gg.searchNumber('1.294621e-38F;0.10000000149F',  gg.TYPE_FLOAT)
r = gg.getResults(2)
r[2].value = '-0.7'
gg.setValues(r)
gg.toast('You Tube = Dragon Star')

end

 

function zabissk()
 
gg.clearResults()
gg.setRanges(gg.REGION_CODE_APP)
gg.searchNumber('1.294621e-38F;0.10000000149F',  gg.TYPE_FLOAT)
r = gg.getResults(2)
r[2].value = '-0.7'
gg.setValues(r)
gg.clearResults()
gg.toast('You Tube = Dragon Star')

end



the point of my script is to learn more out others there pro made scripts and my experience and make it betters  for the users to have a more enjoyable experience. thanks for reply.
Link to comment
Share on other sites

  • Administrators

Function call is not a go to.

If you do not run other part code you must use else block of the if.

And use indentation will be good for easy read code.

if gg.getResultCount() ~= 3 then 
  zabissk()
else
  -- other code
end

 

Link to comment
Share on other sites

Another option for your case is to use "return" statement in "if" block, so that remaining part of the function won't be executed when the condition is met.

if gg.getResultCount() ~= 3 then 
  zabissk()
  return
end

-- Remaining part of the function

 

Link to comment
Share on other sites

I see, and what if I'm using a go to?


if gg.getResultCount() ~= 3 then 
   goto zabissk else return
end



this can work to? (not that I need it, I`m using functions now)                           

Link to comment
Share on other sites

yes, they told me that go to is only good or like more used for assamble scripts or stuff like that.

anyway good I know. I changed my hole ros script to functions()  :), there is maby 1 ;ast question, I hope it not bothers.

But I'm` learned how to let my script appear automaticly when opening gameguardian.

Just tapping the icon and script automaticly appear.

but when you press the GG icon, the script will appear on the main menu of the script, and that's perhaps a bit annoying for users. I want to make the menu appear were they last tapped.

like the user will  tab on "mainmenu=>jumphack=>high jumphack=>activate/deactivate" and then GG will hide the script and when they open it again GG will start at the main menu of the script again
                                                                     

I want to make it that it will appear back on the "high jumpack"  and not back to the mainmenu...I have been struggeling with this for a 12 hours I think. you know what I mean?

Link to comment
Share on other sites

  • Administrators

There can be many solutions. starting from the bad option - use in each submenu of its cycle, ending with the normal option - using one cycle and storing the current state, and on it already open the desired menu.
These are already nontrivial things, which strongly depend on the overall structure of the code, your knowledge and skills.

Link to comment
Share on other sites

alright, thank you guys for the info, I found everything I need, I only need to relook that part what ENBY said, I think I kind of get what you mean tough but still need to test out.
solution for my if statement is like this  :):
 

function _____________________________()
 
gg.clearResults()
gg.searchNumber('450.0;1.04719758034;-300.0', gg.TYPE_FLOAT)
if gg.getResultCount() ~= 3 then zabissk() else
gg.searchNumber('450.0;1.04719758034;-300.0', gg.TYPE_FLOAT)
t = gg.getResults(3)
t[1].value = '50'
t[1].freeze = true
t[1].freezeType = gg.FREEZE_NORMAL
print('addListItems: ', gg.addListItems(t))
gg.clearResults()
gg.setRanges(gg.REGION_CODE_APP)
gg.searchNumber('1.294621e-38F;0.10000000149F',  gg.TYPE_FLOAT)
r = gg.getResults(2)
r[2].value = '-0.7'
gg.setValues(r)
end
end


 
function zabissk()
 
gg.setRanges(gg.REGION_CODE_APP)
gg.searchNumber('1.294621e-38F;0.10000000149F',  gg.TYPE_FLOAT)
r = gg.getResults(2)
r[2].value = '-0.7'
gg.setValues(r)
gg.clearResults()
gg.toast('You Tube = Dragon Star')
end
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.