summaryrefslogtreecommitdiff
path: root/godot/ui/HUD.gd
diff options
context:
space:
mode:
Diffstat (limited to 'godot/ui/HUD.gd')
-rw-r--r--godot/ui/HUD.gd35
1 files changed, 32 insertions, 3 deletions
diff --git a/godot/ui/HUD.gd b/godot/ui/HUD.gd
index 9bbcae1..cfef629 100644
--- a/godot/ui/HUD.gd
+++ b/godot/ui/HUD.gd
@@ -3,6 +3,7 @@ extends Control
var world
onready var character_list = $CharacterSelect/VBoxContainer
+onready var progress_bar: ProgressBar = $UseProgress
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -36,11 +37,31 @@ func _input(_event):
yield(get_tree(), "idle_frame")
$ChatPrompt.text = ""
-func send_chat_msg(txt):
+func send_chat_msg(txt: String):
world.is_chatting = false
- world.rpc_id(1, "_call_on_server", "_send_chat", {"id" : world.client_id, "msg" : txt})
$ChatPrompt.visible = false
$ChatPrompt.text = ""
+ if !txt.begins_with("/"):
+ world.rpc_id(1, "_call_on_server", "_send_chat", {"id" : world.client_id, "msg" : txt})
+ return
+ #command process
+ var end_ind = txt.find(" ")-1
+ if end_ind < -1: end_ind = -1
+ var cmd: String = txt.get_slice(" ", 0).substr(1).to_lower()
+ var args = txt.substr(end_ind+1, -1).split(" ", false)
+ match cmd:
+ "goto":
+ var pos: Vector3 = str2var("Vector3("+txt.get_slice(" ", 1)+")")
+ if world.player_char:
+ world.player_char.ai_set_path_target(pos)
+ "find":
+ var item: String = txt.get_slice(" ", 1)
+ if world.player_char:
+ CharacterAIManager.request_find_object(world.player_char, item, 50, true)
+ "setaistate":
+ world.rpc_id(1,"_call_on_server", "_set_ai_state", [args[0], args[1]])
+ for i in range(2,13):
+ world.rpc_id(1,"_call_on_server", "_set_ai_state", [args[0]+str(i), args[1]])
func ui_chat_msg(msg):
$HUDAnim.stop()
@@ -71,7 +92,7 @@ func update_characters():
for character in world.get_node("PLAYERS").get_children():
if world.player_team == character.team:
var select_button = Button.new()
- select_button.connect("pressed", world, "select_character", [character.name])
+ select_button.connect("pressed", world, "request_select_character", [character.name])
select_button.text = character.name + " (" + str(character.get_network_master()) + ")"
character_list.add_child(select_button)
@@ -83,3 +104,11 @@ func ui_join_red():
func ui_join_blue():
world.join_team("BLUE")
+
+func set_progress(delta: float)-> void:
+ progress_bar.visible = true
+ progress_bar.set_value(delta)
+
+func hide_progress() -> void:
+ progress_bar.set_value(0)
+ progress_bar.visible = false