Wrote some connections between the shock/alarm buttons and the terminal
This commit is contained in:
@@ -87,3 +87,6 @@ offset_bottom = 1542.0
|
|||||||
scale = Vector2(0.29, 0.29)
|
scale = Vector2(0.29, 0.29)
|
||||||
pivot_offset = Vector2(-39.952454, -39.952393)
|
pivot_offset = Vector2(-39.952454, -39.952393)
|
||||||
texture = ExtResource("4_afen0")
|
texture = ExtResource("4_afen0")
|
||||||
|
|
||||||
|
[connection signal="button_down" from="B_Shock" to="CommandPrompt" method="_button_shock"]
|
||||||
|
[connection signal="button_down" from="B_Alarm" to="CommandPrompt" method="_button_alarm"]
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ var commands_directory = DirAccess.open("res://Scripts/Gameplay/CommandLine/Comm
|
|||||||
var commands: Dictionary = {}
|
var commands: Dictionary = {}
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
load_commands()
|
_load_commands()
|
||||||
input_line.text_submitted.connect(self._on_command_entered)
|
input_line.text_submitted.connect(self._on_command_entered)
|
||||||
|
|
||||||
# To make a new command, write it in ./Commands with a main() function for entry.
|
# To make a new command, write it in ./Commands with a main() function for entry.
|
||||||
# This function will automatically find and register all command files
|
# This function will automatically find and register all command files
|
||||||
func load_commands():
|
func _load_commands():
|
||||||
if not commands_directory:
|
if not commands_directory:
|
||||||
push_error("Failed to open commands folder!")
|
push_error("Failed to open commands folder!")
|
||||||
return
|
return
|
||||||
@@ -37,7 +37,6 @@ func _on_command_entered(new_text: String) -> void:
|
|||||||
input_line.clear()
|
input_line.clear()
|
||||||
_print("> " + new_text)
|
_print("> " + new_text)
|
||||||
|
|
||||||
# Store command and ensure its not empty
|
|
||||||
var parts = new_text.strip_edges().split(" ")
|
var parts = new_text.strip_edges().split(" ")
|
||||||
if parts.size() == 0:
|
if parts.size() == 0:
|
||||||
return
|
return
|
||||||
@@ -47,12 +46,17 @@ func _on_command_entered(new_text: String) -> void:
|
|||||||
var args = parts.slice(1, parts.size())
|
var args = parts.slice(1, parts.size())
|
||||||
|
|
||||||
if commands.has(cmd):
|
if commands.has(cmd):
|
||||||
var cmd_script = commands[cmd].new() # Instantiate the script
|
var cmd_script = commands[cmd].new()
|
||||||
if cmd_script.has_method("main"):
|
if cmd_script.has_method("main"):
|
||||||
# Run script
|
|
||||||
cmd_script.main(args, self)
|
cmd_script.main(args, self)
|
||||||
else:
|
else:
|
||||||
_print("DEV ERROR !\nCommand '%s' has no main() function!" % cmd)
|
_print("DEV ERROR !\nCommand '%s' has no main() function!" % cmd)
|
||||||
else:
|
else:
|
||||||
_print("Unknown command: %s" % cmd)
|
_print("Unknown command: %s" % cmd)
|
||||||
input_line.text = "" # Clear input
|
input_line.clear()
|
||||||
|
|
||||||
|
func _button_shock():
|
||||||
|
_print("Shocked")
|
||||||
|
|
||||||
|
func _button_alarm():
|
||||||
|
_print("Alarm Triggered")
|
||||||
|
|||||||
@@ -3,11 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://cv2cadqcahubl"
|
uid="uid://cv2cadqcahubl"
|
||||||
valid=false
|
path="res://.godot/imported/map.png-9eea34967fae34f4388f4a32a16da936.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://map.png"
|
source_file="res://map.png"
|
||||||
|
dest_files=["res://.godot/imported/map.png-9eea34967fae34f4388f4a32a16da936.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user