GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - teeworlds-go/protocol: Teeworlds 0.7 network protocol library

BranchesTags
Open more actions menu

Latest commit

 

History

190 Commits
190 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
chunk7
chunk7
 
 
examples
examples
 
 
internal/testutils
internal/testutils
 
 
messages7
messages7
 
 
network6
network6
 
 
network7
network7
 
 
object7
object7
 
 
packer
packer
 
 
protocol7
protocol7
 
 
snapshot7
snapshot7
 
 
teeworlds7
teeworlds7
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 

Repository files navigation

teeworlds 0.7 protocol library for go

A client side network protocol implementation of the game teeworlds.

high level api for ease of use

The package teeworlds7 implements a high level client library. Designed for ease of use.

package main

import (
	"fmt"
	"os"

	"github.com/teeworlds-go/protocol/messages7"
	"github.com/teeworlds-go/protocol/snapshot7"
	"github.com/teeworlds-go/protocol/teeworlds7"
)

func main() {
	client := teeworlds7.NewClient()
	client.Name = "nameless tee"

	// Register your callback for incoming chat messages
	// For a full list of all callbacks see: https://github.com/teeworlds-go/protocol/tree/master/teeworlds7/user_hooks.go
	client.OnChat(func(msg *messages7.SvChat, defaultAction teeworlds7.DefaultAction) error {
		// the default action prints the chat message to the console
		// if this is not called and you don't print it your self the chat will not be visible
		err := defaultAction()
		if err != nil {
			return err
		}

		if msg.Message == "!ping" {
			// Send reply in chat using the SendChat() action
			// For a full list of all actions see: https://github.com/teeworlds-go/protocol/tree/master/teeworlds7/user_actions.go
			return client.SendChat("pong")
		}
		return nil
	})

	client.OnSnapshot(func(snap *snapshot7.Snapshot, defaultAction teeworlds7.DefaultAction) error {
		fmt.Printf("got snap with %d items\n", len(snap.Items))

		for _, character := range client.Game.Snap.Characters {
			fmt.Printf("  got tee at %.2f %.2f\n", float32(character.X)/32.0, float32(character.Y)/32.0)
		}

		char, found, err := client.SnapFindCharacter(client.LocalClientId)
		if err != nil {
			return err
		}
		if !found {
			return nil
		}
		fmt.Printf("  we are at %d %d\n", char.X/32, char.Y/32)
		client.Right()
		return nil
	})

	err := client.Connect("127.0.0.1", 8303)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

Example usages:

  • client_verbose a verbose client show casing the easy to use high level api
  • client_echo a simple client echoing messages in chat
  • client_trivia a trivia chat bot

low level api for power users

The packages chunk7, messages7, network7, packer, protocol7 Implement the low level 0.7 teeworlds protocol. Use them if you want to build something advanced such as a custom proxy.

projects using protocol

  • MITM teeworlds proxy
  • goofworlds gui client

About

Teeworlds 0.7 network protocol library

Topics

ddnetddnet-clientteeworldsteeworlds-clientteeworlds-protocol

Resources

Readme
BSD-2-Clause license
Activity
Custom properties

Stars

3 stars

Watchers

2 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.