Jump to content

How to Create On/Off Button With Saved List


star360
 Share

Recommended Posts

Create on/off button in lua script

 No need to searching values for every time

 Simple script but better ideas

Read this simple script carefully

You will be understand 

 

 Specially thanks to @MuhammadRizwan87

Credit @TDOhex

 

function search()
  gg.clearResults()
  gg.setRanges(gg.REGION_C_DATA)
  gg.searchNumber("1;2;3", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
  gg.refineNumber("1", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
  local t = gg.getResults(3)
  for i, v in ipairs(t) do
    t[i].name = 'testoff'
  end
  gg.addListItems(t)
  gg.clearResults(t)
end
search()

 

on = "[OFF]"
off = "[ON]"
test = off

 

function main()
  menu = gg.choice({
    test.."  Test",
    "Exit"}, nil, "Example by @TDOhex")

 

  if menu == 1 then
    if test == off then
      test = on
      local t = gg.getListItems(testoff)
      for i, v in ipairs(t) do
        if v.name == "testoff" then
          t[i].value = 0
          t[i].name = 'teston'
        end
        gg.setValues(t)
        gg.addListItems(t)
      end
    else
      test = off
      local t = gg.getListItems(teston)
      for i, v in ipairs(t) do
        if v.name == "teston" then
          t[i].value = 1
          t[i].name = 'testoff'
        end
        gg.setValues(t)
        gg.addListItems(t)
      end
    end

 

  elseif menu == 2 then
    print("Thanks to visiting @TDOhex")
    gg.copyText('https://t.me/TDOhex')
    intro = "Join to @TDOhex"
    for i = 1, #intro do
      gg.toast(intro:sub(1, i) .. "_✍")
      gg.sleep(140)
    end
    local t = gg.getListItems()
    gg.removeListItems(t)
    os.exit()
  end
end

 

while true do
  if gg.isVisible() then
    gg.setVisible(false)
    main()
  end
end

 

I just shared it... 

On-Off_Example.lua

Link to comment
Share on other sites

  • 9 months later...
On 7/3/2020 at 3:32 AM, star360 said:

Create on/off button in lua script

 No need to searching values for every time

 Simple script but better ideas

Read this simple script carefully

You will be understand 

 

 Specially thanks to @MuhammadRizwan87

Credit @TDOhex

 


function search()
  gg.clearResults()
  gg.setRanges(gg.REGION_C_DATA)
  gg.searchNumber("1;2;3", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
  gg.refineNumber("1", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
  local t = gg.getResults(3)
  for i, v in ipairs(t) do
    t[i].name = 'testoff'
  end
  gg.addListItems(t)
  gg.clearResults(t)
end
search()

 


on = "[OFF]"
off = "[ON]"
test = off

 


function main()
  menu = gg.choice({
    test.."  Test",
    "Exit"}, nil, "Example by @TDOhex")

 


  if menu == 1 then
    if test == off then
      test = on
      local t = gg.getListItems(testoff)
      for i, v in ipairs(t) do
        if v.name == "testoff" then
          t[i].value = 0
          t[i].name = 'teston'
        end
        gg.setValues(t)
        gg.addListItems(t)
      end
    else
      test = off
      local t = gg.getListItems(teston)
      for i, v in ipairs(t) do
        if v.name == "teston" then
          t[i].value = 1
          t[i].name = 'testoff'
        end
        gg.setValues(t)
        gg.addListItems(t)
      end
    end

 


  elseif menu == 2 then
    print("Thanks to visiting @TDOhex")
    gg.copyText('https://t.me/TDOhex')
    intro = "Join to @TDOhex"
    for i = 1, #intro do
      gg.toast(intro:sub(1, i) .. "_✍")
      gg.sleep(140)
    end
    local t = gg.getListItems()
    gg.removeListItems(t)
    os.exit()
  end
end

 


while true do
  if gg.isVisible() then
    gg.setVisible(false)
    main()
  end
end

 

I just shared it... 

On-Off_Example.lua 1.64 kB · 32 downloads

Made by RCPolski

Link to comment
Share on other sites

On 7/3/2020 at 3:32 AM, star360 said:

Create on/off button in lua script

 No need to searching values for every time

 Simple script but better ideas

Read this simple script carefully

You will be understand 

 

 Specially thanks to @MuhammadRizwan87

Credit @TDOhex

 


function search()
  gg.clearResults()
  gg.setRanges(gg.REGION_C_DATA)
  gg.searchNumber("1;2;3", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
  gg.refineNumber("1", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
  local t = gg.getResults(3)
  for i, v in ipairs(t) do
    t[i].name = 'testoff'
  end
  gg.addListItems(t)
  gg.clearResults(t)
end
search()

 


on = "[OFF]"
off = "[ON]"
test = off

 


function main()
  menu = gg.choice({
    test.."  Test",
    "Exit"}, nil, "Example by @TDOhex")

 


  if menu == 1 then
    if test == off then
      test = on
      local t = gg.getListItems(testoff)
      for i, v in ipairs(t) do
        if v.name == "testoff" then
          t[i].value = 0
          t[i].name = 'teston'
        end
        gg.setValues(t)
        gg.addListItems(t)
      end
    else
      test = off
      local t = gg.getListItems(teston)
      for i, v in ipairs(t) do
        if v.name == "teston" then
          t[i].value = 1
          t[i].name = 'testoff'
        end
        gg.setValues(t)
        gg.addListItems(t)
      end
    end

 


  elseif menu == 2 then
    print("Thanks to visiting @TDOhex")
    gg.copyText('https://t.me/TDOhex')
    intro = "Join to @TDOhex"
    for i = 1, #intro do
      gg.toast(intro:sub(1, i) .. "_✍")
      gg.sleep(140)
    end
    local t = gg.getListItems()
    gg.removeListItems(t)
    os.exit()
  end
end

 


while true do
  if gg.isVisible() then
    gg.setVisible(false)
    main()
  end
end

 

I just shared it... 

On-Off_Example.lua 1.64 kB · 33 downloads

Jus store the value in a table you dont need to save em in a list

Link to comment
Share on other sites

 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.