Skip to content

Instantly share code, notes, and snippets.

@belkadan
Created Mar 30, 2013
Embed
What would you like to do?
One-hour text adventure shell, written in Lolcode. Intended for use with https://github.com/belkadan/lolcode-rb
HAI 1.3
BTW who remembers CS61A?
CAN HAS "pairs"
O HAI IM room
O HAI IM connection
I HAS A direction
I HAS A room
BTW constructor for connections
HOW IZ I formed YR direction AN YR elsewhere
BTW note the prototype-based inheritance!
I HAS A new ITZ LIEK ME
new'Z direction R direction
new'Z room R elsewhere
FOUND YR new
IF U SAY SO
KTHX
I HAS A name
I HAS A description
I HAS A connections ITZ NOOB
BTW constructor for rooms
HOW IZ I built YR name AN YR description
I HAS A new ITZ LIEK ME
new'Z name R name
new'Z description R description
FOUND YR new
IF U SAY SO
HOW IZ I connected YR direction AN YR elsewhere
MAH connection IZ formed direction AN elsewhere
I IZ consing IT AN MAH connections, MAH connections R IT
IF U SAY SO
HOW IZ I going YR direction
I HAS A choice
IM IN MAH connections gettin YR options
choice R IT
BOTH SAEM choice'Z direction AN direction, O RLY?
YA RLY
FOUND YR choice'Z room
OIC
KTHX
FOUND YR NOOB
IF U SAY SO
KTHX
BTW build the world
room IZ built "Lab" AN "There are lots of computers here. [up, code]"
I HAS A lab ITZ IT
room IZ built "Soda Hall" AN "The home of Computer Science at UC Berkeley. [down, out]"
I HAS A building ITZ IT
room IZ built "The Outside World" AN "It's bright. You are likely to be eaten by a flyerer. [in]"
I HAS A outside ITZ IT
BTW connect the world
lab IZ connected "up" AN building
building IZ connected "down" AN lab
building IZ connected "out" AN outside
outside IZ connected "in" AN building
lab IZ connected "code" AN lab
BTW we use this as a singleton
O HAI IM player
I HAS A location ITZ lab
KTHX
BTW explore!
I HAS A direction, I HAS A destination
IM IN YR head, BTW infinite loop
VISIBLE player'Z location'Z name
VISIBLE player'Z location'Z description
VISIBLE "", BTW blank line
VISIBLE "? " !
GIMMEH direction
BOTH SAEM direction AN "", O RLY?
YA RLY
GTFO head, BTW break!
OIC
player'Z location IZ going direction
destination R IT
BOTH SAEM destination AN NOOB, O RLY?
YA RLY
VISIBLE "HA HA NOOB U CANT GO THAT WAY"
VISIBLE ""
NO WAI
player'Z location R destination
OIC
KTHX
KTHXBYE
HAI 1.3
O HAI IM pair
I HAS A first
I HAS A rest
HOW IZ I finding YR item
BOTH SAEM MAH first AN item
O RLY?
YA RLY, FOUND ME
MEBBE MAH rest, MAH rest IZ finding item
NO WAI, FAIL
OIC
IF U SAY SO
HOW IZ I visible
VISIBLE MAH first " "!
MAH rest, O RLY?
YA RLY, MAH rest IZ visible
NO WAI, VISIBLE "", BTW newline
OIC
IF U SAY SO
BTW IM LIEK ITERATOR?
O HAI IM iterator
I HAS A start
HOW IZ I going
I HAS A value ITZ MAH start'Z first
MAH start R MAH start'Z rest
FOUND YR value
IF U SAY SO
HOW IZ I finished
BOTH SAEM MAH start AN NOOB
IF U SAY SO
KTHX
HOW IZ I gettin
I HAS A iter ITZ LIEK MAH iterator
iter'Z start R ME
FOUND YR iter
IF U SAY SO
KTHX
HOW IZ I consing YR left AN YR right
I HAS A pear ITZ LIEK pair
pear'Z first R left
pear'Z rest R right
FOUND YR pear
IF U SAY SO
HOW IZ I appending YR left AN YR right
NOT left, O RLY?
YA RLY, FOUND YR right
OIC
I IZ appending left'Z rest AN right
I IZ consing left'Z first AN IT
IF U SAY SO
HOW IZ I listing ALL YR things
I HAS A head
IM IN YR things reversin YR elements
I IZ consing IT AN head
head R IT
KTHX
IF U SAY SO
ME IZ frist, O RLY?
YA RLY
CAN HAS "../test/feature/test"
O HAI IM A test
MAH name R "listing"
I IZ disabled, BTW because BOTH SAEM can't be changed right now...
HOW IZ I testin
ME IZ checkin BOTH SAEM I IZ listing MKAY AN NOOB AN "()"
ME IZ checkin BOTH SAEM I IZ listing 1 MKAY AN I IZ consing 1 AN NOOB MKAY AN "(1)"
ME IZ checkin BOTH SAEM...
I IZ listing 1 AN 2 AN 3 MKAY AN...
I IZ consing 1 AN I IZ consing 2 AN I IZ consing 3 AN NOOB MKAY MKAY MKAY AN...
"(1 2 3)"
IF U SAY SO
I IZ runnin
KTHX
OIC
KTHXBAI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment