English Loop for menu button

4 replies
Goto Page
To the start Previous 1 Next To the start
08.08.14 11:29:24 pm
Up
limonata
User
Offline Off
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 ?
08.08.14 11:47:20 pm
Up
Rainoth
Moderator
Offline Off
Code:
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
08.08.14 11:52:35 pm
Up
Bounty Hunter
BANNED
Offline Off
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.
Code:
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
08.08.14 11:56:25 pm
Up
limonata
User
Offline Off
Edit: thanks @user Bounty Hunter: problem solved.
Also thank you @user Rainoth:
09.08.14 12:06:41 am
Up
Bounty Hunter
BANNED
Offline Off
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