Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Thu Mar 10, 2016 9:08 pm   

Catpuring ansi in grey text
 
I have a spell in my mud that uses a spell that requires using specific random letters in a message that are ansi colored inside grey text.

I have several captures, and after the inital casting, the 2nd and 3rd messages are a random message of 5 types.

1st line of spell ->
You call forth a word of great power, invoking the prime nature of your
magic. Crumbling away from the corpse, the soul of the creature is
released in the form of a giant death's head that flies freely into the
room, leaving behind it a great trail of radiant energy!

2nd and 3rd lines are random from the next lines->

Diving around (name), the terrifying death's head growls deeply.
Snarling at (name), the skull gnashes its teeth in anger.
Seething with venomous anger, the death's head howls at (name).
The ghostly skull races around the room, circling (name) menacingly.
Screaming in rage at (name), the skull races around the room.

The monster name is included in the 2nd and 3rd line of spell, and the random ansi letters can be randomly in the monsters name.

To operate the spell you cast the initial spell, then after each successful cast with the ansi letters you are able to cast the next part.
What would be the best way to capture this into a variable, i can use a alias/macro to assimilate needed letters and cast the next part of spell?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4550
Location: Pensacola, FL, USA

PostPosted: Thu Mar 10, 2016 9:25 pm   
 
Sounds like you need a multi state trigger.
The color of the text is only relevant to you, unless which segment is colored changes up each time.
As it stands, I'm not sure which part of the messages you have shown is the part you need to capture.

To my knowledge you can force a pattern to match a certain color.
But you cannot necessarily determine which characters are in a different color, after the fact.
_________________
Discord: Shalimar#3679
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4550
Location: Pensacola, FL, USA

PostPosted: Thu Mar 10, 2016 9:36 pm   
 
Well... short of an ansi trigger for ever color variation.... of every monster.

If you check the Ansi option of the trigger before pasting in test from the buffer, it will include the ansi tags from the mud
And if you do it with your priorities right, the ansi triggers will fire and give you the letters before the spell segment trigger fires, and it will always be up to date.
_________________
Discord: Shalimar#3679
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Thu Mar 10, 2016 9:44 pm   
 
You call forth a word of great power, invoking the prime nature of your
magic. Crumbling away from the corpse, the soul of the creature is
released in the form of a giant death's head that flies freely into the
room, leaving behind it a great trail of radiant energy!

Diving around (name), the terrifying death's head growls deeply.
Snarling at (name), the skull gnashes its teeth in anger.
Seething with venomous anger, the death's head howls at (name).
The ghostly skull races around the room, circling (name) menacingly.
Screaming in rage at (name), the skull races around the room.

these are the only lines that need to be checked for ansi code, however the monsters name will need to be checked to but where name is the monsters name is always there.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4550
Location: Pensacola, FL, USA

PostPosted: Thu Mar 10, 2016 9:45 pm   
 
So only one of the characters in (name) is changing colors?
_________________
Discord: Shalimar#3679
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4550
Location: Pensacola, FL, USA

PostPosted: Thu Mar 10, 2016 9:55 pm   
 
I see it as several triggers for each monster to capture the letters, and then the master state trigger for the spell that concatenates the letters together in a variable as you go along, and spits out the finished string at the end... or each as you go, however it is needed.

The tedious part will be collecting all the ansi variants for each monster.
_________________
Discord: Shalimar#3679
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Thu Mar 10, 2016 10:01 pm   
 
Hrrrm not really needed to remember what monster name, just need a trigger that will find all the ansi in a trigger after the anchor trigger fire...

so the Diving around (*), the terrifying death's head growls deeply. <- this will be the anchor trigger, and i need to know how to strip ansi letters from it.

#TR {Diving around (*), the terrifying death's head growls deeply.} #con {You strain as you reel in the power of the prime spell!} {ansi collecting code}

sorry i don't think i mentioned this, the spell is in order, from 1, 2, 3... each part requires the ansi code.. so after each part i need the code to get to the next in order to cast the spell.
So the examples will all work for anchor triggers to assimilate the needed ansi code, then in the script part, i'd have the script to enter the ansi letters and it would move to the next.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4550
Location: Pensacola, FL, USA

PostPosted: Thu Mar 10, 2016 10:31 pm   
 
I understand what you want, but I know of no other way to get the results short of having known what the possible results are beforehand.
On the plus side, perhaps your mud won't use every combination of every monster name.

Perhaps one of the other users can think of a better way to pick out color changing characters.

You will need to manually make a trigger as follows, via the GUI Editor:

Highlight just the new monster name ansi variant on the buffer
Open settings
New trigger
Check ansi trigger in the options panel
Set priority to 1
paste to the pattern line
The script should be as follows:
#RAISE spellString {whatever the letters are}

And that's it.
Then you can define the matching #EVENT that just got passed your string and do with it what you will.
Something like:

#EVENT spellString {
spellString=%concat(@spellString, %params)
#CO darkslategray //Just so you can tell which variants are getting captured already
}

