OOP Menu 
3 comments hi, I share my implementation of my "OOP" menu, that I've made for
the pcs mixmatch script. http://github.com/edwinmrtn/pcs_mixmatch
there is an automatic pagination system when more than 6 buttons are added to a menu.
Each button will execute a function and/or a method on press
MenuList(int id)
Menu(int id,string title)
Button(int Id,String Nom,String Value,String Fonction,Object Object,String FoncObject,String ParamOb)
let's have a class cat like that :
A Random function :
A main code :
Results on screens below
Server.lua :
Licences :
the pcs mixmatch script. http://github.com/edwinmrtn/pcs_mixmatch
there is an automatic pagination system when more than 6 buttons are added to a menu.
Each button will execute a function and/or a method on press
MenuList(int id)
Menu(int id,string title)
Button(int Id,String Nom,String Value,String Fonction,Object Object,String FoncObject,String ParamOb)
let's have a class cat like that :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Cat = newclass("Cat")
--Constructor
function Cat:init(Id)
self.Id = Id
end
--methods
function Cat:getId()
return self.Id
end
function Cat:speak(param)
msg("miewwww")
msg(param)
end
--Constructor
function Cat:init(Id)
self.Id = Id
end
--methods
function Cat:getId()
return self.Id
end
function Cat:speak(param)
msg("miewwww")
msg(param)
end
A Random function :
Code:
1
2
3
2
3
function hello()
msg("hello Basic function")
end
msg("hello Basic function")
end
A main code :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
--new menuList - only use this instance for all menu
theMenuList = MenuList(0);
--new menu
local amenu = Menu(1,"Title")
theMenuList:addMenu(amenu);
--new cat
local aCat = Cat(1)
--new Bouton
local abutton = button(1,"name","value","hello",aCat,":speak","randomString")
amenu:addButton(abutton)
amenu:Show(id)
theMenuList = MenuList(0);
--new menu
local amenu = Menu(1,"Title")
theMenuList:addMenu(amenu);
--new cat
local aCat = Cat(1)
--new Bouton
local abutton = button(1,"name","value","hello",aCat,":speak","randomString")
amenu:addButton(abutton)
amenu:Show(id)
Results on screens below
Server.lua :
Licences :
edited 2×, last 07.11.15 06:02:26 pm

Comments
3 comments



Log in!
You need to log in to be able to write comments!Log in



