Gamethread
From EventScripts Community Encyclopedia
|
[edit] Module: gamethread[edit] Module OverviewEventScripts version: 2.0 [edit] Table of Contents
[edit] DescriptionThis 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. [edit] Quick Exampleimport 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") [edit] Module Content[edit] ClassesNo public classes. [edit] Methodsgamethread.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() 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. [edit] See Also
|
|
