# tabuildr.icn class Way(src,dest,descrip) end class Room(name, descrip, detail, edges) method mkway(dest, descrip) /edges := table() descrip ? { tab(find("[")+1) way := tab(find("]")) } edges[way] := Way(self, dest, descrip) end initially(nm, desc, det) name := \nm | "unknown room" descrip := \desc | "You are in a nondescript empty room." detail := \det | "There is nothing here." end global rooms, current procedure main() rooms := table() write("Welcome to the text adventure builder") current := rooms["void"] := Room("void","You are in a dark void.","You can't see anything much.") repeat { write(current.descrip) every write((!\(current.edges)).descrip) if not ( command := read() ) then stop("Goodbye.") argv := cmdlist(command) case argv[1] of { "mkrm": { rooms[argv[2]] := Room(argv[2], argv[3], argv[4]) write("Made ", argv[2]) } "mkway": { src := rooms[argv[2]] dest := rooms[argv[3]] src.mkway(dest, argv[4]) } "stop"| "quit": stop("Goodbye.") "look": write(current.detail) } } end procedure cmdlist(s) L := [ ] trim(s,0) ? { while put(L, tab(upto(' \t'))) do { while L[-1][1]=="\"" & L[-1][-1]~=="\"" do { L[-1] ||:= tab(many(' \t')) L[-1] ||:= tab(upto(' \t')) } if L[-1][1]=="\"" & L[-1][-1]~=="\"" then L[-1] := L[-1][2:-1] tab(many(' \t')) } put(L, tab(0)) } return L end