Checking if a line of text is there or not

Post Reply
Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Checking if a line of text is there or not

Post by Guilend »

Ok, I have an ability to check a person defences, what i was wondering is if it's possible to search for a line a text and if it's found you can then make it do things, like echo.


You look carefully at Jade, Jewel of the Forest.
Your physical armour alone has a strike-reduction value of 95%.
Your combined armoury amounts to 95% possible strike-coverage.
You are wearing magic enhancers of Master potency.
You have limited immunity to cold attack.
You have enhanced the power of your adrenalin.
Your death will be prevented by your consumption of olvar.
You have quaffed a potion of life-giving.
You have limited extra-sensory perception.
You sparkle celerity but your supernatural sight-and-sense is imperfect.

This is the text, lets say just say I want to cast a freezing spell, so I hit my freezing spell alias, it then checks the targets defences, which is inspect <target> then if the line "You have limited immunity to cold attack." is true, then to echo like cold resist up and cast the freezing spell, if that line of text isn't there, it's false and it will just cast the freezing spell.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Checking if a line of text is there or not

Post by Jor'Mox »

Since you are casting the spell anyway, does it matter if the echo appears after casting begins?

If not, I would just have the alias activate trigger to look for the appropriate text, a timer to turn the trigger off after an appropriate time (1 second or so would be plenty usually), and sends the appropriate commands. Then if the trigger fires, it sets some variable so that when the timer goes off, it shows the echo you want. You could also use a trigger in place of the timer, that detects something like a blank line or your prompt, both good indicators you are done looking at whoever, and possibly a good place to show the message you want.

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Checking if a line of text is there or not

Post by Guilend »

the idea is to not cast the spell if the defence is there, it would be a waste of equilibrium if the defence is there. Which is why I was hoping to make this setting. I mean, unless i can figure something like this, then this ability is kind of pointless since you will be looking at like up to 20+ lines of text and there is no way you can see that during a fight and find the defence you are looking for lol, i tried using echos at the end to tell me if it was there, but in a fight it was hard to see it after a wall of text zooming by.

I was thinking though, I might just use a chain trigger, then maybe a timer in the alias i want to use it in. Not sure how that will work out, i haven't tried it yet.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Checking if a line of text is there or not

Post by Jor'Mox »

Okay, so what you are describing now makes a lot more sense than what you described in your first post, and I would approach it as follows.

First, your alias enables a trigger and sends the command to look at the person and set your tracking variable to false. Second, you will have a trigger that detects the start of you looking at someone (the "You look carefully at" line), and it turns on two more triggers and disables itself. Next, your trigger to catch the specific line of text (the "You have limited immunity to cold attack" line) is there to toggle your variable to true. Third, your closing trigger (which can trigger off a blank line) checks the tracking variable and either casts your spell or makes an echo telling you they are protected, and also disables both triggers.

Edit: Reasonably, given that you are probably eventually wanting to be able to test for multiple conditions, I would make the triggers generic, in that they test for all of the conditions that you might care about, regardless of what enables them, while your aliases have a second variable that they set that your triggers use to determine which condition to check for and which command to send if the condition is in whatever state you want it to be in. In that case, I would also make the starting trigger be the place where all of the check variables are reset, rather than doing that in the alias, so that any alias you make to act in essentially this way just has to set a single variable, enable the one trigger, and send the look command, and the triggers take care of the rest.

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Checking if a line of text is there or not

Post by Guilend »

Thanks. I just woke u and my brain only followed parts of that lol. Someone sent me a trigger chain (still trying to figure out how to make it work) but I will get back on here later and see what i can do. I will just have to go through what you just wrote piece by piece as i make the stuff, but i think i have an idea of what you are telling me, but my groggy brain is just no piecing it together just yet lol.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Checking if a line of text is there or not

Post by Jor'Mox »

To help with that, here is some pseudo-code for the various pieces I described in my above post:
Code: [show] | [select all] lua
-- Code for the alias
enableTrigger("looking trigger")
check = "freeze"
target = matches[2]
send("look " .. target)
Code: [show] | [select all] lua
-- Code for the "looking trigger"
resistances = {}
enableTrigger("cold immune trigger")
enableTrigger("blank line trigger")
disableTrigger("looking trigger")
Code: [show] | [select all] lua
-- Code for the "cold immune trigger"
resistances.cold = true
Code: [show] | [select all] lua
-- Code for the "blank line trigger"
disableTrigger("cold immune trigger")
disableTrigger("blank line trigger")
if check == "freeze" then
    if resistances.cold then
        echo("target is resistant to cold damage")
    else
        send("cold blast " .. target)
    end
end

Post Reply