make prints from the demo optional
This commit is contained in:
@@ -14,12 +14,19 @@ class Story {
|
||||
var storyScript: String;
|
||||
// Separate reader for Hiss expressions:
|
||||
var reader: HissReader;
|
||||
var debug: Bool;
|
||||
|
||||
function hissRead(str: String) {
|
||||
return reader.read("", HStream.FromString(str));
|
||||
}
|
||||
|
||||
public function new(storyScript: String, storyTeller: StoryTeller) {
|
||||
function debugPrint(val: HValue) {
|
||||
return if (debug) val.print() else val;
|
||||
}
|
||||
|
||||
public function new(storyScript: String, storyTeller: StoryTeller, debug = false) {
|
||||
this.debug = debug;
|
||||
|
||||
StaticFiles.compileWith("reader-macros.hiss");
|
||||
StaticFiles.compileWith("hanklib.hiss");
|
||||
|
||||
@@ -34,6 +41,8 @@ class Story {
|
||||
interp.importFunction(this, hissRead, "hiss-read");
|
||||
interp.importFunction(reader, reader.readDelimitedList, "hiss-read-delimited-list", List([Int(3)]) /* keep blankELements wrapped */, ["terminator", "delimiters", "start", "stream"]);
|
||||
|
||||
interp.importFunction(this, debugPrint, "debug-print", T);
|
||||
|
||||
interp.load("hanklib.hiss");
|
||||
}
|
||||
|
||||
@@ -42,12 +51,14 @@ class Story {
|
||||
|
||||
var storyCode = interp.readAll(StaticFiles.getContent(storyScript));
|
||||
|
||||
String("Main logic:").message();
|
||||
storyCode.print();
|
||||
if (debug) {
|
||||
String("Main logic:").message();
|
||||
storyCode.print();
|
||||
|
||||
String("").message();
|
||||
String("").message();
|
||||
String("").message();
|
||||
String("").message();
|
||||
String("").message();
|
||||
String("").message();
|
||||
}
|
||||
|
||||
stackSafeEval(Symbol("begin").cons(storyCode));
|
||||
}
|
||||
|
||||
@@ -10,8 +10,13 @@ class StoryTellerDemo implements StoryTeller {
|
||||
|
||||
var examples = sys.FileSystem.readDirectory("src/hank/examples");
|
||||
var demo = new StoryTellerDemo();
|
||||
var debug = false;
|
||||
#if debug
|
||||
debug = true;
|
||||
#end
|
||||
|
||||
demo.handleChoices(examples, (index) -> {
|
||||
new Story("examples/" + examples[index] + "/main.hank", demo).run();
|
||||
new Story("examples/" + examples[index] + "/main.hank", demo, debug).run();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
`(let (c (make-choice ,@args)
|
||||
label (choice-label c)
|
||||
id (length *choices*))
|
||||
(print c)
|
||||
(debug-print c)
|
||||
(push! *choices* c)
|
||||
(when label (dict-set! *labeled-choices* label c))
|
||||
id))
|
||||
@@ -59,7 +59,7 @@
|
||||
(for o choice-outputs (eval o)))
|
||||
(enable-continuations)
|
||||
(begin
|
||||
(setlocal player-choice-index (print (get-player-choice-index choice-texts)))
|
||||
(setlocal player-choice-index (debug-print (get-player-choice-index choice-texts)))
|
||||
(disable-continuations)
|
||||
|
||||
(let (player-choice
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
(hiss-read-delimited-list "\n" ["->"] t nil start stream)
|
||||
divert-calls
|
||||
(for target targets 'divert))
|
||||
(print (cons
|
||||
(debug-print (cons
|
||||
'begin
|
||||
(case (last targets)
|
||||
// tunnel statement:
|
||||
@@ -30,7 +30,7 @@
|
||||
(read-all (first (HStream:take-until stream ["=="] nil nil t))))
|
||||
|
||||
// Define the knot's function at READ-TIME
|
||||
(eval (print `(defun ,knot-name () ,@knot-body (quit))))
|
||||
(eval (debug-print `(defun ,knot-name () ,@knot-body (quit))))
|
||||
nil))
|
||||
|
||||
(defun read-choice (start stream)
|
||||
|
||||
Reference in New Issue
Block a user