Forum

> > CS2D > Scripts > Loop for menu button
Forums overviewCS2D overview Scripts overviewLog in to reply

English Loop for menu button

4 replies
To the start Previous 1 Next To the start

old Loop for menu button

limonata
User Off Offline

Quote
Hi all there is problem i need help.
I want to write a message for all menu buttons.
So, for example my message is "Test" and when i pressed button1 or button2 or button3... message will appear. But i dont want to write this code (msg("Test")) for 10-20 times.. I want to write this code just for one not for all button controls.
So how i can make it ?

old Re: Loop for menu button

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("menu","potato")
function potato(id,t,b)
	if t == "apple" then
		msg2(id,"Test "..b)
	end
end

addhook("serveraction","cucumber")
function cucumber(id,b)
	local stringA = "apple,"
	for a = 1,8 do
		stringA = stringA.."Test"..a..","
	end
	stringA = stringA.."Next Page"
	menu(id,stringA)
end

Dunno which one you meant, when any button pressed or to quickly make buttons. Anyways, not checked, might work might not.
edited 1×, last 09.08.14 12:38:38 am

old Re: Loop for menu button

Bounty Hunter
BANNED Off Offline

Quote
user limonata has written
I want to write this code just for one not for all button controls.

Or I'm fu*ked up, or the sentence contradicts the previous one.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
message = 'lol'

addhook('serveraction','sa')
function sa(id,key)
	menu(id,'My menu,button 1,button 2,button 3')
end

addhook('menu','mn')
function mn(id,t,b)
	if t == 'My menu' then
		-- for 3 buttons
		if b >= 1 and b <= 3 then
			msg2(id,message)
		end
	end
end

old Re: Loop for menu button

Bounty Hunter
BANNED Off Offline

Quote
No problem. If you will have any question for Lua do NOT ask me by PM, but create a new thread and I will answer there if you tell me about the thread.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview