--
-- word mixer module
--

function adlib (Text)

   -- replace tags that read as /tag/ with the given text; /tag/ must be recognized in the dictionary
   local Tags = Text:split ("/")
   local FText = ""
   for ID, Tag in pairs (Tags) do

      if ((ID % 2) == 0) then

         local Dict = adlib_dict[Tag]
         if (Dict) then

            FText = FText .. table_choose (Dict)
         else

            WARN ("unknown dictionary tag: ``" .. Tag .. "'' in text ``" .. Text .. "''")
            FText = FText .. Tag
         end
      else

         FText = FText .. Tag
      end
   end

   return FText
end

adlib_dict = {

   nameless = { "nameless", "small", "lonesome", "dark", "abandoned", "cold", "darkened", "dead-end" },
   truckstop = { "truck stop", "station", "service station" },
}
