RCRPG/Unicon: Difference between revisions

m
Fixed syntax highlighting.
(words out of order)
m (Fixed syntax highlighting.)
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{collection|RCRPG}}
The following program implements the RCRPG game in Unicon.
 
Line 18 ⟶ 19:
 
The main program follows:
<langsyntaxhighlight Uniconlang="unicon">record roominfo(x,y,z,name,items,n,s,e,w,u,d) # about rooms
record urinfo(here,carrying,using) # about your character
 
Line 37 ⟶ 38:
(\Alias_Setup)() # optional
repeat Describe() & DoCommand()
end</langsyntaxhighlight>
 
The following implement the navigation procedures:
<langsyntaxhighlight Uniconlang="unicon">procedure AddRoom(x,y,z,name,item[]) #: Create room w/item(s)
if *item = 0 then push(item, \?[&null,"sledge","ladder","gold"]) # randomize
return roominfo(x,y,z,\name|"",item)
Line 67 ⟶ 68:
put(UR.here.items,"broken hammer")
write("You broke your sledge hammer and left it on the ground.")
write(if \Abracadabra then "There is a hint of magic in the air."
else "Hope you found another.")
}
}
Line 91 ⟶ 94:
"west" : UR.here.w
}
end</langsyntaxhighlight>
 
The following are the command processing and non-navigational commands:
<langsyntaxhighlight Uniconlang="unicon">procedure Alias() #: make a command alias
/Aliases := table()
if Aliases[Command[2]] := Command[3] then
Line 235 ⟶ 238:
else write("I see no ",item)
else write("What do you want me to take?")
end </langsyntaxhighlight>
 
The following are miscellaneous supprt procedures:
<langsyntaxhighlight Uniconlang="unicon">procedure ShowList(X,c) #: return c separated elements
/c := ", "
every (s := "") ||:= !X || c
Line 246 ⟶ 249:
procedure index(L, x) #: generate indices for x
every if x === L[i := 1 to *L] then suspend i
end</langsyntaxhighlight>
 
The following are minor embellishments that are silently linked. If they are left out, the remaining code should be able to continue on unaffected.
<langsyntaxhighlight Uniconlang="unicon">procedure Abracadabra() #: magic word
static uses
initial uses := 3
Line 258 ⟶ 261:
}
else if uses = 0 then write("... No. Nothing happens.")
else if uses = -1 then write("... You are now have a fuchsai tail!!")
else write("... Thankfully nothing else happens.")
end
Line 267 ⟶ 270:
Aliases[a[1]] := a
every Aliases[!["hocus","pocus","shazzam","walla","xyzzy"]] := "abracadabra"
end</langsyntaxhighlight>
9,483

edits