Skip to content

Go: Economy

Functions

OnMoneyBefore

Go
func OnMoneyBefore(fn func(MoneyEvent) bool) error

OnMoneyBefore calls fn before every economy transaction; returning false vetoes it.

OnMoneyAfter

Go
func OnMoneyAfter(fn func(MoneyEvent)) error

OnMoneyAfter calls fn after every economy transaction.

Money

Go
func Money(xuid string) (int64, error)

Money is a balance. A negative answer means it cannot be read, an empty xuid or no economy backend, and is an error: a real balance is never negative.

  • Parameters:
    • xuid : string
  • Return type: (int64, error)
  • Slots: get_money

SetMoney

Go
func SetMoney(xuid string, amount int64) error

SetMoney sets a balance.

  • Parameters:
    • xuid : string
    • amount : int64
  • Return type: error
  • Slots: set_money

AddMoney

Go
func AddMoney(xuid string, delta int64) error

AddMoney adds to a balance.

  • Parameters:
    • xuid : string
    • delta : int64
  • Return type: error
  • Slots: add_money

ReduceMoney

Go
func ReduceMoney(xuid string, delta int64) error

ReduceMoney takes from a balance.

  • Parameters:
    • xuid : string
    • delta : int64
  • Return type: error
  • Slots: reduce_money

TransferMoney

Go
func TransferMoney(from, to string, value int64, note string) error

TransferMoney moves value between two balances; the recipient receives it taxed.

  • Parameters:
    • from : string
    • to : string
    • value : int64
    • note : string
  • Return type: error
  • Slots: trans_money

MoneyKind

Go
type MoneyKind int32

MoneyKind is what an economy event does, one of the Money* kinds. A value outside them is one a newer economy backend sent; a veto listener should refuse it rather than guess.

Name Value Description
MoneySet 0
MoneyAdd 1
MoneyReduce 2
MoneyTrans 3

MoneyEvent

Go
1
2
3
4
5
6
type MoneyEvent struct {
    Kind  MoneyKind
    From  string
    To    string
    Value int64
}

MoneyEvent is one economy transaction.