Documentation ¶
Overview ¶
Package event implements WolfMUD's asynchronous scripting mechanism.
Index ¶
Constants ¶
This section is empty.
Variables ¶
FindName is an indirect reference to the attr.FindName function. The attr package cannot be imported directly as it causes a cyclic dependency. However the attr package can import the event package to initialise this variable which we can then use. See init function in attr/name.go for initialization.
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 init function 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. Queue returns a channel to cancel the event and the time of when the event is expected to fire.
The firing time is only the expected time and not guaranteed to be 100% accurate due to system load, scheduling and processing delays. Typically delays are expected to be < 500µs (0.0005s). Delays can be monitored by setting Debug.Events to true in the configuration file, in which case the delivered messages will contain the amount the event was delayed by, for example: "Event delivered (delayed 127.596µs)"
The passed Thing is expected to be the 'actor' for the scripted event.
The input string can use any normal player command and in addition can use the scripting only commands starting with the '$' symbol.
The event can be cancelled by closing the returned Cancel channel.
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.