pedestals working
This commit is contained in:
parent
813feb9fef
commit
4a564dc3f5
6 changed files with 109 additions and 9 deletions
|
|
@ -6,15 +6,14 @@ signal broadcast(command : String)
|
|||
@export_group("Variables")
|
||||
@export var level_tick : float = 1 # how often to run a command
|
||||
@export var level_time : float = 10 # the amoutn of time allowed for the level
|
||||
@export var commands : Array[String]
|
||||
|
||||
|
||||
@export_group("Node References")
|
||||
@export var gui : Control
|
||||
@export var pedestals : Array[Pedestal]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
while(commands.size() < level_time / level_tick): # prevent index out of bounds error
|
||||
commands.append("")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
|
|
@ -22,8 +21,7 @@ func _ready():
|
|||
func _process(delta):
|
||||
pass
|
||||
|
||||
func set_command(position : int, command : String):
|
||||
commands[position] = command
|
||||
|
||||
|
||||
func start_room():
|
||||
# open door
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ func _physics_process(delta):
|
|||
if Input.is_action_just_pressed("interact"):
|
||||
if "name" in raycast.get_collider():
|
||||
if "command_name" in raycast.get_collider():
|
||||
# clicked a command block
|
||||
print(raycast.get_collider().command_name)
|
||||
|
||||
#hand.add_child(held_object)
|
||||
|
|
@ -52,6 +53,18 @@ func _physics_process(delta):
|
|||
held_object.position = Vector3(0,0,0)
|
||||
held_object.freeze = true
|
||||
has_object = true
|
||||
elif "placed_command" in raycast.get_collider():
|
||||
# clicked a pedestal, place on pedestal if its not already got something
|
||||
var clicked_pedestal = raycast.get_collider() as Pedestal
|
||||
print("clicked pedestal: "+ clicked_pedestal.name)
|
||||
if(has_object and not clicked_pedestal.has_command):
|
||||
print("trying to place")
|
||||
held_object.reparent(clicked_pedestal.slot)
|
||||
held_object.position = Vector3(0,0,0)
|
||||
held_object.rotation_degrees = Vector3(0,0,0)
|
||||
has_object = false
|
||||
clicked_pedestal.has_command = true
|
||||
clicked_pedestal.placed_command = held_object
|
||||
else:
|
||||
print(raycast.get_collider().name)
|
||||
object_clicked.emit(raycast.get_collider())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue