|
Module: settinglib
Module Overview
EventScripts version: 2.0 or greater
Table of Contents
Description
Creates an easymenu setting menu that allows easy user based setting creation and handling.
Quick Example
Creating a simple user setting:
# Create a new toggle settings menu
mySetting = settinglib.create('example_setting', 'Example Settings', 'toggle')
# Set question and add some options
mySetting.addoption('message', 'Welcome Message')
mySetting.addoption('sound', 'Welcome Sound')
mySetting.setdefault('message', 1) # enable the toggle by default
mySetting.setdefault('sound', 1) # enable the toggle by default
mySetting.addsound('ui/buttonclick.wav')
Module Content
Classes
Methods
- settinglib.create(settingname, menu-title, menu-type)
- Creates a new setting object with the specified name and returns a reference to the newly created setting class object of type settinglib.Setting_list or settinglib.Setting_toggle.
- The setting can be later referred to by the name given here by other functions shown here or with the setting console command.
- Parameters:
- settingname -- the global setting name that identifies this setting
- menu-title -- menu title that is used in all popups
- menu-type -- the settings type, either 'list' or 'toggle'
- Example:
# Create a new toggle settings menu
mySetting = settinglib.create('example_setting', 'Example Settings', 'list')
- settinglib.free(settingname)
- Frees a setting with the given name if it exists. This function does also remove the settings data file.
You should use settinglib.delete if you want to keep the settings.
- Raises ValueError if the setting does not exist
- Example:
try:
settinglib.free('example_setting')
except ValueError:
es.dbgmsg(0, 'example_setting did not exist...')
- settinglib.delete(settingname)
- Deletes a setting with the given name if it exists.
- Raises ValueError if the setting does not exist
- Example:
try:
settinglib.delete('example_setting')
except ValueError:
es.dbgmsg(0, 'example_setting did not exist...')
- settinglib.exists(settingname)
- Returns True or False depending on if the named setting exists
- Example:
if settinglib.exists('example_setting'):
settinglib.delete('example_setting')
- settinglib.find(settingname)
- Find the named setting object and returns the class object reference. If the named setting was not found, None is returned.
- Example:
mySetting = settinglib.find('example_setting')
if mySetting:
mySetting.send(myUserid)
- settinglib.send(settingname, users, prio = False)
- Sends the specified setting menu to selected users. As with most other functions, users can be either a single userid or a list of users.
- If the named setting is not found, this function raises ValueError
- prio is an optional parameter that allows you to send the setting to the top of the users popup queue.
- Example:
settinglib.send('example_setting', es.getUseridList())
- settinglib.sendGlobal(settingname, users, prio = False)
- Sends the specified setting menu to selected users. As with most other functions, users can be either a single userid or a list of users.
This function does send the global option based setting menu to the users, not their own setting menu. This is useful for shared options through all users, e.g. admin options.
- If the named setting is not found, this function raises ValueError
- prio is an optional parameter that allows you to send the setting to the top of the users popup queue.
- Example:
settinglib.sendGlobal('example_setting', es.getUseridList())
See Also
|
|