"99 Bottles of Beer" in Halo Script

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
FleetAdmiralBacon




Critic Pyre Articulatist 500

Posts: 2377
Joined: Sat Nov 26, 2005 7:01 pm
Location: Ohio
Contact:

"99 Bottles of Beer" in Halo Script

Post by FleetAdmiralBacon »

I was really bored this morning and started randomly surfing.
I came across a site with programs that print the lyrics to 99 Bottles of Beer in 1103 different programming languages. After perusing the list, which included everything from Brainf*ck to PHP to MS DOS batch files. One thing it lacked was a Halo Script. Seeing as I was still bored out of my mind, I wrote one up and tested it.

Code: Select all

(global real bottles 99)

(script continuous drinkBeer
	(if (> bottles 1)
		(begin
		(inspect bottles)
		(print "bottles of beer on the wall!")
		(inspect bottles)
		(print "bottles of beer!")
		(print "Take one down, pass it around")
		(set bottles (- bottles 1))
		(inspect bottles)
		(print "bottles of beer on the wall!")
		(print " ")
		)
	)
	(if (= bottles 1)
		(begin
		(print "One bottle of beer on the wall")
		(print "One last bottle of beer!")
		(print "Take it down, pass it around")
		(print "No more bottles of beer on the wall!")
		(print " ")
		(print "No bottles of beer on the wall")
		(print "No more bottles of beer!")
		(print "Go to the store, buy some more")
		(print "99 bottles of beer on the wall!")
		(set bottles -1)
		(print " ")
		)
	)
)
Please note that this will only run in Sapien, as Halo doesn't actually print when you call (print <string>). Another important note is that since there is absolutely no way to convert 'bottles' to a string, and since you can't print or sv_say a value other than a string, we (inspect) it.


Enjoy.
Image
Everything you'll ever need to know about me.
Need help with Linux, C#, C, Python, Java, PHP, Javascript, CSS, or VB? I'm available from 3:00PM-8:00PM EST on weekdays.
SFlpm





Posts: 53
Joined: Fri Jun 30, 2006 6:16 am

Post by SFlpm »

Wow, you must have seriously been bored. Anyway cool, I sometimes come up with random ideas like that.
User avatar
MasterNeoChief




Conceptionist

Posts: 2431
Joined: Tue Dec 23, 2003 9:34 am
Location: The Netherlands

Post by MasterNeoChief »

Damn me. Good work though.

But get rid of the begins... Such useless script.

Also, wouldn't this print every line of the lyrics in rapid succession?
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

Halo scripting kind of reminds me of the scheme programming language, at least the syntax.
User avatar
FleetAdmiralBacon




Critic Pyre Articulatist 500

Posts: 2377
Joined: Sat Nov 26, 2005 7:01 pm
Location: Ohio
Contact:

Post by FleetAdmiralBacon »

MasterNeoChief wrote:Damn me. Good work though.

But get rid of the begins... Such useless script.

Also, wouldn't this print every line of the lyrics in rapid succession?
Sapien gave me syntax errors on the if statements, so I added the begins.

If you want to slow it down, you can just stick a sleep in there.

@ OwnZ joO: There are definitely similarities, but Halo's scripting language has squat when it comes to regular programmability.
Image
Everything you'll ever need to know about me.
Need help with Linux, C#, C, Python, Java, PHP, Javascript, CSS, or VB? I'm available from 3:00PM-8:00PM EST on weekdays.
Post Reply