Jump to content

ON/OFF button in one hack.


Platonic

Recommended Posts

hey guys I tried making a ON/OFF button in one...please take a look at the script...there is also a video part of it, how I made it and stuff like that but It seems the video is not that clear, that's why I give ya guys the file of that script in case you want to see how I made it or to improve it or stuff like that, please if you have improve the script, let me know I would like to see a better way. thanks guys

https://www.youtube.com/watch?v=5j2DQOoxhIc&t=90s

tutorial.lua

Link to comment
Share on other sites

  • 1 month later...

Nice one... But there is a easy way to do this and have the "ON" and "OFF" in the same button

-- testing

if gg.isVisible(true) then
  gg.setVisible(false)
end

status = 0
on = 'turn off'
off = 'turn on'

function menu()
  if status == 0 then
    gg.choice({off,'exit'},
    'Want to turn the option on?')
    if choice == 1 then
      status = 1
      menu()
    else
      os.exit()
    end
  else
    gg.choice({on,'exit'},
    'Want to turn the option off?')
    if choice == 1 then
      status = 0
      menu()
    else
      os.exit()
    end
  end
end

menu()

Ofc you don't need to make the vars

U can simple write it right after the gg.choice

gg.choice('turn on', 'exit')
--and then
gg.choice('turn off','exit')

 

Anyways, thx for helping the community!

Link to comment
Share on other sites

  • 2 weeks later...
On 8/3/2018 at 3:00 AM, RCPOLSKI said:

Nice one... But there is a easy way to do this and have the "ON" and "OFF" in the same button


-- testing

if gg.isVisible(true) then
  gg.setVisible(false)
end

status = 0
on = 'turn off'
off = 'turn on'

function menu()
  if status == 0 then
    gg.choice({off,'exit'},
    'Want to turn the option on?')
    if choice == 1 then
      status = 1
      menu()
    else
      os.exit()
    end
  else
    gg.choice({on,'exit'},
    'Want to turn the option off?')
    if choice == 1 then
      status = 0
      menu()
    else
      os.exit()
    end
  end
end

menu()

Ofc you don't need to make the vars

U can simple write it right after the gg.choice


gg.choice('turn on', 'exit')
--and then
gg.choice('turn off','exit')

 

Anyways, thx for helping the community!

Thx alot buddy ?

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 8/3/2018 at 3:00 AM, RCPOLSKI said:

Nice one... But there is a easy way to do this and have the "ON" and "OFF" in the same button


-- testing

if gg.isVisible(true) then
  gg.setVisible(false)
end

status = 0
on = 'turn off'
off = 'turn on'

function menu()
  if status == 0 then
    gg.choice({off,'exit'},
    'Want to turn the option on?')
    if choice == 1 then
      status = 1
      menu()
    else
      os.exit()
    end
  else
    gg.choice({on,'exit'},
    'Want to turn the option off?')
    if choice == 1 then
      status = 0
      menu()
    else
      os.exit()
    end
  end
end

menu()

Ofc you don't need to make the vars

U can simple write it right after the gg.choice


gg.choice('turn on', 'exit')
--and then
gg.choice('turn off','exit')

 

Anyways, thx for helping the community!

Im a Bit Comfused rn... where do i add the Functions. Can you show it with a gg.toast() ? Thank you

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.