Bugged trading inventory

This commit is contained in:
gotfishmakesticks 2024-01-14 14:00:42 +03:00
commit 793938857e
3 changed files with 136 additions and 45 deletions

View file

@ -27,6 +27,10 @@ var base
@onready var equip_primary = $EquipmentMenu/EquipPrimaryButton
@onready var equip_secondary = $EquipmentMenu/EquipSecondaryButton
@onready var label_mod_info = $EquipmentMenu/LabelInfoBlock
@onready var label_energy = $TradingMenu/EnergyCount
@onready var label_food = $TradingMenu/FoodCount
@onready var label_minerals = $TradingMenu/MineralsCount
@onready var label_water = $TradingMenu/WaterCount
var base_types = ["Power Supply", "Mining", "Food Production", "Trading"]
var equipment_category = "hull"
var focused_mod_id = -1
@ -78,6 +82,7 @@ func _ready():
shields_prices = base.shields_prices
weapons_prices = base.weapons_prices
select_hull_mod()
update_goods_numbers()
## Updates buy and sell list in trading menu with available items
func update_lists():
@ -123,7 +128,7 @@ func buy_item():
else:
ship.hull.cargo[item_data[0]] = amount
ship.money -= total_price
print(ship.hull.cargo)
update_goods_numbers()
## Event handler for sell option in trading menu
func sell_item():
@ -150,7 +155,7 @@ func sell_item():
return
ship.hull.cargo[item_data[0]] -= amount
ship.money += total_price
print(ship.hull.cargo)
update_goods_numbers()
func buy_text_changed(_new_text):
buy_input.placeholder_text = "Amount to sell"
@ -505,3 +510,22 @@ func set_module_info_text(item):
}
text += "Ammo type: {ammotype}\nAmmo consumption: {ammocons} units/usage\nFirerate: {firerate} usages/second\nSpread: {spread} degrees".format(format)
label_mod_info.text = text
func update_goods_numbers():
var cargo = ship.hull.cargo
if cargo.has('Energy Cell'):
label_energy.text = str(cargo['Energy Cell'])
else:
label_energy.text = "0"
if cargo.has('Food Supplies'):
label_food.text = str(cargo['Food Supplies'])
else:
label_food.text = "0"
if cargo.has('Raw Materials'):
label_minerals.text = str(cargo['Raw Materials'])
else:
label_minerals.text = "0"
if cargo.has('Water Barrel'):
label_water.text = str(cargo['Water Barrel'])
else:
label_water.text = "0"

View file

@ -22,8 +22,6 @@ func open():
base_menu.quest_status_update()
"EquipmentMenuGoto":
menu = equipment_menu
"InfoMenuGoto":
menu = info_menu
menu.visible = true
if submenu != null:
submenu.visible = true