From fbb81024ea206bfad1436e27f49175a815b010b7 Mon Sep 17 00:00:00 2001 From: nokoe Date: Sat, 22 Jun 2024 18:14:27 +0200 Subject: update multiplayer, add take, put --- client/scripts/player.gd | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'client/scripts/player.gd') diff --git a/client/scripts/player.gd b/client/scripts/player.gd index 8f53b790..6e07c3aa 100644 --- a/client/scripts/player.gd +++ b/client/scripts/player.gd @@ -9,7 +9,9 @@ var position_ = Vector2(0, 0) var mesh = preload("res://scenes/player.tscn").instantiate() -func _init(id: int, new_name: String, pos: Vector2, _character: int, new_game: Game): +var hand: Node3D = null + +func _init(id: int, new_name: String, pos: Vector2, _character: int): add_child(mesh) position_ = pos name = new_name @@ -19,6 +21,17 @@ func update_position(new_position: Vector2, new_rotation: float): position_ = new_position rotation.y = new_rotation -func _process(delta): - position.x = position_.x - position.z = position_.y +func take_item(tile: FullTile): + if hand != null: + push_error("already holding an item") + var i = tile.take_item() + if i == null: + push_error("tile is null") + hand = i + +func put_item(tile: FullTile): + var i = hand + if i == null: + push_error("holding nothing") + i = null + tile.put_item(hand) -- cgit v1.2.3-70-g09d2