Forum

> > CS2D > Scripts > Menu button 2
Forums overviewCS2D overview Scripts overviewLog in to reply

English Menu button 2

2 replies
To the start Previous 1 Next To the start

old Re: Menu button 2

Bowlinghead
User Off Offline

Quote
Do it like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
isEnabled = true

function menu1(id)
	menu(id,"Blablabla, Setting 1| "..isEnabled..",hi") -- your menu what so ever (doesnt have to be a function but i recommend it
end

addhook("menu","menuh")
function menuh(id,t,b)
	if (t=="Blablabla") then
		if (b==1) then -- user want to change setting 1
			if (isEnabled) then  -- toggle variable of that setting
				isEnabled = false 
				-- todo: what to do if deactivated
				parse("kill "..id)
			else
				 isEnabled = true
				-- todo: what to do if activated 
			end 
			menu1(id) -- REOPEN menu, thats the effect of the "non closing menu"
		elseif (b==2) then
			msg("hi :3")
		end
	end
end

The menu closes itself automaticly after pressing a button. You just reopen it to maintain it open.

Of course you need a seperate variable for each setting you want to change
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview