File: python_event.py

package info (click to toggle)
crossfire-maps 1.75.0%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 275,656 kB
  • sloc: python: 7,711; sql: 92; sh: 73; makefile: 7
file content (18 lines) | stat: -rw-r--r-- 661 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# python_event.py - this script handles all global events, except the plugin init (check plugin_init.py for that).
#
# This script merely looks and launches scripts in a specific subdirectory of /python/events/
# Only .py files are considered, you can simply rename a file to disable.
#
# This should simplify the separation of different Python things.

import Crossfire
import os

path = os.path.join(Crossfire.DataDirectory(), Crossfire.MapDirectory(), 'python/events', Crossfire.ScriptParameters())

if os.path.exists(path):
	scripts = os.listdir(path)

	for script in scripts:
		if (script.endswith('.py')):
			exec(open(os.path.join(path, script)).read())