Twine Q&A - Recent questions tagged live-macro Powered by Question2Answer Problems With Live Macro (harlowe) <p>(Harlowe 2.1.0)</p><p>I&#39;m making a text version of the old unreleased game &#39;Desert Bus&#39; where you drive a bus 360 miles in real time as a way to play around with and learn the (live:) macro.</p><p>I have a (live:) macro run every 2 seconds and refresh the info on screen (speed, distance, time, etc.)</p><p>I also test the win/lose cases as the last thing checked on every cycle of the (live:) macro.</p><p>The major issue I&#39;m having is that when you do finally travel 360 miles and hit the win state rather than go to the win screen Google Chrome just&nbsp;throws&nbsp;the generic &quot;Aww, Snap!&quot; error screen.</p><p>The weird thing is that if I set the variable containing your milleage to start at, say, 350, everything runs as expected and goes to the win screen. It seems to only fail if it&#39;s been running a rather long time.</p><p>Here is the code I use to test for winning or losing. I keep it in a seperate passage and use the (display:) macro on the main passage:</p><pre><code>{ ::func:tests alt:: &lt;!--Tests if you've driven far enough--&gt; (if: $bus's distance is &gt;=(360*$trips))[ (set: $bus's distance to (360*$trips)) (goto:"win") ] &lt;!-- Tests if you've gone off road or stood idle too long --&gt; (else:)[ (if: $bus's orientation is &gt;=-10 and &lt;=10)[ (if: $bus's speed is &gt;0)[ (set: $bus's orientation to it +1) (set: $bus's speed to it -1) (set: $stopCounter to 0) ] (if: $bus's distance is &gt; ((360 * ($trips -1))))[ (if: $stopCounter is &gt;= 5)[ (goto: "lose") ] (elseif: $bus's speed is 0)[ (set: $stopCounter to it +1) ] ] ] (else:)[ (goto:"lose") ] ] }</code></pre><p>&nbsp;</p><p>Here is the main passage containing the (live:) macro. I ended up using two (live:) macros to try and mitigate a problem I was having where the macro starts to refresh slower and slower as time goes on. (It didn&#39;t work and I haven&#39;t yet changed it back)&nbsp;The test cases are at the bottom:</p><pre><code>{ (live: 2s)[ (display:"header") ] --- &lt;div class="small"&gt; YOUR DRIVER IS: &lt;br&gt; $name. &lt;/div&gt; &lt;br&gt; (live: 2s)[ (display: "func:bugSplat alt") &lt;div id="dataDisplay"&gt; (display: "data") &lt;/div&gt; &lt;br&gt; &lt;br&gt; &lt;div class="center"&gt;-ROAD-&lt;/div&gt; (display:"func:orientation") (display:"status alt") --- &lt;br&gt; &lt;div id="controls"&gt; (display:"controls") &lt;/div&gt; (display:"func:tests alt") ] }</code></pre><p>I don&#39;t have much programming knowledge (only some visual basic in college) so, I guess my question is why would it break after having run for an extended amount of time and is there a way to fix it?</p><p>I would also like to know if there is a way to make the (live:) macro refresh at a more consistent rate?</p><p>&nbsp;</p><p>Thank you.</p> Sat, 03 Nov 2018 05:10:49 +0000 Any way to implement better / more precise timing? <p>As an experiment, I&#39;ve been trying to see if I can construct an exploding bomb with a countdown timer and a red wire/green wire choice that all takes place within a single passage.</p><p>Everything works, except that if you cut the red wire in the last second before the bomb explodes ... it still explodes. It momentarily displays the text &#39;Just in the nick of time&#39;, but then the counter hits zero and the bomb explodes anyway.</p><p>Here is the code:</p><pre><code>[(set:$secondsleft to 10){(live: 1s)[(set:$secondsleft to it - 1)(if: $redwirecut is "yes")[(stop:)]]}The bomb timer reads (live: 0.5s)[$secondsleft]]&lt;bombscenario| [(link: "Cut the red wire")[(set: $redwirecut to "yes")(replace: ?greenwireoption)[](replace: ?redwireoption)[Just in the nick of time!]]]&lt;redwireoption| [(link: "Cut the green wire")[(replace: ?bombscenario)[BOOOOM](replace: ?greenwireoption)[](replace: ?redwireoption)[]]]&lt;greenwireoption| (live: 1s)[(if: $secondsleft is 0)[(replace: ?bombscenario)[BOOOOM](replace: ?greenwireoption)[](replace: ?redwireoption)[]]]</code></pre><p>The &#39;Just in the nick of time&#39; text should display in the same instant that the countdown stops, so I&#39;m not sure what&#39;s going wrong.</p> Thu, 20 Jul 2017 09:12:26 +0000