Docs · shop

shop

22 shop commands, generated from the engine's own registry — signatures, parameters and a worked example each. A does something command acts on the game; a needs x() one answers a confident wrong answer when its client hooks are missing.

shop returns list<shopitem>
shop() -> list<shopitem>

Every slot holding something, in grid order. Empty while no shop is open, which is not the same as an empty shop.

Example
for row in shop() { print(row.name, row.stock) }
shopAvailable returns bool
shopAvailable() -> bool

Whether the shop hooks are published. shopIsOpen() answers a confident false when they are not, which looks exactly like a closed shop.

Example
if not shopAvailable() { stop }
shopBuy does something returns bool
shopBuy(id: int, amount: int) -> boolshopBuy(name: string, amount: int) -> bool

Buys from the shop and waits for the items to appear in the bag. Not a passthrough: the API sends the packet and returns at once. The amount is clamped to the shop's stock, as the dialog clamps it.

Buys by name and waits for the items to appear in the bag.

ParameterTypeWhat it does
idrequired int the item id
amountrequired int how many to buy
namerequired string the item name
Example
if not shopBuy(151, 10) { return 1000 }
if not shopBuy("Coal", 10) { return 1000 }
shopBuyPrice returns int
shopBuyPrice(id: int, amount: int) -> intshopBuyPrice(id: int) -> intshopBuyPrice(name: string, amount: int) -> intshopBuyPrice(name: string) -> int

What buying this many would cost in total, or -1 when the shop has none or the item's value is not published. Not amount times the unit price - each one bought pushes the price up.

What one costs to buy, or -1.

What buying this many of a named item would cost, or -1 when the shop does not list it.

What one of a named item costs to buy, or -1.

ParameterTypeWhat it does
idrequired int the item id
amountrequired int how many, because each one moves the price
namerequired string the item name
Example
if shopBuyPrice(151, 10) > 500 { print("too dear") }
print("each:", shopBuyPrice(151))
if shopBuyPrice("Coal", 10) < 500 { print("cheap") }
print("each:", shopBuyPrice("Coal"))
shopBuyPriceMod returns int
shopBuyPriceMod() -> int

The percentage of an item's value the shop charges you, before the stock adjustment. For reading a shop, not for pricing a trade - use shopBuyPrice for that.

Example
print("markup:", shopBuyPriceMod())
shopClose does something returns bool
shopClose() -> bool

Shuts the shop window and waits for it to go. False when it was already shut or the window never closed.

Example
shopClose()
shopContains returns bool
shopContains(id: int) -> boolshopContains(name: string) -> bool

True when the shop lists this item at all, in stock or not.

True when the shop lists an item with this name, in stock or not.

ParameterTypeWhat it does
idrequired int the item id
namerequired string the item name
Example
if shopContains(151) { print("it deals in these") }
if shopContains("Coal") { print("it deals in these") }
shopCount returns int
shopCount() -> int

How many slots hold something. 0 while no shop is open.

Example
if shopCount() == 0 { return 600 }
shopIsGeneralStore returns bool
shopIsGeneralStore() -> bool

True in a general store. Those buy anything and list your own bag alongside their stock - those slots read back with a stock of 0. Everywhere else only buys what it already stocks, and refuses bank notes.

Example
if shopIsGeneralStore() { print("it will take anything") }
shopIsOpen needs shopAvailable() returns bool
shopIsOpen() -> bool

True while a shop window is up. Nothing else in this group does anything while it is false.

Example
if not shopIsOpen() { return 600 }
shopItem returns shopitem?
shopItem(id: int) -> shopitem?shopItem(name: string) -> shopitem?

The shop's slot for this item, or none.

The shop's slot for the item with this name, or none.

ParameterTypeWhat it does
idrequired int the item id
namerequired string the item name
Example
let ore = shopItem(151)
let axe = shopItem("Bronze axe")
shopMissing returns string
shopMissing() -> string

Which shop hooks are unbound, as one line, or an empty string when they all are. Worth printing once rather than guessing why nothing works.

Example
let absent = shopMissing()
shopPriceMultiplier returns int
shopPriceMultiplier() -> int

How hard the price swings as stock drifts from a slot's basis. 0 means a shop whose prices never move.

Example
if shopPriceMultiplier() == 0 { print("fixed prices") }
shopPricesKnown returns bool
shopPricesKnown() -> bool

Whether prices can be worked out on this client. False means the item value the curve needs is not published, so every price reads -1 while the stock and the trading still work.

Example
if not shopPricesKnown() { print("no prices on this server") }
shopSelectedID returns int
shopSelectedID() -> int

The item in the highlighted slot, or -1.

Example
print("selected:", shopSelectedID())
shopSelectedSlot returns int
shopSelectedSlot() -> int

The slot the dialog has highlighted, or -1. Nothing here needs a selection - the packets carry the item - so this is for reading the window.

Example
print("highlighted:", shopSelectedSlot())
shopSell does something returns bool
shopSell(id: int, amount: int) -> boolshopSell(name: string, amount: int) -> bool

Sells to the shop and waits for the items to leave the bag. The amount is clamped to what is carried, and a shop that does not list the item will not take it - a general store lists your bag for that reason.

Sells by name and waits for the items to leave the bag.

ParameterTypeWhat it does
idrequired int the item id
amountrequired int how many to sell
namerequired string the item name
Example
if not shopSell(151, 10) { return 1000 }
if not shopSell("Coal", 10) { return 1000 }
shopSellAll does something returns bool
shopSellAll(id: int) -> boolshopSellAll(name: string) -> bool

Sells every one of this item you are carrying and waits for the bag to lose them.

Sells every one of this item by name and waits for the bag to lose them.

ParameterTypeWhat it does
idrequired int the item id
namerequired string the item name
Example
shopSellAll(151)
shopSellAll("Bones")
shopSellPrice returns int
shopSellPrice(id: int, amount: int) -> intshopSellPrice(id: int) -> intshopSellPrice(name: string, amount: int) -> intshopSellPrice(name: string) -> int

What selling this many would fetch in total, or -1 when the shop would not take them or the item's value is not published.

What one fetches when sold, or -1.

What selling this many of a named item would fetch, or -1 when the shop would not take them.

What one of a named item fetches when sold, or -1.

ParameterTypeWhat it does
idrequired int the item id
amountrequired int how many, because each one moves the price
namerequired string the item name
Example
print("the lot:", shopSellPrice(151, 28))
print("each:", shopSellPrice(151))
print("the lot:", shopSellPrice("Bones", 28))
print("each:", shopSellPrice("Bones"))
shopSellPriceMod returns int
shopSellPriceMod() -> int

The percentage of an item's value the shop pays you, before the stock adjustment.

Example
print("they pay:", shopSellPriceMod())
shopSlot returns shopitem?
shopSlot(slot: int) -> shopitem?

Whatever is in that slot of the grid, or none when it is empty. The grid is 40 slots; slot 0 is the top left.

ParameterTypeWhat it does
slotrequired int which slot, counting from 0
Example
let third = shopSlot(2)
shopStock returns int
shopStock(id: int) -> intshopStock(name: string) -> int

How many of an item the shop has, 0 if it does not stock it at all.

How many of an item the shop has by name, 0 if it does not stock it.

ParameterTypeWhat it does
idrequired int the item id
namerequired string the item name
Example
if shopStock(151) > 0 { print("in stock") }
if shopStock("Coal") > 0 { print("in stock") }