Documentation
¶
Overview ¶
Package settings holds the rules for the settings a mod declares in its manifest: which declarations a build may carry, which values each setting accepts, and the value a player starts with. Hosts without a settings service keep players' values in a File.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Canonical ¶
func Canonical(setting *settingspb.Setting, value string) (string, bool)
Canonical returns value as the setting holds it and whether the setting accepts it: a choice's value, "true" or "false", or a number from min to max on a step from min.
func Default ¶
func Default(setting *settingspb.Setting) string
Default returns the value a player starts with: the declared default, or the first choice, off or min when the setting declares none.
func Find ¶
func Find(manifest *manifestpb.Manifest, key string) *settingspb.Setting
Find returns the setting named key that manifest declares, or nil.
func Validate ¶
func Validate(manifest *manifestpb.Manifest) error
Validate checks the settings manifest declares.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File keeps players' settings in memory and, given a path, in a JSON file of settings.StoredSettings, the same file modlock-host keeps. It reads the file when opened and rewrites it on each change. A File is not safe for concurrent use.
func Open ¶
Open reads the settings file at path, or starts empty when path is empty or the file does not exist. A file that does not decode starts empty, and the error says why.