I prefer #EVENTs to #ALIASes, because if you disable them, anything that fires the event will now do nothing, anything that fired the alias, is still sending you callword to the mud though.

Then your spell trigger just needs to reset @spellString once it uses it:

spellString=""
_________________
Discord: Shalimar#3679
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Mar 10, 2016 11:52 pm   
 
If you use an ANSI trigger as shalimar suggested, that would also let you capture the raw ANSI sequences if you use a wildcard, so it should be pretty easy to pick out the colored letters. A full example with the color codes included would help a lot though. Could you post a few lines from the script debugger window with the ANSI codes option enabled, please?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Mar 11, 2016 4:07 am   
 
As both Shalimar and Daern have said you will need to use a trigger with the ANSI option enabled. Shalimar is also on the right track that you should employ multistate triggers.
If there are are clear lines that surround the lines when you must capture ANSI information then you can use those for the specific state. Otherwise the capture will need to use a Loop Pattern type. In both cases a pattern of "^(*)$" will be needed to capture all the ANSI codes within the line.

Once you have a trigger correctly capturing actionable lines and the ANSI codes I would suggest %subregex as the best method to parse the line.

As was suggested you will need to provide more specific examples for us to produce more specific answers.

I seem to recall from someone's post (possibly yours) that you have to collect all the colored letters and send that to the MUD to move to the next spell step. That really is the easy part, knowing what lines contain that information is the hard part. Think through the entire process and you will find that it is often beneficial to start with an #ONINPUT that recognizes your initiation of a series of actions.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Sun Mar 13, 2016 12:31 am   
 
You call forth a word of great power, invoking the prime nature of your
magic. Crumbling away from the corpse, the soul of the creature is
released in the form of a giant death's head that flies freely into the
room, leaving behind it a great trail of radiant energy!

#TR {You call forth a word of great power, invoking the prime nature of your} {#cond {^(*)$} {#EVENT spellString {
spellString=%concat(@spellString, %params)
#CO darkslategray //Just so you can tell which variants are getting captured already}
} {looplines|Param=3}
i would click "ansi trigger".

the above text is the first cast of the spell... and any letter could contain ansi letter, which is why i need to strip from the parahgraph, and store in a variable, and type: invoke prime "ansiletters" (no quotes)

the next part of spell (2nd and 3rd) are random as well but from a list of 5 messages... The monster name is always part of this message, but always in the same place in each message, so i could easily put (%w) to cover that portion.
Diving around (name), the terrifying death's head growls deeply.
Snarling at (name), the skull gnashes its teeth in anger.
Seething with venomous anger, the death's head howls at (name).
The ghostly skull races around the room, circling (name) menacingly.
Screaming in rage at (name), the skull races around the room.

these are the 5 random messages after fist ansi "code" has been inputed.
So each one will have to be a seperate trigger, and have the way to strip ansi from it
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4550
Location: Pensacola, FL, USA

PostPosted: Sun Mar 13, 2016 7:29 pm   
 
Okay, you need to slow down a bit.
What you want has been made clear (to me at least) so reiterating it over and over is not helping us move forward.

You are making several mistakes already in your rush to cobble things together:
1. the #EVENT call should go on the command line itself, you should not have to redefine it, just #RAISE it in your settings
2. the #COND call should go on the line after your #TRIGGER, not inside of it
_________________
Discord: Shalimar#3679
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Mon Mar 14, 2016 1:07 pm   
 
Sorry, i didn't meant to make this look like i knew what i was doing, i was just reiterating because as far as i could tell people were asking what way I wanted things to do...

And thank you again for answering, I really do appreciate all the help here. I just don't really know these functions much at all, I'm used to bare boned triggers and such as the correct methods are unknown and sometimes quite beyond me.

But ok, I will start witht hat shalimar, thanks again.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Mar 14, 2016 8:25 pm   
 
As I said in a previous post, start with #ONINPUT. You will have to correct the text of the command that starts the spell. It has been a long time since I did an ansi capture, but I think I remember everything. Copy and paste the following into the command line then press enter. Then disable any other triggers you have that are supposed to react to these lines.
Code:
#ONINPUT "primeSpell" {^invoke prime %w$} {}
#COND {} {#IF (%stripansi(%line)="You call forth a word of great power, invoking the prime nature of your") {
 spellString=%line
 #STATE primeSpell 2
}} {looplines|param=50|ansi}
#COND {} {spellString=%concat(@spellString,%line)} {looplines|param=3|ansi}
#COND {*.501} {#SHOW "this still needs to be written but here is where the second invoke will go, copy and paste the command line contents to the forum"
#INPUT {%replace(@spellString,%char(27),"\033")}
} {alarm}


After you run that trigger once I will need what it puts in the command line pasted into the forum so I can see how the ansi codes come up. If it is possible to have 2 or more colored letters next to each other then it would be best to post that decoding. If there are no ansi codes captured into the spellString variable then I will have to go back and look up how to do it.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net