Files

> > CS2D > Lua Scripts > Menu Object v1.0
Files overviewCS2D overviewLua Scripts overview

English Menu Object v1.0 >

3 comments3 kb, 433 Downloads

old Menu Object v1.0

MikuAuahDark
User Off Offline

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
1
Menu=dofile("sys/lua/menu.txt")
If you only use this 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)
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
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:
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:
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:
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:
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
Approved by Seekay

Download Download

3 kb, 433 Downloads

Comments

3 comments
To the start Previous 1 Next To the start

Log in!

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

old

Avo
User Off Offline

Handlers, how I like them.
I like it!

old

H-X
User Off Offline

looks nice.
But i will rate after testing :D!

old

Sebax
User Off Offline

Nice work!
I like it!
To the start Previous 1 Next To the start