0 votes
by (220 points)

(Harlowe 2.1.0)

I'm making a text version of the old unreleased game 'Desert Bus' where you drive a bus 360 miles in real time as a way to play around with and learn the (live:) macro.

I have a (live:) macro run every 2 seconds and refresh the info on screen (speed, distance, time, etc.)

I also test the win/lose cases as the last thing checked on every cycle of the (live:) macro.

The major issue I'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 throws the generic "Aww, Snap!" error screen.

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's been running a rather long time.

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:

{	::func:tests alt::

	<!--Tests if you've driven far enough-->
	
	(if: $bus's distance is >=(360*$trips))[
		(set: $bus's distance to (360*$trips))
		(goto:"win")
		
	]
	
	<!-- Tests if you've gone off road or stood idle too long -->
	
	 (else:)[
		(if: $bus's orientation is >=-10 and <=10)[
			(if: $bus's speed is >0)[
				(set: $bus's orientation to it +1)
				(set: $bus's speed to it -1)
				(set: $stopCounter to 0)
			]
		
		
			(if: $bus's distance is > ((360 * ($trips -1))))[
				(if: $stopCounter is >= 5)[
					(goto: "lose")
				]
		
				(elseif: $bus's speed is 0)[
					(set: $stopCounter to it +1)
				]
			]
	
		] 

		(else:)[
			(goto:"lose")
		]
	]
}

 

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't work and I haven't yet changed it back) The test cases are at the bottom:

{
		(live: 2s)[
			(display:"header")
		]
---
<div class="small">
	YOUR DRIVER IS: 
	<br>
	$name.
</div>
<br>

(live: 2s)[
(display: "func:bugSplat alt")
		<div id="dataDisplay">
			(display: "data")
		</div>
		
	<br>
	<br>

	<div class="center">-ROAD-</div>
	(display:"func:orientation")
	(display:"status alt")
---
<br>
	<div id="controls">
			(display:"controls")
	</div>
			(display:"func:tests alt")
		]
}

I don'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?

I would also like to know if there is a way to make the (live:) macro refresh at a more consistent rate?

 

Thank you.

2 Answers

0 votes
by (220 points)
I've been testing it some more it seems to work on Firefox but not Chrome
0 votes
by (6.2k points)
if there seems to be nothing wrong with the code and it works on firefox, its probably just the browser. perhaps you could set up a saving system so the progress is saved then the game is refreshed and continued?
...