signs

package module
v0.0.0-...-e1f0adc Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 13 Imported by: 1

README

mt-multiserver-signs

signs, is a toolbox for working with mcl_signs on multiserver

import (
	signs "github.com/ev2-1/mt-multiserver-signs"
)

pkg.go.dev

Documentation

Index

Constants

View Source
const (
	SIGN_WIDTH         = 115
	LINE_LENGTH        = 15
	NUMBER_OF_LINES    = 4
	LINE_HEIGHT        = 13
	CHAR_WIDTH         = 5
	PRINTED_CHAR_WIDTH = CHAR_WIDTH + 1
)

Variables

View Source
var CharUrl = "" /* 135-byte string literal not displayed */

CharUrl is the Url the characters.txt file will be loaded from (default is official MineClone2 repos)

View Source
var Prefix string = "micl2_"

Prefix is the prefix before the chars

Functions

func CenterLine

func CenterLine(line string, filler rune, width int) string

CenterLine centers a line, by padding the same left and right (right one more with odd length strings)

func GenerateSignAOAdd

func GenerateSignAOAdd(text, color string, pos [3]int16, rotation Rotate, wall bool, id mt.AOID) mt.AOAdd

func GenerateSignTexture

func GenerateSignTexture(text string, wall bool, color string) mt.Texture

GenerateSignTexture generates a sign texture (color has to be mt colorspec)

func GenerateTextureAOMod

func GenerateTextureAOMod(text string, wall bool, color string) *mt.AOCmdTextureMod

Generates a mt.AOCmdTextureMod for some signtext

func LoadCharMap

func LoadCharMap()

LoadCharMap downloads the character map from constant SignUrl (if not already have)

func Maths

func Maths()

Calculates some stuff for signs

func Ready

func Ready(cc *proxy.ClientConn)

Ready is called internaly Should not have to be called externaly

func RegisterSign

func RegisterSign(ps *Sign)

func SignProps

func SignProps() mt.AOProps

SignProps retuns a ruff AOProps representing a empty/raw sign

func Unready

func Unready(cc *proxy.ClientConn, srv string)

Unready is called internaly Should not have to be called externaly

func Update

func Update()

Update should be called whenever a `DynContent` value might change

Types

type Center

type Center struct {
	Filler rune
	Length int

	Content DynContent
}

Padding is a `DynContent`

func (*Center) Evaluate

func (ce *Center) Evaluate(text string, pos *SignPos) string

type ClickEvent

type ClickEvent interface {
	Click(cc *proxy.ClientConn, sign *Sign)
}

func ParseClick

func ParseClick(s string) ClickEvent

ParseClick parses a Stringrepresentation of a ClickEvent

type DynContent

type DynContent interface {
	Evaluate(string, *SignPos) string
}

func ParseDyn

func ParseDyn(s string) DynContent

ParseDyn parses string into dyncontent Interface

type Hop

type Hop struct {
	Srv string
}

Hops is a `ClickEvent`, when clicked cc.Hop(Srv) is executed

func (*Hop) Click

func (hop *Hop) Click(cc *proxy.ClientConn, _ *Sign)

type Padding

type Padding struct {
	Prepend bool
	Length  int
	Filler  rune
	Content DynContent
}

Padding is a `DynContent`, padding Content to be `Length` long filleed up by `Filler` while either `Prepending` or else Appending

func (*Padding) Evaluate

func (pa *Padding) Evaluate(text string, pos *SignPos) string

type PlayerCnt

type PlayerCnt struct {
	Srv string
}

PlayerCnt is a `DynContent` replaced by the PlayerCount on Srv

func (*PlayerCnt) Evaluate

func (pc *PlayerCnt) Evaluate(text string, pos *SignPos) string

type Rotate

type Rotate uint8
const (
	North Rotate = iota
	North22_5
	North45
	North67_5
	East
	East22_5
	East45
	East67_5
	South
	South22_5
	South45
	South67_5
	West
	West22_5
	West45
	West67_5
)

func ParseRotationString

func ParseRotationString(s string) Rotate

ParseRotationString parses rotation string

func (Rotate) String

func (i Rotate) String() string

type Sign

type Sign struct {
	Pos *SignPos

	Text  string
	Color string
	Dyn   []DynContent

	OnClick ClickEvent
	// contains filtered or unexported fields
}

func ParseScanner

func ParseScanner(scan *bufio.Scanner) (s []*Sign)

ParseScanner parses a bufio.Scanner into a []*Sign

type SignPos

type SignPos struct {
	Pos      [3]int16
	Wall     bool
	Rotation Rotate
	Server   string
}

SignPos defines the absolute position of a signtext

func ParsePos

func ParsePos(s string) (pos *SignPos)

ParsePos parses a stringpos like: 2 10 -5@hub wall South into a SignPos

type Text

type Text struct {
	Text string
}

Text is a `DynContent` thats static any always returns `Text`

func (*Text) Evaluate

func (t *Text) Evaluate(text string, pos *SignPos) string

Jump to

Keyboard shortcuts

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