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.
for row in shop() { print(row.name, row.stock) }
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() -> list<shopitem>
Every slot holding something, in grid order. Empty while no shop is open, which is not the same as an empty shop.
for row in shop() { print(row.name, row.stock) }
shopAvailable() -> bool
Whether the shop hooks are published. shopIsOpen() answers a confident false when they are not, which looks exactly like a closed shop.
if not shopAvailable() { stop }
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| amountrequired | int | how many to buy |
| namerequired | string | the item name |
if not shopBuy(151, 10) { return 1000 }
if not shopBuy("Coal", 10) { return 1000 }
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| amountrequired | int | how many, because each one moves the price |
| namerequired | string | the item name |
if shopBuyPrice(151, 10) > 500 { print("too dear") }
print("each:", shopBuyPrice(151))
if shopBuyPrice("Coal", 10) < 500 { print("cheap") }
print("each:", shopBuyPrice("Coal"))
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.
print("markup:", shopBuyPriceMod())
shopClose() -> bool
Shuts the shop window and waits for it to go. False when it was already shut or the window never closed.
shopClose()
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| namerequired | string | the item name |
if shopContains(151) { print("it deals in these") }
if shopContains("Coal") { print("it deals in these") }
shopCount() -> int
How many slots hold something. 0 while no shop is open.
if shopCount() == 0 { return 600 }
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.
if shopIsGeneralStore() { print("it will take anything") }
shopIsOpen() -> bool
True while a shop window is up. Nothing else in this group does anything while it is false.
if not shopIsOpen() { return 600 }
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| namerequired | string | the item name |
let ore = shopItem(151)
let axe = shopItem("Bronze axe")
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.
let absent = shopMissing()
shopPriceMultiplier() -> int
How hard the price swings as stock drifts from a slot's basis. 0 means a shop whose prices never move.
if shopPriceMultiplier() == 0 { print("fixed prices") }
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.
if not shopPricesKnown() { print("no prices on this server") }
shopSelectedID() -> int
The item in the highlighted slot, or -1.
print("selected:", shopSelectedID())
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.
print("highlighted:", shopSelectedSlot())
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| amountrequired | int | how many to sell |
| namerequired | string | the item name |
if not shopSell(151, 10) { return 1000 }
if not shopSell("Coal", 10) { return 1000 }
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| namerequired | string | the item name |
shopSellAll(151)
shopSellAll("Bones")
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| amountrequired | int | how many, because each one moves the price |
| namerequired | string | the item name |
print("the lot:", shopSellPrice(151, 28))
print("each:", shopSellPrice(151))
print("the lot:", shopSellPrice("Bones", 28))
print("each:", shopSellPrice("Bones"))
shopSellPriceMod() -> int
The percentage of an item's value the shop pays you, before the stock adjustment.
print("they pay:", shopSellPriceMod())
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.
| Parameter | Type | What it does |
|---|---|---|
| slotrequired | int | which slot, counting from 0 |
let third = shopSlot(2)
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.
| Parameter | Type | What it does |
|---|---|---|
| idrequired | int | the item id |
| namerequired | string | the item name |
if shopStock(151) > 0 { print("in stock") }
if shopStock("Coal") > 0 { print("in stock") }