dstparser

package
v0.0.0-...-734a412 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseTranslationTable

func ChooseTranslationTable(l *lua.LState, locale string) *lua.LFunction

ChooseTranslationTable returns *lua.LFunction, this function used to choose the translation table in lua state.

func ParsePlayerTxt

func ParsePlayerTxt(content string) []string

ParsePlayerTxt parse player.txt file, returns slice of klei ID

func ToCaveLevelDataOverridesLua

func ToCaveLevelDataOverridesLua(overrides LevelDataOverrides) ([]byte, error)

ToCaveLevelDataOverridesLua converts LevelDataOverrides to lua script

func ToClusterInI

func ToClusterInI(config ClusterConfig) ([]byte, error)

ToClusterInI converts ClusterConfig to cluster.ini

func ToMasterLevelDataOverridesLua

func ToMasterLevelDataOverridesLua(overrides LevelDataOverrides) ([]byte, error)

ToMasterLevelDataOverridesLua converts LevelDataOverrides to lua script

func ToModOverrideLua

func ToModOverrideLua(options []ModOverRideOption) ([]byte, error)

ToModOverrideLua return the lua representation of the modOverride options, the format is same as modoverride.lua

func ToPlayerTxt

func ToPlayerTxt(kleiIDs []string) ([]byte, error)

ToPlayerTxt converts kleiIDs to player.txt

func ToServerInI

func ToServerInI(config ServerConfig) ([]byte, error)

ToServerInI converts ServerConfig to server.ini

Types

type ChatLog

type ChatLog struct {
	Time   string `mapstructure:"time"`
	Type   string `mapstructure:"type"`
	KleiId string `mapstructure:"klei_id"`
	Name   string `mapstructure:"player_name"`
	Msg    string `mapstructure:"msg"`
}

ChatLog represents a chat record in server_chat_log.txt

func ParseServerChatLogs

func ParseServerChatLogs(content []byte) ([]ChatLog, error)

type ClusterConfig

type ClusterConfig struct {
	GamePlay GamePlay       `ini:"GAMEPLAY"`
	NetWork  ClusterNetwork `ini:"NETWORK"`
	Misc     Misc           `ini:"MISC"`
	Shard    ClusterShard   `ini:"SHARD"`
	Steam    ClusterSteam   `ini:"STEAM"`
}

ClusterConfig represents cluster.ini

func ParseClusterInI

func ParseClusterInI(data []byte) (ClusterConfig, error)

ParseClusterInI parses the cluster.ini to ClusterConfig struct type

type ClusterNetwork

type ClusterNetwork struct {
	// basic information
	WhiteListSlots     int    `ini:"whitelist_slots"`
	ClusterPassword    string `ini:"cluster_password"`
	ClusterName        string `ini:"cluster_name"`
	ClusterDescription string `ini:"cluster_description"`
	ClusterLanguage    string `ini:"cluster_language"`
	ClusterCloudId     string `ini:"cluster_cloud_id,omitempty"`

	// network
	Offline   bool `ini:"offline_cluster"`
	TrickRate int  `ini:"tick_rate,omitempty"`
	LanOnly   bool `ini:"lan_only_cluster"`
}

type ClusterShard

type ClusterShard struct {
	ShardEnable bool   `ini:"shard_enabled"`
	BindIP      string `ini:"bind_ip"`
	ClusterKey  string `ini:"cluster_key"`
	MasterIp    string `ini:"master_ip"`
	MasterPort  int    `ini:"master_port"`
}

type ClusterSteam

type ClusterSteam struct {
	GroupOnly  bool   `ini:"steam_group_only"`
	GroupId    string `ini:"steam_group_id"`
	GroupAdmin bool   `ini:"steam_group_admins"`
}

type GamePlay

type GamePlay struct {
	MaxPlayers     int    `ini:"max_players"`
	Pvp            bool   `ini:"pvp"`
	GameMode       string `ini:"game_mode"`
	PauseWhenEmpty bool   `ini:"pause_when_empty"`
	VoteEnable     bool   `ini:"vote_enabled"`
	VoteKickEnable bool   `ini:"vote_kick_enabled"`
}

type LevelDataOverrides

type LevelDataOverrides struct {
	Id                    string  `mapstructure:"id"`
	Name                  string  `mapstructure:"name"`
	Version               float64 `mapstructure:"version"`
	Desc                  string  `mapstructure:"desc"`
	Location              string  `mapstructure:"location"`
	PlayStyle             string  `mapstructure:"playstyle"`
	HideMiniMap           bool    `mapstructure:"hideminimap"`
	MaxPlayerListPosition float64 `mapstructure:"max_playerlist_position"`
	MinPlayerListPosition float64 `mapstructure:"min_playerlist_position"`
	NumRandomSetPieces    int     `mapstructure:"numrandom_set_pieces"`
	OverrideLevelString   bool    `mapstructure:"override_level_string"`

	// setting
	SettingId   string `mapstructure:"settings_id"`
	SettingName string `mapstructure:"settings_name"`
	SettingDesc string `mapstructure:"settings_desc"`

	// worldgen
	WorldGenId   string `mapstructure:"worldgen_id"`
	WorldGenName string `mapstructure:"worldgen_name"`
	WorldGenDesc string `mapstructure:"worldgen_desc"`

	// meta info
	Overrides           []LevelOverrideItem `mapstructure:"overrides"`
	RandomSetPieces     []string            `mapstructure:"random_set_pieces"`
	RequiredPrefabs     []string            `mapstructure:"required_prefabs"`
	RequiredSetPieces   []string            `mapstructure:"required_setpieces"`
	Substitutes         []string            `mapstructure:"substitutes"`
	BackGroundNodeRange []float64           `mapstructure:"background_node_range"`
}

LevelDataOverrides represents level data overrides information

func ParseLevelDataOverrides

func ParseLevelDataOverrides(luaScript []byte) (LevelDataOverrides, error)

ParseLevelDataOverrides parses the leveldataoverrides.lua, returns LevelDataOverrides information

type LevelOverrideItem

type LevelOverrideItem struct {
	Name  string `mapstructure:"name"`
	Value any    `mapstructure:"value"`
}

type Misc

type Misc struct {
	MaxSnapShots  int  `ini:"max_snapshots"`
	ConsoleEnable bool `ini:"console_enabled"`
}

type ModInfo

type ModInfo struct {
	// basic information
	Id          string `mapstructure:"id"`
	Name        string `mapstructure:"name"`
	Description string `mapstructure:"description"`
	Author      string `mapstructure:"author"`
	Version     string `mapstructure:"version"`
	ForumThread string `mapstructure:"forum_thread"`

	// dont starve
	ApiVersion              int  `mapstructure:"api_version"`
	DontStarveCompatible    bool `mapstructure:"dont_starve_compatible"`
	ReignOfGiantsCompatible bool `mapstructure:"reign_of_giants_compatible"`
	ShipWreckedCompatible   bool `mapstructure:"shipwrecked_compatible"`
	HamletCompatible        bool `mapstructure:"hamlet_compatible"`

	// dont starve together
	ApiVersionDst     int  `mapstructure:"api_version_dst"`
	DstCompatible     bool `mapstructure:"dst_compatible"`
	AllClientRequired bool `mapstructure:"all_client_required"`
	ClientOnly        bool `mapstructure:"client_only_mod"`
	ServerOnly        bool `mapstructure:"server_only_mod"`
	ForgeCompatible   bool `mapstructure:"forge_compatible"`

	// meta info
	FilterTags []string `mapstructure:"server_filter_tags"`
	Priority   float64  `mapstructure:"priority"`
	Icon       string   `mapstructure:"icon"`
	IconAtlas  string   `mapstructure:"icon_atlas"`

	// configuration
	ConfigurationOptions []ModOption `mapstructure:"configuration_options"`
}

func ParseModInfo

func ParseModInfo(luaScript []byte) (ModInfo, error)

ParseModInfo returns the parsed modinfo from lua script

func ParseModInfoWithEnv

func ParseModInfoWithEnv(luaScript []byte, folderName, locale string) (ModInfo, error)

ParseModInfoWithEnv parse mod info from lua script with mod environment variables.

type ModOption

type ModOption struct {
	// option name, maybe empty
	Name string `mapstructure:"name"`
	// option label, maybe empty
	Label string `mapstructure:"label"`
	// hover tooltip, maybe empty
	Hover string `mapstructure:"hover"`
	// default value of this option
	Default any      `mapstructure:"default"`
	Client  bool     `mapstructure:"client"`
	Tags    []string `mapstructure:"tags"`
	// options available
	Options []ModOptionItem `mapstructure:"options"`
}

ModOption represents a mod option in 'configuration_options'

type ModOptionItem

type ModOptionItem struct {
	Description string `mapstructure:"description"`
	Data        any    `mapstructure:"data"`
}

type ModOverRideOption

type ModOverRideOption struct {
	Id      string                  `mapstructure:"id"`
	Enabled bool                    `mapstructure:"enabled"`
	Items   []ModOverRideOptionItem `mapstructure:"options"`
}

func ParseModOverrides

func ParseModOverrides(luaScript []byte) ([]ModOverRideOption, error)

ParseModOverrides returns the mod override options from modoverrides.lua

type ModOverRideOptionItem

type ModOverRideOptionItem struct {
	Name  string `mapstructure:"name"`
	Value any    `mapstructure:"value"`
}

type ServerAccount

type ServerAccount struct {
	EncodeUserPath bool `ini:"encode_user_path"`
}

type ServerConfig

type ServerConfig struct {
	Network ServerNetwork `ini:"NETWORK"`
	Shard   ServerShard   `ini:"SHARD"`
	Steam   ServerSteam   `ini:"STEAM"`
	Account ServerAccount `ini:"ACCOUNT"`
}

ServerConfig represents server.ini

func ParseServerInI

func ParseServerInI(data []byte) (ServerConfig, error)

ParseServerInI parses the server.ini to ServerConfig struct type

type ServerNetwork

type ServerNetwork struct {
	ServerPort int `ini:"server_port"`
}

type ServerShard

type ServerShard struct {
	ID       string `ini:"id,omitempty"`
	Name     string `ini:"name,omitempty"`
	IsMaster bool   `ini:"is_master"`
}

type ServerSteam

type ServerSteam struct {
	MasterServerPort   int `ini:"master_server_port"`
	AuthenticationPort int `ini:"authentication_port"`
}

Jump to

Keyboard shortcuts

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