Created
December 12, 2017 18:55
-
-
Save GoldsteinE/9457dda8decb77cdeb4b50143baee61e to your computer and use it in GitHub Desktop.
scripting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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