shop

Shop stock and buy/sell actions.

Methods
17
Fields
None

Getting one

shop

Methods

MethodReturnsDescription
isOpen()booleanWhether a shop interface is open.
close()booleanClose the shop.
contains(number)booleanWhether the shop stocks an item.
containsName(string)booleanWhether the shop stocks an item whose whole name matches, ignoring case: | separates alternatives and * is any run of characters.
items(){ ShopItem }Everything the shop has in stock; empty when it is shut.
item(number)ShopItem?The row stocking an item, resolved live.
stock(number)numberHow many of an item the shop currently holds.
buyOptions(number){ number }Which buy quantities the shop offers for an item, in menu order.
buy1(number)booleanBuy one of an item by id.
buy5(number)booleanBuy five of an item by id.
buy10(number)booleanBuy ten of an item by id.
buy50(number)booleanBuy fifty of an item by id.
sellOptions(number){ number }Which sell quantities the shop offers for an item, in menu order.
sell1(number)booleanSell one, by id.
sell5(number)booleanSell five, by id.
sell10(number)booleanSell ten, by id.
sell50(number)booleanSell fifty, by id.

Method details

isOpen

isOpen: (Shop) -> boolean

Whether a shop interface is open.

close

close: (Shop) -> boolean

Close the shop.

Returns
false when no shop is open.

contains

contains: (Shop, number) -> boolean

Whether the shop stocks an item.

itemId
Exact item id.

containsName

containsName: (Shop, string) -> boolean

Whether the shop stocks an item whose whole name matches, ignoring case: | separates alternatives and * is any run of characters.

name
The name pattern, e.g. "Air rune" or "* rune".

items

items: (Shop) -> { ShopItem }

Everything the shop has in stock; empty when it is shut.

item

item: (Shop, number) -> ShopItem?

The row stocking an item, resolved live.

Shop layout is not fixed, so a slot is not a stable way to name what you want -- an id is.

itemId
Exact item id.
Returns
nil when the shop is shut or does not stock it.

stock

stock: (Shop, number) -> number

How many of an item the shop currently holds.

itemId
Exact item id.
Returns
0 when it is not stocked, or the shop is shut.

buyOptions

buyOptions: (Shop, number) -> { number }

Which buy quantities the shop offers for an item, in menu order.

A shop quantity is a MENU OPTION, not a number: the row's right-click is Value / Buy 1 / Buy 5 / Buy 10 / Buy 50, and some shops omit 50. That is why the buys below are four named calls rather than one taking a count -- an unavailable quantity has no option to click.

itemId
Exact item id.

buy1

buy1: (Shop, number) -> boolean

Buy one of an item by id.

itemId
Exact item id, e.g. ItemID.AIR_RUNE.

buy5

buy5: (Shop, number) -> boolean

Buy five of an item by id.

itemId
Exact item id.

buy10

buy10: (Shop, number) -> boolean

Buy ten of an item by id.

itemId
Exact item id.

buy50

buy50: (Shop, number) -> boolean

Buy fifty of an item by id.

The game truncates to available stock, so this buys twelve when twelve are stocked. Keep the option at or below your own remaining target.

itemId
Exact item id.

sellOptions

sellOptions: (Shop, number) -> { number }

Which sell quantities the shop offers for an item, in menu order.

itemId
Exact item id.

sell1

sell1: (Shop, number) -> boolean

Sell one, by id.

itemId
Exact item id.

sell5

sell5: (Shop, number) -> boolean

Sell five, by id.

itemId
Exact item id.

sell10

sell10: (Shop, number) -> boolean

Sell ten, by id.

itemId
Exact item id.

sell50

sell50: (Shop, number) -> boolean

Sell fifty, by id.

itemId
Exact item id.