-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBaseCommands.gd
75 lines (57 loc) · 1.91 KB
/
BaseCommands.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
extends Reference
func _init():
Console.register('echo', {
'description': 'Prints a string in console',
'args': [TYPE_STRING],
'target': [Console, 'writeLine']
})
Console.register('history', {
'description': 'Print all previous commands used during the session',
'target': [Console._History, 'printAll']
})
Console.register('commands', {
'description': 'Lists all available commands',
'target': [Console._Commands, 'printAll']
})
Console.register('help', {
'description': 'Outputs usage instructions',
'args': [TYPE_STRING],
'target': self
})
Console.register('quit', {
'description': 'Exit application',
'target': self
})
Console.register('clear', {
'description': 'Clear the terminal',
'target': Console
})
Console.register('version', {
'description': 'Shows engine version',
'target': self
})
Console.register('fps_max', {
'args': [Console.IntRange.new(10, 1000)],
'description': 'The maximal framerate at which the application can run',
'target': [Engine, 'set_target_fps'],
})
# @param string|null command
static func help(command = null):
if command:
var Command = Console._Commands.get(command)
if !Command:
Console.Log.warn('No such command')
return
Command.describe()
else:
Console.writeLine(\
"Type [color=#ffff66][url=help]help[/url] <command-name>[/color] show information about command.\n" + \
"Type [color=#ffff66][url=commands]commands[/url][/color] to get a list of all commands.\n" + \
"Type [color=#ffff66][url=quit]quit[/url][/color] to exit the application.")
static func version(): # void
Console.writeLine(Engine.get_version_info())
# This function is called from scripts/console_commands.gd to avoid the
# "Cannot access self without instance." error
static func quit(): # void
Console.Log.warn('Quitting application...')
Console.get_tree().quit()