English Menu Object v1.0 icon

3 comments
28.09.13 01:17:34 pm
like 2 like it!
3 kb, 81 Downloads
MikuAuahDark
User
Offline Off
Menu Object by MikuAuahDark

∗ Description ∗
This LUA allows you to make a menu easier and better(so you don't need to create if,elseif,if men==bla, etc. at menu hook)

∗ Features ∗
• Object-like sytem
• (maybe) good syntax
• No need a hook(this lua itself use hook) for menu handling.

∗ How to Install ∗
Note: it's not like another script, this script is special.
1. Extract menu.lua at sys/lua folder
2. Open server.lua and write this at end of file
Code:
1
Menu=dofile("sys/lua/menu.txt")

If you only use this code:
Code:
1
dofile("sys/lua/menu.txt")

You may gonna getting "attempt to call a nil value" errors(at hooks) and "attempt to index field 'Menu' (a nil value)" errors
3. Save

∗ Reserved Global Variables ∗
> New*
> Menu**
* - This variable doesn't re-created if it's already exist
** - It can to be a name that you like, where Menu=dofile("sys/lua/menu.txt") holds all the table

∗ Information ∗
> Hooks: 1(cs2d lua hook menu)
> Size: 1384 Bytes(*_desc.lua 3248 Bytes)

∗ Example ∗
> Example Code(Shows a example menu at player with ID 1)
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
Menu=dofile("menu.lua")

MenuHandle=Menu.New("This is a menu",{
     {"Selection 1",function(id,men,sel)
          msg2(id,"You press selection 1 at \""..men.."\"")
     end},
     [0]={"",function(id,men,sel)
          msg2(id,"You cancel the menu selection!")
     end}
     }
)
msg("Menu handle is "..tostring(MenuHandle).."(ID "..#MenuHandle.." Title "..(-MenuHandle)..")")
MenuHandle:Show(1)

> Selection manipulation
Code:
1
2
3
4
5
6
7
8
Handle=Menu.New("Menu Title",{
     {"Selectiin 1",function(id,men,sel) end},
})
local function temp(id,men,sel)
     print("OK")
end
Handle:SetSel(1,"Selection 1",temp)
Handle:Show(1)


∗ Functions ∗
>> Used variable name is Handle <
> Menu.New(title{striing},selection{table})
• > Creates a new Menu Handle
• Parameters:
• >> title - The menu title
• >> selection - The selection table. Format is {[selection_id]={"Selection Name",selection_function},...}(Separated by comma)
• ∗ Returns: The menu handle{table}(modified)
• Example:
Code:
1
Handle=Menu.New("Menu Title",{[selection_id]={"Selection Name",selection_function}})

> Handle:Show(id{number})
• > Show the menu
• Parameters:
• >> id - The player that want you to show the menu(or 0 for all players)
• ∗ Returns: None
• Example:
Code:
1
Handle:Show(5) -- Show menu for ID 5

> Handle:SetTitle(title{string})
• > Set the menu title(same as Handle.title="The title")
• Parameters:
• >> title - The new title
• ∗ Returns: None
• Example:
Code:
1
Handle:SetTitle("Menu Title")

> Handle:SetSel(selection_number{number},selection_name{string},selection_function{function})
• > Change the selection informaton at specific number
• Parameters:
• >> selection_number - The selection number(0-9)
• >> selection_name - The selection name, put empty string for selection 0(or put nil if you don't want to change this information)
• >> selection_function - The function to be executed when the selection is pressed(or put nil if you don't want to change this information)
• ∗ Returns: None
• Example:
Code:
1
Handle:SetSel(1,"Selection Name",selection_function)


∗ Notes ∗
1. Feedbacks? suggestions? bugs? always on comments
2. I'm currently cannot find good name for this script

∗ Rules ∗
√ You can use it for your server
√ You can edit it
√ You can upload at another website, say MikuAuahDark or user MikuAuahDark made t
× You can't say this is yours
× You can't upload on another website without put me on credits

∗ Version History ∗
>> v1.0
>> • ADDED Initial Release
edited 2×, last 29.09.13 03:43:52 am
ok This file has been reviewed and approved by Seekay (04.12.15 01:08:35 pm)

Comments

3 comments
Goto Page
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in
05.01.14 06:58:02 pm
like I like it!
Up
Avo
User
Offline Off
Handlers, how I like them.
28.09.13 08:02:52 pm
Up
H-X
User
Offline Off
looks nice.
But i will rate after testing :D!
28.09.13 02:47:12 pm
like I like it!
Up
Sebax
User
Offline Off
Nice work!
To the start Previous 1 Next To the start