|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Fri Aug 06, 2021 9:21 am
Quoting strings (for DBVARS) |
Aardwolf has the annoying fact of item names using all manner of ascii characters including:
~["! and so on
The equal sign (=) is particularly annoying as it messes up key-value pairs.
This has the adverse effect of foxing cMud when trying to deal with strings. Can anyone come up with a simple method of ending up with:
name=[] Tootie-frootie brand beans
getting stored as
name="[] Tootie-frootie brand beans"
?
I tried this as an exercise but it is impractical to test for everything...
replacing '"' (double quote) with EQSIGN. But this means I have to then decipher EQSIGN back into a double-quote. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Fri Aug 06, 2021 7:01 pm |
This could just be an artifact from the way json variables are stored internally... are the extra quotes still there when you try to reference the value?
If not, this might be easier with a trigger.
Can you show the direct output from the mud? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Sat Aug 07, 2021 9:28 am |
Item name examples:
Code: |
[] Tootie-frootie brand beans
=*= OFFICIAL WTC STUDENT ID BADGE =*=
|
as I stated, no ascii character seems to be exempt in item names.
=*= is particularly annoying as adding the entire thing creates a key pair with a 'key pair' after client decides that =*= represents a key-value pair. The same for the trailing pattern.
If I can grab the name string and have it quoted before I need to write it away will solve the issue. Again, I tried this quoting the = but ended up with a spaghetti of double and single quotes.
The goal here is to identify equipment and looted items. Problems exist because aard items have a unique id number and this means that if you get similar items they will have the same name and stats but a different id number. You only get the ID number with an actual ID command. When items are looted the text shown is the name. So, I make a key with the name but strip everything out of it that is not aA-zZ. When I actually ID these items I want to write the name as it is, 'warts and all'. It is not possible to do this real identify at loot time with a guarantee of success as the client cannot keep up with the mud output if you loot 4,5, or more items from the mob.
I am after a simple way to
ADDKEY name "actual name with fuzzy chars"
which will give me my key-value pair and avoid the character mucky-muck that confuses the cmud client. Obviously, I cannot write that as an actual command as double-quoting a variable turns it into a text string. I thought about
#ADDKEY name %concat(""",@name,""")
but I was half-hoping that there might be an obscure something I have missed. In truth I have not tried concatenation as it may end up that the variable gets dealt with first and I still end up with a messy key value. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sat Aug 07, 2021 3:22 pm |
Ahhh, perfect, the item is on a line all by itself. this should allow us to just use %line in your script to reference the item.
But first, another question, how does your script know what keyword to use to reference the items? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Sun Aug 08, 2021 7:59 am |
You get [] Tootie-frootie brand beans from the corpse of blah.
'item' is the name. Everything not an a-zA-Z char gets stripped out and made lower-case. This gives me a key that I use to prevent adding the same items looted again and again to a list which would grow un-necessarily.
tootiefrootiebrandbeans
gets written to a var as a key, and values are name, mob, room and zone. Aard funky functions include TAGS. Coupled with 'invdata' command, I get a listing of currently held items
Code: |
{invdata}
2511897117,MGH,a Symbol of Miad'Bir,62,6,0,-1,-1
2159327481,KM,Swift Galleon,1,15,1,-1,-1
2427716871,KMGH,a Bag of Aardwolf,201,11,1,-1,-1
2323137108,KMGH,a Bag of Aardwolf,201,11,1,-1,-1
2171181549,KMGH,a Bag of Aardwolf,201,11,1,-1,-1
2159396604,KMGH,a Bag of Aardwolf,201,11,1,-1,-1
{/invdata} |
I then loop through each matching the name against the name of the values in the looted list. ID an item and add the name to a $templist of items already identified if it does not exist there. Thus I can skip any items with the same name and just pack them away. So, in the end, I am only id-ing items once. I could just make a key from the ID name and match that against the key of the looted name. The key matches should be the same but matching the exact string is more exact. So I use the name and not the key.
How does using %line differ from just adding %trim(*) to a value? I have never used it but my understanding is that capture $var=%line(int) will capture the output from start to end:
item=You get fred's hammer from the corpse of fred
when all I want is
item="fred's hammer".
Other than my capture being an entire line as opposed to the text I want being a substring of %line, I see no benefit. %line is not going to really solve the problem of '"~=+~ in item names confusing cmud. |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Sun Aug 08, 2021 9:03 am |
For the record, I have just tried to concat double-quotes.
stringify
$returnString=%concat(""",$stringIn""")
#SH @stringify([] Tootie-frootie brand beans)
RETURNS
",$stringIn,"
So I guess %concat is a bust. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sun Aug 08, 2021 2:22 pm |
try:
$returnString=%concat(%char(34), $stringIn, %char(34)) |
|
_________________ Discord: Shalimarwildcat |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Tue Aug 10, 2021 11:06 am |
May work
|
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Thu Dec 30, 2021 9:52 pm |
Alas! Did not work. I also tried %string, %insert, %replace and a slew of other things. In every case, surrounding " are stripped out. So, the idea of having
name="(~--bizarre and un-necessary item name--~)"|id=1234567891|wgt=10|etc=etc
will not happen as far as I can see.
The problem has two fronts:
1. aardwolf's inane use of ANY ascii chars in item names
2. cMud's inability to boundary quote a key value.
Any char which conflicts with cmud's idea of a script/special/command char causes a problem. Re-assigning any 'special' chars is not going to help as aard will undoubtedly have item names that will conflict with any re-assignments.
I am running out of ideas and all I can think of is changing every non alpha/digit to a pseudo html special (eg., &qt, &, &lftbrk, &etc) but this is going to make my item name insanely lengthy in some cases. Plus, I then have to decode all this chaff to get a meaningful string back out.
If anyone knows of an alternative, LUA, VBscript that will work I'd gladly take that for my trigger.
#TRIG {You get ($itemName:*) from {the *|the} corpse of ($corpse:*).} |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Tue Jan 04, 2022 7:12 am |
OK...I have narrowed the problem down a little more.
mobstage1tbl
Code: |
anarrow = mob=Crow, the archer|zone=Goblin Fortress|room=31865|name=an arrow
ashinydullscalpel = mob=a busy surgeon|zone=Tilule Rehabilitation Clinic|room=39790|name=a shiny, dull scalpel
anidentificationbracelet = mob=a taller man|zone=Tilule Rehabilitation Clinic|room=39811|name="[=an=identification=bracelet=]"
atreatiseonvampires = name=a treatise on vampires|mob=Count Vlastrog von Hammerschlag|room=6206|zone=Zangar's Demonic Grotto
|
You can see that the bracelet has been delimited. This was done somehow by the cMud client.
After some period, a second table gets created
mobstage2tbl
Code: |
2604888286 = flags=H|name=an arrow
2604754169 = flags=M|name=a shiny dull scalpel
2604650400 = flags=IM|name="[=an=identification=bracelet=]"
2605393741 = flags=M|name=a treatise on vampires
|
As you can see, the comma from the scalpel name has been removed. Once again, this has been done by cMud somewhere, and the bracelet name has, once again, been delimited by cMud.
Code: |
$lootBag=aardbag3
$stage1List=%dbkeys(@MOB_VARS/mobStage1Tbl)
$stage2List=%dbkeys(@MOB_VARS/mobStage2Tbl)
$itemRecord=@EQ_VARS/itemRecord
#LOCAL $itemsDone
#FORALL $stage2List {
$stage2Rec=%db(@mobStage2Tbl,%i)
#IF (%ismember($stage2Rec.name,$itemsDone)) {#CONTINUE} {
#FORALL $stage1List {
$stage1Rec=%db(@MOB_VARS/mobStage1Tbl,%j)
#IF (%match($stage2Rec.name,$stage1Rec.name)) {
#T+ gatherEQdata
identify %i
#WAIT 750
#ADDKEY EQ_VARS/itemRecord mob $stage1Rec.mob
#ADDKEY EQ_VARS/itemRecord zone $stage1Rec.zone
#ADDKEY EQ_VARS/itemRecord room $stage1Rec.room
$tempID=$itemRecord.id
#DELKEY $itemRecord id
#ADDKEY MOB_VARS/mob_db $tempID $itemRecord
#ADDITEM $itemsDone $stage2Rec.name
}
}
}
}
#WIN EQ @eqTime "Created mob_db"
sort_items mob
|
Because I am testing the name (to prevent identifying duplicates until the tables are cleared), the entire script fails as the second record has had the comma removed somewhere by cMud.
It is impossible to manually delimit the name at any point. I have tried but delimiters are stripped by cMud. It is VERY frustrating. Ideally, I would like EVERY name delimited so as to eliminate the aard problem of ascii chars in names. Or some way to write a string literal without cMud messing around with things.
If I knew why it was delimiting as some points but not at others there might be a way around the problem. |
|
|
|
|
|
|
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
|
|