Documentation ¶
Overview ¶
Package event implements WolfMUD's asynchronous scripting mechanism.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.