RustHacker/inv_system/sell_panel.gd
2026-01-14 19:00:40 +11:00

40 lines
961 B
GDScript

extends Inventory
@export var sell_label : Label
@export var sell_button : Button
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
super()
calculate_sell_value()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
super(delta)
pass
func _notification(what: int) -> void:
super(what)
if what == Node.NOTIFICATION_DRAG_END:
calculate_sell_value()
pass
func calculate_sell_value():
if slots[0].item:
sell_label.text = str(floori(slots[0].item.buy_value / float(2)))
sell_button.disabled = false
else:
sell_label.text = "Place an item"
sell_button.disabled = true
func _on_sell_button_pressed() -> void:
if slots[0].item:
var sell_value : int = floori(slots[0].item.buy_value / float(2))
slots[0].item = null
slots[0].update_ui()
PlayerInventory.money += sell_value
calculate_sell_value()