Boolen compare trigger?

Post Reply
Posts: 2
Joined: Wed Oct 04, 2017 2:43 am

Boolen compare trigger?

Post by duckeybones » Wed Oct 04, 2017 3:02 am

So I'm kind of a schlub when it comes to coding(I do some SQL stuff for work but outside of that, not too familiar with anything else, sadly).

What I'm trying to do is build an IF statement to look at a string in my score(Lifeforce: 100 / 100) and compare the first number to the second number and then initiate a trigger if the first number matches the second number.

I've got a super rudimentary set of triggers gimmicked up right now and a timer set for every minute or so to throw the Score command up and it sorta works, but it feels super inelegant and clunky and requires that the Lifeforce string stays the same(which it won't given I'm setting up triggers to stat train, which is completely allowable in this MUD).

Example here is that I've got it setup with multiple triggers to go north and sleep when it sees the string indicating I cannot train anymore, then the timer throws Score in there every minute until it sees Lifeforce [100 / 100] and then that will wake me up, move me south, and throw the command "gravtrain int 1000" until the process starts again, but this prevents me from training stats that would increase lifeforce.

I'm just kind of at a loss here and can't figure out exactly what to do. I feel like it should be possible given some of the reading but I'm not sure how to implement it. Would anyone be able to help me out?

User avatar
Site Admin
Posts: 94
Joined: Mon Mar 21, 2011 9:36 am
Discord: keneanung#2803

Re: Boolen compare trigger?

Post by keneanung » Fri Oct 06, 2017 2:04 pm

You can use a backreference in a perl regex for that. Your trigger would look like "^Lifeforce \[(\d+) / \1\]$" (without quotes) and trigger type set to "perl regex".

Posts: 2
Joined: Wed Oct 04, 2017 2:43 am

Re: Boolen compare trigger?

Post by duckeybones » Sat Oct 07, 2017 3:22 am

Regex, my mortal enemy, we meet again. /fistshake

Thank you! I didn't even bother thinking about that due to a deep wish that anything Regex was a person I could punch in the face.

Edit: I tried it, didn't work. Ran it through a Regex notepad and it was throwing the error on the open / in the middle, so I adjusted it as such, also including the : in Lifeforce: [# / #]

^Lifeforce: \[(\d+) \/ \1\]$/g

I also tried it without the : and no dice.

Posts: 1099
Joined: Wed Apr 03, 2013 2:19 am

Re: Boolen compare trigger?

Post by Jor'Mox » Mon Oct 09, 2017 12:08 pm

Okay, so just looking at your explanation vs the pattern, it seems likely that the Lifeforce bit isn't the entire text on that line, so the ^ and $ parts of your trigger are probably the problem (^ stands for the beginning of the line, and $ stands for the end of the line). I would just try this:
Lifeforce: \[(\d+) \/ \1\]
And if that doesn't work, then you could do this:
Lifeforce: \[(\d+) \/ (\d+)\]
And then do the comparison of the two numbers in code, rather than in regex.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 15 guests