Gamethread

From EventScripts Community Encyclopedia


Module: gamethread

Module Overview

EventScripts version: 2.0

Table of Contents

Contents


Description

This module lets you execute things later within the primary gamethread. It provides access to queues and delayed command management such that you can interact safely with the server from external threads.

Quick Example

import es
import gamethread
 
def myfunc(text):
    es.msg(text)
 
def player_say(event_var):
    # this causes myfunc() to be called in 0.1 seconds
    gamethread.delayed(0.1, myfunc, "Hello world")

Module Content

Classes

No public classes.

Methods

gamethread.delayed(seconds, cmd, args=(), kw=None)

Delay a Python function for seconds seconds.

gamethread.delayedname(seconds, name, cmd, args=(), kw=None)

Delay a Python function for seconds seconds. By naming the delayed function, you can cancel it by that name later with gamethread.cancelDelayed()

gamethread.cancelDelayed(name)

Cancel a pending delayed Python function that was started with gamethread.delayedname()

gamethread.listDelayed()

Prints to stdout a list of all pending delayed commands.

gamethread.queue(function, a=(), kw=None)

Queue a Python command to run at the very next opportunity during the server's main thread (typically during a GameFrame). Useful for other threads to execute commands on the next gameframe since the Source engine is not thread-safe.

See Also

blog comments powered by Disqus