RCRPG/Unicon: Difference between revisions

m
Fixed syntax highlighting.
(tweak messages)
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user 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 93 ⟶ 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 237 ⟶ 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 248 ⟶ 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 269 ⟶ 270:
Aliases[a[1]] := a
every Aliases[!["hocus","pocus","shazzam","walla","xyzzy"]] := "abracadabra"
end</langsyntaxhighlight>
9,476

edits