Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-19-2008, 05:42 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
replacestring

Uses my TMap 'class'... Thought it might be useful for generic converters.
( Note: This can't convert a Muslim to being Christian. )

PHP Code:
function onCreated()
{
  
this.codeMap TMap.newInstance();
  
this.codeMap.put"&""&" );
  
this.codeMap.put"<""&ltag;" );
  
this.codeMap.put">""&rtag;" );
}

function 
encodeoldString )
{
  return 
convertoldStringthis.codeMap );
}

function 
decodeoldString )
{
  return 
convertoldStringTMap.inversethis.codeMap ) );
}

function 
convertoldStringtemp.codeMap )
{
  
temp.newString oldString;
  
temp.codes temp.codeMap.keySet();
  for ( 
temp.0temp.temp.newString.length(); temp.++ )
  {
    for ( 
temp.codetemp.codes )
    {
      if ( 
temp.newString.substringtemp.itemp.code.length() ) == temp.code )
      {
        
temp.replace temp.codeMap.gettemp.code );

        
temp.newString =
          
temp.newString.substring0temp.)
            @ 
temp.replace @
          
temp.newString.substringtemp.temp.code.length() );
        
        
temp.+= temp.replace.length() - temp.code.length();
      }
    }
  }
  
  return 
temp.newString;

Reply With Quote
  #2  
Old 01-19-2008, 06:02 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
Cool!
__________________
Trying to be nice now...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.