-
Notifications
You must be signed in to change notification settings - Fork 6
Functions
cobrapitz edited this page Oct 28, 2019
·
22 revisions
const ConsoleRights = preload("res://console/console_rights.gd")
# @param 1: reference to the 'function' owner
# @param 2: function name (reference)
# @param 3: what kind of reference
# @param 4: arguments amount
# -> (either single decimal/String(word)/float, Array or VARIANT([1, 2], would mean 1 or 2 arguments have to be passed on)
# When CommandRef.VARIANT is used, the argument will be passed by Array
# That means your Refered func
CommandRef.new(obj, ref : String, type, argsExpected)
#var printRef = CommandRef.new(self, "my_print", CommandRef.VARIANT)# @param 1: Command name
# @param 2: Reference to the CommandRef.new(...)
# @param 3: Description (shown e.g. when /man <command> is used)
# @param 4: Default arguments (used if no args used
# @param 5: Needed user priviliges to call this command
var command = Command.new(name : String, cmdRef, args : Array, description : String, callRights)
# example (setThemeRef is from type: CommandRef)
ConsoleCommand.new('setUserName', setThemeRef, 'Sets the theme.', [], ConsoleRights.CallRights.USER)# called with
ConsoleFlags.Type.INDENT # example
class_name ConsoleFlags
enum Type {
NONE = 0,
USER_PREFIX = 1,
CLICKABLE = 2048,
NO_DRAW = 4, # won't be drawn on console text
BOLD = 8,
ITALICS = 16,
UNDERLINE = 32,
CODE = 64,
CENTER = 128,
RIGHT = 256,
FILL = 512,
INDENT = 1024,
URL = 2048,
NO_COMMANDS = 4096,
TRACK_MESSAGE = 8192, # append to the message stack that can be scrolled through with ui_up/ui_down
SHOW_TIME = 16384,
}Adds a command.
# @param 1: command
add_command(command : ConsoleCommand)
# example:
var manRef = CommandRef.new(self, "man", 1) # requires 1 argument,
var manCommand = ConsoleCommand.new('man', manRef, 'shows command description.')
console.add_command(manCommand)Call / user rights
# You can get the value by
ConsoleUserRight.Type.USER or DEV or ...
class_name ConsoleUserRight
# The higher the number, the higher the privilegs
enum Type{
NONE = 0, # no (default) commands
USER = 1, # default command-call-right if not otherwise specified
TESTER = 2,
MODERATOR = 4,
ADMIN = 8,
DEV = 16,
}
Writes text.
# @param 1: message
# @param 2: flags (default: NONE)
write(message : String, flags=ConsoleFlags.Type.NONE)Writes text and appends a newline.
# @param 1: message
# @param 2: flags (default: NONE)
write_line(message : String, flags=ConsoleFlags.Type.NONE)Writes text to the sepcified channel.
# @param 1: channelName
# @param 2: message
# @param 3: flags (default: NONE)
write_channel(channelName : String, message : String, flags=ConsoleFlags.Type.NONE)Raw text and no commands will be executed.
# @param 1: channelName
# @param 2: message
# @param 3: flags (default: NONE)
write_line_channel(channelName : String, message : String, flags=ConsoleFlags.Type.NONE)Calls: -> e.g. write_line("[color=yellow]%s[/color]" % your_message, flags = 0)
# no need to specify if you want the message to show in the all channel
console.warn("This is a warning in yellow", channelName="All")
console.error("This is a error message in red", channelName="All")
console.success("This is a succes message in green", channelName="All")
# additional: [WARNING], [ERROR] or [SUCCESS] will be appended in log fileRaw text and no commands will be executed.
# @param 1: channelName
get_channel(channelName : String)Returns all channels.
get_channels()Adds a channel.
# @param 1: channelName
add_channel(channelName : String)Removes channel by name.
# @param 1: channelName
remove_channel(channelName : String)