[prev in list] [next in list] [prev in thread] [next in thread]
List: flightgear-devel
Subject: Re: [Flightgear-devel] [PATCH] fgdata chat message highlighting
From: scosu <scos () allfex ! org>
Date: 2012-01-22 17:36:50
Message-ID: 20120122183650.23ac0b79 () raven
[Download RAW message or body]
Hi,
Thank you, I searched for this function but didn't find it. I replaced the 'tolower' \
function with the string.lc calls in the patch.
scosu
On Sun, 22 Jan 2012 16:46:30 +0100
Melchior FRANZ <mfranz@aon.at> wrote:
> Hey,
>
> your proposed function screen.tolower() is redundant, because there
> is already string.uc() (named after Perl's function uc() for "upper
> case").
>
> m. (who wrote screen.nas)
[Attachment #3 (text/x-patch)]
diff --git a/Nasal/screen.nas b/Nasal/screen.nas
index 2d572aa..26e1508 100644
--- a/Nasal/screen.nas
+++ b/Nasal/screen.nas
@@ -458,6 +458,38 @@ _setlistener("/sim/signals/fdm-initialized", func {
# functions that make use of the window class (and don't belong anywhere else)
##############################################################################
+# highlights messages with the multiplayer callsign in the text
+var msg_mp = func (n) {
+ if (!getprop("/sim/multiplay/chat-display"))
+ return;
+ var msg = string.uc(n.getValue());
+ var call = string.uc(getprop("/sim/multiplay/callsign"));
+ var matching = 0;
+ var found = 0;
+ for(var i = 0; i < size(msg); i = i + 1) {
+ if (msg[i] == ` ` or msg[i] == `,` or msg[i] == `.` or msg[i] == `;` or msg[i] == \
`:` or msg[i] == `>`) { + if (matching == size(call)) {
+ found = 1;
+ break;
+ }
+ matching = 0;
+ continue;
+ }
+ if (matching >= size(call)) {
+ matching = matching + 1;
+ continue;
+ }
+ if (call[matching] == msg[i]) {
+ matching = matching + 1;
+ } else {
+ matching = 0;
+ }
+ }
+ if (found == 1 or matching == size(call))
+ screen.log.write(n.getValue(), 1.0, 0.5, 0.5);
+ else
+ screen.log.write(n.getValue(), 0.5, 0.0, 0.8);
+}
var msg_repeat = func {
if (getprop("/sim/tutorials/running")) {
@@ -557,9 +589,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
func(n) map("copilot", n.getValue(), 1.0, 1.0, 1.0));
listener.ai_plane = setlistener(m ~ "ai-plane",
func(n) map("ai-plane", n.getValue(), 0.9, 0.4, 0.2));
- listener.mp_plane = setlistener(m ~ "mp-plane",
- func(n) map("ai-plane", n.getValue(), 0.5, 0.0, 0.8,
- func getprop("/sim/multiplay/chat-display")));
+ listener.mp_plane = setlistener(m ~ "mp-plane", msg_mp);
});
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic