Skip to content

Instantly share code, notes, and snippets.

@GoldsteinE
Created December 12, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoldsteinE/9457dda8decb77cdeb4b50143baee61e to your computer and use it in GitHub Desktop.
Save GoldsteinE/9457dda8decb77cdeb4b50143baee61e to your computer and use it in GitHub Desktop.
scripting.py
import os
import threading
import time
from storage import storage, temp_storage, one_time_storage
def run(level, script_name, args):
def run_f(level, script_name, args):
def say(text):
text_id = level.game.start_dialog(text)
while level.game.dialog_pool.has(text_id) or level.game.dialog_text_id == text_id:
time.sleep(0.1)
script_name = os.path.join(*script_name)
script_text = open(os.path.join('scripts',
script_name + '.py'),
encoding='utf-8').read()
script = compile(script_text, script_name + '.py', 'exec')
exec(script, {'say': say,
'store': storage,
'temp': temp_storage,
'ots': one_time_storage}, {})
script_thread = threading.Thread(target=run_f, daemon=True, args=(level, script_name, args))
script_thread.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment