Economy Buy SellResource

Player earns and spends currency at merchants; price and value decisions are meaningful.

Gold is spent and earned at a merchant: buying deducts an item's price into your goods, a too-dear item is refused, and selling returns gold.

How economy buy sell works in Godot

A shop is a currency integer plus a price table plus a transaction that mutates both sides atomically. No special node required.

intprimitive

Currency is a single number in GameState. Every price decision reads and writes it; guard against going negative.

var gold := 0
func can_afford(price): return gold >= price

Resourceprimitive

A ShopData resource holds the stock and prices. Different merchants are just different resources, not different code.

class_name ShopData extends Resource
@export var stock: Array[ItemData]
@export var prices: Dictionary   # { item_id: cost }

Signalsprimitive

A buy is one transaction: check funds, subtract gold, add item, emit. Emitting gold_changed keeps every gold display in sync.

signal gold_changed(amount)
func buy(item, price):
    if not can_afford(price): return
    gold -= price; inventory.add(item); gold_changed.emit(gold)

In short: currency int in GameState; ShopData Resource with item array and prices; transaction updates both currency and inventory

Retro games that use economy buy sell

69 catalogued game(s) use this mechanic, spanning 1985–1999.

Related resource mechanics

▶ Explore Economy Buy Sell interactively — see every game + the Godot system