So i created a function for the shop system to reroll the items and it works. I know that when starting out, if it works leave it but I keep telling my sell you can make it better, they’re ways of making it better. That alone make’s it hard for me to anything I’m interested in doing not just coding. Is there a why to shake this mindset?
Also the code if you want to see it:
class_name StoreInventory extends Resource
@export var store_items: Array[SlotData] = []
@export var loot_table: ItemDropTable
var rng: RandomNumberGenerator
var previous_shops: Dictionary[int, Array] = {}
var store_index: int
func reroll_store() -> void:
var temporary_array: Array[SlotData]
temporary_array.resize(10)
for index: int in range(temporary_array.size()):
temporary_array[index] = SlotData.new()
for index: int in temporary_array.size():
var item: ItemData = LootGenerator.generate_loot(loot_table)
if not index == 0 and temporary_array.any(
func(slot: SlotData) -> bool:
if slot == null or slot.item_data == null:
return false
return slot.item_data.name == item.name):
continue
temporary_array[index].item_data = item
if temporary_array[index].item_data == null:
continue
if temporary_array[index].item_data is not EquippableItemData:
temporary_array[index].quantity = Globals.rng.randi_range(1, 5)
continue
temporary_array[index].quantity = 1
temporary_array = temporary_array.filter(func (slot: SlotData) -> bool:
return slot.item_data != null)
store_index += 1
previous_shops = {store_index: store_items.duplicate(true)}
store_items.clear()
temporary_array.sort_custom(
func(slot_A: SlotData, slot_B: SlotData) -> bool:
if slot_A.item_data == null or slot_B.item_data == null:
return false
return slot_A.item_data.cost > slot_B.item_data.cost)
store_items.append_array(temporary_array)
the issue is with item equals null check can’t roll a null value unless i purposely add an empty slot with a weighting and the item doesn’t hold the quantity value the slot data does, but everything else looks cleaner than mine.
I’m not good with time constraints, I would more than likely be panicking over what to make than actually making it. I’m not disregarding the idea just confidence is not high for it.
I thought that, too, but signed up for one anyway. OK, the game I made was not good, but I did it in the time allotted and it helped me more than I would have thought. I recommend the experience.