Jump to content
  • 0

Help,how can I make multiple on/off switches?


Ashleycolton

Question

on = 
off = ×
cstatus=off

function Main()

    SN =gg.choice({
       "筑基", --main 1
       "高阶", --main 2
       "内存防封/检测/举报", --main 3
       "特殊", --main 4 
       "所有功能菜单", --
       "加速速开", --main6
       "855上色区", --main7
       cstatus.. "超级上帝视角",
       "TEST FUNCTION", --main
       "车加速", --
       "超级圈圈自瞄",
       "退出脚本"
},nil,"🌴")
if SN == 1 then A1() end
if SN == 2 then A2() end
if SN == 3 then A3() end
if SN == 4 then miscellaneous() end
if SN == 5 then newmenu() end
if SN == 6 then KJS() end
if SN == 7 then ColorWheel() end
if SN == 8 then

if cstatus == on then --checks for status is on
cstatus = off
cgod2() --关
else
cstatus = on
cgod1()
end
end
if SN == 9 then Test() end
if SN == 10 then Sonicboom() end
if SN == 11 then Zm() end
if SN == 12 then leave() end
XGCK = -1
end

I used cstatus for on off switch. But it's not enough for multiple switches, as they dont share the same on off button.

How to make more switches with few global variable? 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

25 minutes ago, Ashleycolton said:

How to make more switches with few global variable?

Just like you did it with one global variable, but create as many global variables as switches you need. Or better create a table that will contain status values for all switches.

Link to comment
Share on other sites

     function a(data)
    gg.clearResults()
    text = {"Choice 1", "Choice 2"}
    if not data then
        texts = text
    else
        texts = data
    end
    b = gg.choice(texts, c, "😄")
    if b then
        b = { = true}
        if b[1] then
            gg.searchNumber(1)
            c = 1
            if not d then
                text[1] = text[1].." On"
                d = true
            else
                text[1] = text[1].." Off"
                d = false
            end
            return a(text)
        elseif b[2] then
            gg.searchNumber(2)
            c = 2
            if not d then
                text[2] = text[2].." On"
                d = true
            else
                text[2] = text[2].." Off"
                d = false
            end
            return a(text)
        end
    end
end
return a()

 

Link to comment
Share on other sites

on = '[✅]'
off = '[🚫]'

function a(data)
gg.clearResults()
local copycat =''
text = { "copycat 选项1", "无人机模式🚁"}
if not data then
        texts = text --table of choices
    else
        texts = data --off
 os.exit()
    end
b = gg.choice(texts, c, "😄") --set choices of table or data (b)
    if b then 
        b = {true}
        if b[1] then
            gg.searchNumber(1)
c = 1 --decides which button in the menu is clicked
            if not d then
copycat = on            
                text[1] = text[1]..copycat
                d = true
            else
copycat = off
                text[1] = text[1]..copycat
                d = false
            end
copycat =''
return a(text) --on off toggled, return to on/off choices
            
        elseif b[2] then

            c = 2
            gg.searchNumber(2)            
            if not d then --condition doesnt change text2 dont work
copycat = on
text[2] = text[2]..copycat
d = true
gg.setRanges(32)
gg.searchNumber("220;25;178", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
gg.searchNumber("220", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(10)
gg.editAll("9999", gg.TYPE_FLOAT)
gg.toast("Drone Activated")
else
copycat = off
text[2] = text[2]..copycat
d = false

gg.setRanges(32)
gg.searchNumber("9999;25;178", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
gg.searchNumber("9999", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1)
gg.getResults(10)
gg.editAll("220", gg.TYPE_FLOAT)
gg.toast("Drone Disabled")
gg.clearResults()
            end
copycat =''            
return a(text) --on off toggled, return to on/off choices            
        end
    end
end
return a()


	 



	 

 

Thanks for the inputs!

I used os.exit() to debug and the code seems problematic. Without citations this snippet is a brain wreckage with so many operators.

Why is button2 not triggered at all when you click on it? 

It exits everytime at os.exit()

Also i do not understand this line

b = { = true}

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.