TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Vertical split map/chats area

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts
View previous topic :: View next topic  
Author Message
compmstr



Joined: 05 Jul 2010
Posts: 17

PostPosted: Sat Jul 17, 2010 4:54 pm    Post subject: Vertical split map/chats area Reply with quote

This script adds a few aliases that allow you to have a 10x10 map with other output beside it in the top split.
You could also use it to set up some gauges or something in the "map" area.
Usage:
need to have a split of 11, 1
clearmap; - clears the map
addmapline <map text>; - adds a new line to the bottom of the map
addchatline <text>; - adds a new chat line, bottom displayed is most recent.
showtop; - displays both the map and chat lines at the top of the screen

Any comments would be welcome Smile

Code:

#nop set up maplines and chatlines
#var maplines {};
#loop {1} {10} {cnt} {#list maplines insert 1 {};};
#var chatlines{};
#loop {1} {10} {cnt} {#list chatlines insert 1 {};};

#alias {clearmap}
{
   #unvariable maplines;
   #nop #echo {Clearing map}
   #var maplines {};
   #loop {1} {10} {cnt} {#list maplines insert 1 { };}
};

#alias {addmapline}
{
   #nop each map line will be at most 10 visible chars
   #nop #echo {Adding map line};
   #list maplines ins -1 {%0};
   #list maplines del 1;
};

#alias {addchatline}
{
   #var newChatLine {};
   #unvariable newChatLine;
   #var newChatLine {%0};
   #replace {newChatLine} {"%"} {"&perc;"};
   #replace {newChatLine} {'} {&apos;};
   #format {scriptLine} {addChatLine.pl %C '$newChatLine'};
   #script {$scriptLine};
};

#nop display the map and chat lines
#alias {showtop}
{
   #loop {1} {10} {cnt}
   {
      #format {curString} {%-12s%s} {$maplines[$cnt]} {$chatlines[$cnt]};
      #echo {{$curString} {-$cnt}};
   };
};


*Edit: of course, it would help if I included the perl script for add chat lines Smile*
Code:

#!/usr/bin/env perl

use Text::Wrap;

$screenCols = $ARGV[0];
$theText = $ARGV[1];
$theText =~ s/&apos;/'/g;

$Text::Wrap::columns = $screenCols - 13;

open LOG, ">>chatline.log";
print LOG "\n\nNew run...\n";

print LOG "Columns: $screenCols\n";
print LOG "Text: $theText\n";

#take the ANSI sequences out of the text
#store in two lists, one of the indexes that they were found at, the other with
#   the sequence itself
$curIndex = 0;
@indices = ();
@escapes = ();
$firstIndex = index($theText, "\x1b[");
$smallString = $theText;
while(1)
{
   #find the last escape sequence
   if($curIndex == 0 && $firstIndex == 0)
   {
   }
   else
   {
      $curIndex = index($theText, "\x1b[", $curIndex);
   }
   #print "Index: $curIndex\n";
   if($curIndex == -1)
   {
      last;
   }
   else
   {
      #find the first letter m at the end of it
      $curEnd = index($theText, 'm', $curIndex + 1);
      #print "End: $curEnd\n";
      $curEscape = substr($theText, $curIndex, $curEnd - $curIndex + 1);
      $escapeFind = quotemeta $curEscape; #escape regexp metachars
      #print "Escape search: " . $escapeFind . "\n";
      $smallString =~ s/$escapeFind//;
      #print "Small String: ";
      #print $smallString . "\n";
      @indices = (@indices, $curIndex);
      @escapes = (@escapes, $curEscape);
   }
   $curIndex += 1;
}

#print "Indices: " . @indices . "\n";

@lines = split /\n/, wrap("", "", $smallString);
$lineStart = 0;
$curIndex = 0;
foreach $line (@lines)
{
   while($curIndex <= length(@indices) and $indices[$curIndex] < length($line))
   {
      substr($line, $indices[$curIndex], 0) = $escapes[$curIndex];
      #print "Index: " . $indices[$curIndex] . "\n";
      $curIndex += 1;
   }
   print "#list chatlines ins -1 {$line};";
   print "#list chatlines del 1;";
   print LOG "#list chatlines ins -1 {$line};";
   print LOG "#list chatlines del 1;";
   print LOG "\n";
   $lineStart += length($line);
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group