Suggestion to localization thing

The format of 'mes' messages also needs improvements (ie merge all the lines of a sentence into the same string, be it separated by n or not). I'm personally for not separating it by n (except in the places where a line break is needed), so that the text flow will change accordingly to the font use by a (hexed) client.

For mob and NPC names, we currently don't have a plan. I'm open to ideas.

Announce/dispbottom, etc are all translatable, by using the _() macro.

FluxCP currently doesn't have a maintainer, so I'm not sure whether it'll happen.

 
Last edited by a moderator:
Here you go, see if it works alright (did only basic testing). Requires PHP-CLI:

php collapsemes.php /path/to/npc/folderOld files are backed up as *.bak, files that need no change are not touched. You might want to use this in a separate working copy in case it screws up.

collapsemes.php:

#!/usr/bin/php<?php// =================================================================// Collapse consecutive *mes into one, v1.0.1// (c) 2015 Ai4rei/AN//// This work is licensed under a// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )// =================================================================// Down-level (PHP 4)if(!function_exists('file_put_contents')){ function file_put_contents($sFileName,$sData) { if(($hFile = fopen($sFileName,'wb'))!==false) { return fwrite($hFile,$sData) && fclose($hFile); } return false; }}// Down-level Endfunction ProcessFile($sFile){ $bSuccess = false; echo "File: {$sFile}... load"; if(($sData =@file_get_contents($sFile))!==false) { echo ' conv'; // mes ( ( var | string ) [,+] )* string; mes " $sPattern = '/((?<![a-z0-9_])mess+((??:(??:[$.]?@?|#{1,2}|')(?:[a-zA-Z0-9_]+)$?)|(??<!)"(?:.(?!(?<!)"))*.?"))s*[,+]s*)*(??<!)"(?:.(?!(?<!)"))*.?))"s*;s*mess+")/sS'; if(preg_match($sPattern,$sData)) { do { $sData = preg_replace($sPattern,'mes $2n',$sData); } while(preg_match($sPattern,$sData)); echo ' save'; if(rename($sFile,substr($sFile,0,-3).'bak') && file_put_contents($sFile,$sData)) { echo " successn"; $bSuccess = true; } else { echo " failuren"; } } else { echo " skipn"; $bSuccess = true; } } else { echo " failuren"; } return $bSuccess;}function ProcessPath($sPath){ $bSuccess = true; echo "Enter: {$sPath}n"; if(($hDir =@opendir($sPath))!==false) { while(($sFile = readdir($hDir))!==false) { if(substr($sFile,0,1)=='.') {// unix world: skip self- and parent-references and so-called hidden files continue; } $sFullPath = $sPath.'/'.$sFile; if(is_dir($sFullPath)) { if(!ProcessPath($sFullPath)) { $bSuccess = false; break; } } elseif(is_file($sFullPath) && substr(strtolower($sFile),-4)==='.txt') { if(!ProcessFile($sFullPath)) { $bSuccess = false; break; } } } closedir($hDir); } else { echo "Failed to read directory: {$sPath}n"; } echo "Leave: {$sPath}n"; return $bSuccess;}function Main($nArgc,$aArgv){ if($nArgc<2) { echo "Usage: php collapsemes.php <script path>n"; return true; } return ProcessPath($aArgv[1]);}if(isset($_SERVER['argc']) && isset($_SERVER['argv'])){ return Main($_SERVER['argc'],$_SERVER['argv']) ? 0 : 1;}die("This script must be run on command line.n");?>
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Edit:

v1.0.1: Removed a flag, added regexp overview.
hello
default_tongue.png
any chance to have it updated in order to work with current system (that has been merged today), well, no hurries tho, but I guess they are not providing a conversion too for all npcs since there are only samples 

 
Just to make sure, to make it support the following?

mes "Lorem ipsum dolor sit amet,\r"

"consectetur adipiscing elit."

↓↓↓
Code:
mes "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
 
Just to make sure, to make it support the following?

mes "Lorem ipsum dolor sit amet,\r"
"consectetur adipiscing elit."↓↓↓
Code:
mes "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
better wait for @Haru input, by the way since you pointed it out, the early code you provided can work now I guess, can you re-paste it and I'll try to make it work again (I don't really remember how I managed to do so lol)

 
Back
Top