event

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2018 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package event implements WolfMUD's asynchronous scripting mechanism.

Index

Constants

This section is empty.

Variables

View Source
var Script func(t has.Thing, input string) string

Script is an indirect reference to the cmd.Script function. The cmd package cannot be imported directly as it causes a cyclic dependency. However the cmd package can import the event package to initialise this variable which we can then use. See cmd.Init in cmd/state.go for initialization.

Functions

This section is empty.

Types

type Cancel

type Cancel chan<- struct{}

Cancel is a send only channel that can be used to cancel a queued event. When an event is queued via Queue a Cancel channel will be returned. The Cancel channel should be closed to cancel the pending event that was queued.

func Queue

func Queue(thing has.Thing, input string, delay time.Duration, jitter time.Duration) Cancel

Queue schedules a scripted event to happen after the given delay period. Events can use any normal player commands and in addition have access to scripting only commands starting with the '$' symbol. The event can be cancelled by closing the returned Cancel channel. The passed in Thing is expected to be the 'actor' for the event. The input is the command to script. The delay is the period after which the command will be run. The jitter is a random amount that can be added to the delay. So the actual delay for an event will be between delay and delay+jitter. For a totally random event delay can be 0s.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL