Skip to content

Commit 6b8f111

Browse files
Fixed an issue where the last picked up item wouldn't show in the HUD if you enter a new level
1 parent aeb5a72 commit 6b8f111

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

HUD.gd

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ var advice := [
2424
"If you find yourself surrounded by enemies, get out of there",
2525
]
2626
var player_died := false
27-
var last_pickup :Item = null
2827
func _ready():
2928
if Items.level == 1:
3029
Items.using_seed = Items.WorldRNG.seed
3130
$HUD/Generating/UsefulAdvice.text = advice[randi()%advice.size()] + "\n"
3231
$HUD/Generating/UsefulAdvice.text += "Seed: " + str(Items.using_seed)
3332
var end_times : String
3433
func _process(delta):
35-
if last_pickup == null:
34+
if Items.last_pickup == null:
3635
$HUD/LastItem.texture = null
3736
else:
38-
$HUD/LastItem.texture = last_pickup.texture
37+
$HUD/LastItem.texture = Items.last_pickup.texture
3938
if get_tree().get_nodes_in_group("Player")[0].health.temperature > 30:
4039
$HUD/Hot.modulate.a = lerp($HUD/Hot.modulate.a, (get_tree().get_nodes_in_group("Player")[0].health.temperature-30)/110.0, 0.2)
4140
else:
@@ -153,14 +152,14 @@ func _process(delta):
153152
$HUD/ShortDesc.visible = true
154153
$HUD/ShortDesc.text = Items.player_spells[i].name
155154

156-
if last_pickup != null and mouse.x > 4 and mouse.y > 184 and mouse.x < 20 and mouse.y < 200:
155+
if Items.last_pickup != null and mouse.x > 4 and mouse.y > 184 and mouse.x < 20 and mouse.y < 200:
157156
if Input.is_key_pressed(KEY_SHIFT):
158157
$HUD/Description.visible = true
159-
$HUD/Description/Name.text = last_pickup.name
160-
$HUD/Description/Description.text = last_pickup.description
158+
$HUD/Description/Name.text = Items.last_pickup.name
159+
$HUD/Description/Description.text = Items.last_pickup.description
161160
else:
162161
$HUD/ShortDesc.visible = true
163-
$HUD/ShortDesc.text = last_pickup.name
162+
$HUD/ShortDesc.text = Items.last_pickup.name
164163

165164
if Input.is_action_just_pressed("Interact1") and clicked != -1:
166165
match clicked:

Items/ItemEntity.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ func _process(delta):
1414
if Player.position.distance_to(position) < 50:
1515
if Input.is_action_just_pressed("down"):
1616
Items.player_items.append(item.id)
17-
get_tree().get_nodes_in_group("HUD")[0].last_pickup = item
17+
Items.last_pickup = item
1818
queue_free()

Items/Items.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ var level := 1
4040

4141
var using_seed := 0
4242

43+
var last_pickup :Item = null
44+
4345
func _ready():
4446
var generator_seed := hash(OS.get_time())
4547
print("Generator seed: ", generator_seed)
@@ -155,6 +157,7 @@ func pick_random_item(rng:RandomNumberGenerator = LootRNG) -> Item:
155157
return items[tier].values()[rng.randi()%items[tier].values().size()]
156158

157159
func reset_player():
160+
last_pickup = null
158161
level = 1
159162
var generator_seed := hash(OS.get_time())
160163
print(Items.custom_seed)

0 commit comments

Comments
 (0)