Documentation
¶
Index ¶
- func AddExec(L *lua.LState, m *lua.LTable)
- func AddReader(L *lua.LState, m *lua.LTable)
- func AddTimer(L *lua.LState, m *lua.LTable)
- func Loader(L *lua.LState) int
- func OpenCore(L *lua.LState)
- func OpenCoreWithName(name string, L *lua.LState)
- type LineCallbackOptions
- type Reader
- type Timer
- type TimerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenCoreWithName ¶
Types ¶
type LineCallbackOptions ¶
type LineCallbackOptions struct {
// PrefixArgs holds a list of arguments that should be passed to the callback
// before the actual line
PrefixArgs []lua.LValue
// SuffixArgs holds a list of arguments that should be passed to the callback
// after the actual line
SuffixArgs []lua.LValue
}
LineCallbackOptions holds additional options for Reader.WithLineCallback
type Reader ¶
Reader wraps the io.Reader interface into a dedicated type exposed to Lua
func NewReader ¶
NewReader is a utility method that creates a new reader object. The returned LUserData still needs to be pushed to the Lua stack using L.Push
func (*Reader) WithLineCallback ¶
func (r *Reader) WithLineCallback(lineCb callback.Callback, opts *LineCallbackOptions)
WithLineCallback starts reading from the reader and calls the provided callback for each line
type Timer ¶
type Timer struct {
*TimerOptions
// contains filtered or unexported fields
}
func NewTimer ¶
NewTimer creates a new timer for the given lua.LState. Note that the caller is responsible for initializing the timer by calling .Init(). Passing the timer-object to lua without calling .Init() may have strange side-effects
func (*Timer) Again ¶
func (t *Timer) Again()
Again restart the time. This is equalent to calling .Stop() and .Start()
func (*Timer) Init ¶
Init initializes the timer. If CallNow is set, Init() will try to execute the callback. In this case, if L is provided, the callback function will run immediately. If L is nil, the callback is scheduled on the loop and Init() will wait for it to finish. Note that the caller MUST provide L if it's currently running inside the loop. Otherwise it will deadlock. The returned error will always be nil if CallNow is set to false. If the callback is invoked immediately, the returned error may be a lua error
type TimerOptions ¶
type TimerOptions struct {
// Timeout for the timer. After each timeout, the Callback function is invoked
// this field MUST be set
Timeout time.Duration
// Autostart defines whether the time should start immediately
Autostart bool
// CallNow defines whether the callback function should be triggered immediately
CallNow bool
// Callback is the actual callback function to invoke
Callback callback.Callback
// SingleShot configures the timer to automaticall stop after the first timeout
SingleShot bool
}
TimerOptions holds configuration options for a new timer