Keymenulib.Keymenu keymenu

From EventScripts Community Encyclopedia

Contents

Class: Keymenulib.Keymenu_keymenu

Note: Requires EventScripts 2.0
Module: keymenulib
EventScripts version: 2.0

Overview

Description

A normal keymenu to be displayed, where the contents are added from a keygroup or KeyValues object. For constructing item based menus in Python, usage of popuplib.Popup_easymenu is recommended.

You should not create instances of this class directly, instead use keymenulib.create method which will correctly bind the keymenu object.

Quick Example

This example shows how to create a simple keymenu, send it later and delete it.

import es
import keymenulib
 
myKeymenu = None
 
def load():
    global myKeymenu
    # Create a keygroup that holds some player information
    es.server.cmd("es_xcreateplayerlist playerlist")
 
    # Create a new Keymenu_keymenu object using the create method from keymenulib:
    myKeymenu = keymenulib.create('example_keymenu', '_temp', submit, 'playerlist', '#keyvalue name', '#key', 'Playerlist\nSelect a player')
 
def player_jump(event_var):
    # Let's greet the jumping player with our keymenu
    myKeymenu.send(event_var['userid'])
 
def submit(userid, choice, keymenuname):
    es.tell(userid, "You selected item "+choice+" from "+keymenuname)
 
def unload():
    # Script unloading, remove the keymenu from taking memory
    myKeymenu.delete()

Methods

delete ()
Deletes the keymenu from memory
send (users, page = 0)
Sends the keymenu to selected user/users
unsend (users, page = 0)
Remove this keymenu from users' queue and display
update (keygroup = None)
Refresh the keymenu from a new keygroup or if no new keygroup is given, from the old one that still has to exists
getpages ()
Returns the number of pages in a keymenu
changeblock (function)
Allows you to re-define the menuselect block or function
backmenu (backmenu)
Allows you to define a menu (popuplib, keymenulib or settinglib) that will be shown on close
information (listlevel)
Output information of the keymenu to server console

See Also

blog comments powered by Disqus