first commit

master
cynic 4 years ago
commit 8cf907653c
  1. 1
      .gitignore
  2. 4
      events_def.py
  3. 21
      main.py
  4. 4
      scripts/script1.py
  5. 6
      scripts/script2.py

1
.gitignore vendored

@ -0,0 +1 @@
__pycache__

@ -0,0 +1,4 @@
from enum import Enum
class events(Enum):
ONCE = 0, #once, on program start
PER_TICK = 1 #once per tick

@ -0,0 +1,21 @@
import os
import sys
import time
from events_def import events
sys.path.append("./scripts")
plugins = list(map(lambda n : n.split(".py")[0], filter(lambda n : n[-3:] == ".py", os.listdir("./scripts"))))
plugins_loaded = []
print(plugins)
for plugin in plugins:
module = __import__(plugin)
plugins_loaded.append(module)
if events.ONCE in module.triggers:
getattr(module, "run")(None)
for tick_count in range(1, 10):
for plugin in plugins_loaded:
if events.PER_TICK in plugin.triggers:
getattr(plugin, "run")(tick_count)

@ -0,0 +1,4 @@
from events_def import events
triggers = [events.ONCE]
def run(ctx):
print("wooooo, script1!")

@ -0,0 +1,6 @@
from events_def import events
triggers = [events.PER_TICK, events.ONCE]
def run(ctx):
print("woooo, script2!")
if ctx:
print("run on tick:", ctx)
Loading…
Cancel
Save