MODULE: Digraphs v1.0 - Automatically replace accented characters

Started by SSH, Fri 02/12/2005 17:39:03

Previous topic - Next topic

SSH

This module is for translating digraphs (i.e. pairs of characters) into single characters. This may be useful if you have accented characters in your font, replacing some unused chars like '$' or '!'.

Download here (Requires AGS v2.71)
Documentation
Mirror
Mirror 2

Just two functions:

//   function Digraph.Set(String digraph, char to);
//     Set up a digraph. One would normally set up a bunch of these in
//     game_start so that they apply for the whole game. The two characters
//     specified in the string will be converted to the char value "to" when
//     the digraph-translation function is used.
//    
//   String function Digraph.T(String from)
//     Translates the String passed and returns a modified string. If no
//     digraphs to translate, will return an identical string. A #define is
//     also setup to allow abbreviation of this function name to DG

Example code:

Code: ags

// global script

function game_start() {
  Digraph.Set("a'", '$'); // a acute
  Digraph.Set("e'", '!'); // e acute
  Digraph.Set("n~", '@'); // enye
}


Code: ags

// room script

function room_a() {
  // Script for room: Player enters room (after fadein)

  Display(DG("Ole', mi espan~ola, que ta'l?"));
}
12

strazer

I thought about doing something like this once but abandoned it since you can't use it in dialog scripts. Good work though.

SMF spam blocked by CleanTalk