Fiendish said:
Quote: how can i remove the "&#" part and replace it with the standard ANSI code?
The simplest way to do this is
color_ANSI = {
k = ANSI(0,30),
r = ANSI(0,31),
g = ANSI(0,32),
y = ANSI(0,33),
b = ANSI(0,34),
m = ANSI(0,35),
c = ANSI(0,36),
w = ANSI(0,37),
K = ANSI(1,30),
R = ANSI(1,31),
G = ANSI(1,32),
Y = ANSI(1,33),
B = ANSI(1,34),
M = ANSI(1,35),
C = ANSI(1,36),
W = ANSI(1,37)
}
ANSIstring = string.gsub(str,"&([^&])", color_ANSI)
It works, but then i'd like to add some other values to this table.... how can i add a "-" to it (the client receive lines containing the string "&-")?
Fiendish said:
Quote: The map is sent using non-ascii charachters. How can i "grab" them and send them to the (still to be made) mapping window? Plenty of other threads talk about how to make triggers.
Quote: How can i search for a string that begins with, say, - "AbCd - (the " char is part of the string) followed by 5 numbers, comma separated, and show only what follow the last comma in a new line? Plenty of other threads talk about how to make triggers.
I know. I've read a lot of page. It may be that LUA is new for me, it may be that RegExp are barely understandable, for me; it may be that being English not my first language i'm missing something. It may be that i'm dumb, also.
Anyway, i've still to found a solution.
I tried with a regExp generator (http://osteele.com/tools/rework/#) but the result is not "valid" in the script.
I'll try to ask again, expanding my question.
This are a packet i receive, breaking it in multiple lines to show the various "fields" i need to work with:
1) &d001100
2) &!pi" [»²»2©]2»²])2»2)6»²]\» \;"
3) &!t"Le stalle"
4) &!d"Questa deve essere la stanza dove vengono custoditi i cavalli. Qui il tipico odore di cavalli e ronzini e' molto piu' forte. Non riesci a scorgere il pavimento, tanta e' la paglia che lo ricopre. Su un soppalco sono accumulati grossi fasci di fieno ed avena e alzando lo sguardo noti le grosse travi che sorreggono il soffitto."
5) &!ao"605,0,1,0,70312,Vedi una torcia accesa, posta su un sostegno di ferro infisso alla parete. "
5) &!am"157,0,1,0,632008,Un grasso nano si gratta nervosamente la barba."
6) &o6
7) &!st"22,22,0,0,115,131"
They are, in the order:
1) Unknown data
2) Map data (contains also non ascii chars)
3) Title
4) Description
5) Room contents
6) Weather graphics
7) Status data (health, stamina, mana)
What i'd need, after some thoughs, is to remove the "&!" special code, save the relative lines (and numeric fields) in some global variables, and put in the output everything is between the << " >> chars.
So i put your code in the plugin OnPluginPacketReceived function, and i tried to expand that function.
Trying to follow your example, and using that RegExp generator, i wrote a line to remove the numeric fields from 5)
ANSIstring,n = string.gsub (ANSIstring, '&!ao"([0-9]*,)([0-9]*,)([0-9]*,)([0-9]*,)([0-9]*,)', "\n&g")
Still, i have problems 'cause i'm not able to search for the ([0-9]*,) pattern 5 times, i don't know how to save what i've found in a variable, and how to keep only what's inside the quotes.
Thanks
|