mirror of https://github.com/dirtbags/moth.git
Now you can add scripts from puzzle.py
This commit is contained in:
parent
333f728e2a
commit
8d8db58f73
|
@ -260,15 +260,12 @@ class Puzzle:
|
||||||
|
|
||||||
elif key == 'script':
|
elif key == 'script':
|
||||||
stream = open(val, 'rb')
|
stream = open(val, 'rb')
|
||||||
# Make sure this shows up in the header block of the HTML output.
|
self.add_script_stream(stream, val)
|
||||||
self.files[val] = PuzzleFile(stream, val, visible=False)
|
|
||||||
self.scripts.append(val)
|
|
||||||
|
|
||||||
elif key == "scripts" and isinstance(val, list):
|
elif key == "scripts" and isinstance(val, list):
|
||||||
for script in val:
|
for script in val:
|
||||||
stream = open(script, "rb")
|
stream = open(script, "rb")
|
||||||
self.files[script] = PuzzleFile(stream, script, visible=False)
|
self.add_script_stream(stream, val)
|
||||||
self.scripts.append(script)
|
|
||||||
|
|
||||||
elif key == "objective":
|
elif key == "objective":
|
||||||
self.objective = val
|
self.objective = val
|
||||||
|
@ -322,6 +319,11 @@ class Puzzle:
|
||||||
self.add_stream(stream, name, visible)
|
self.add_stream(stream, name, visible)
|
||||||
return stream
|
return stream
|
||||||
|
|
||||||
|
def add_script_stream(self, stream, name):
|
||||||
|
# Make sure this shows up in the header block of the HTML output.
|
||||||
|
self.files[name] = PuzzleFile(stream, name, visible=False)
|
||||||
|
self.scripts.append(name)
|
||||||
|
|
||||||
def add_stream(self, stream, name=None, visible=True):
|
def add_stream(self, stream, name=None, visible=True):
|
||||||
if name is None:
|
if name is None:
|
||||||
name = self.random_hash()
|
name = self.random_hash()
|
||||||
|
|
Loading…
Reference in New Issue