Popuplib.Popup popup

From EventScripts Community Encyclopedia

Contents

Class: popuplib.Popup_popup

Note: Requires EventScripts 2.0
Module: popuplib
EventScripts version: 2.0

Overview

Description

A normal popup/menu to be displayed, where the contents are added line at a time. For constructing bigger menus, usage of popuplib.Popup_easymenu is recommended.

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

Quick Example

This example shows how to create a simple popup with multiple language support, send it later and delete it.

import es
import popuplib
 
myPopup = None
 
def load():
    global myPopup
    # Create a new Popup_popup object using the create method from popuplib:
    myPopup = popuplib.create('example_popup')
    
    # add some stuff to it in a few languages:
    myPopup.addline("Hello there!", 'en')
    myPopup.addline("Hallo!", 'de')
    myPopup.addline("Terve vaan!", 'fi')
    
    # another way to add multiple language content is using a dict-like object:
    text = {
        'en': 'This is a test',
        'de': 'Dies ist ein Test',
        'fi': 'Testataan vaan...',
    }
    myPopup.addline(text)
 
def player_jump(event_var):
    # Let's greet the jumping player with our popup
    myPopup.send(event_var['userid'])
 
def unload():
    # Script unloading, remove the popup from taking memory
    myPopup.delete()

Methods

delete ()
Deletes the popup from memory
send (users)
Sends the popup to selected user/users
timeout (mode, time)
Sets popup to time out after specified number of seconds
unsend (users)
Remove this popup from users' queue and display (similar to Popuplib.close method functionality)
update (users)
Refresh the popup on users' display if being showed
addline (text, language=None)
Adds a line of text to the popup (Note: can't be used after a non-addline call)
addlineAll (text)
Adds a line of text to all languages
delline (line, language=None)
Deletes specified line number from the popup
dellineAll
Deletes specified line number from all languages
information (listlevel)
Output information of the popup to server console
insline (line, text, language=None)
Inserts a line to be on numbered line, moving existing lines down to make space
inslineAll (line, text)
Inserts a line to all languages
menuvalue (variable, choice, value)
Sets a console variable to be set to specified value when the player chooses the specified menu item
modline (line, text, language=None)
Modifies an existing line replacing it with new text
modlineAll (line, text)
Modifies an existing line on all languages
recache (users=[])
Refreshes the popup display cache
select (choice, method)
Specifies a Python method or script block to be called when selecting specified menu item
submenu (choice, menuname)
Specifies another popup to be immediately displayed after choosing the specified menu item

Attributes

name = (as specified during creation)
The global name identifier of this popup
vguititle = name
The title shown in VGUI windows
prepuser = ""
The method or script block to be called just before the popup is displayed to a player
oldskooltov = False
Use EventScripts 1.2-1.3 compatible behavior on timeout (trigger menuselect 10)
displaymode = "normal"
How the popup handles unassigned choices
menuselect = ""
A function or script block to be called every time any input is given to the popup
menuselectfb = ""
A function or script block to be called when input is given and no other function (select or submenu) has been assigned for the chosen number
cachemode = "global"
The method how popup display cache is handled
editlang = "default"
The language used by addline, delline, modline and insline commands

Notes

  • When dealing with multiple languages in popups, the *All methods can be dangerous if the different language versions have different number of lines

See Also

blog comments powered by Disqus