Quick Question regarding placement of text

Post Reply
AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Quick Question regarding placement of text

Post by AlterAeonUser »

I have a trigger that calculates the number of practices I can get as well as the amount of experience needed for the next practice that matches on this:
You have 18262052 experience points.

To see the lost exp hall of fame, try the 'exp lost' command.
My trigger works flawlessly so my only issue is, when I type "exp" (to show the pattern to match) it then shows this:
You have 18262052 experience points.
'You should be able to get 2 practices'

'You have 662052 till your next practice'

To see the lost exp hall of fame, try the 'exp lost' command.
So, my question is: How can I get it to put the displayed text BELOW the other line?

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: Quick Question regarding placement of text

Post by phasma »


User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Quick Question regarding placement of text

Post by Vadi »

Which should be below which?

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Quick Question regarding placement of text

Post by AlterAeonUser »

The text that is inserted after the first pattern, I want inserted after the second pattern.

So, instead of this:
You have 18262052 experience points.
'You should be able to get 2 practices'

'You have 662052 till your next practice'

To see the lost exp hall of fame, try the 'exp lost' command.
I want it to show like this:
You have 18262052 experience points.

To see the lost exp hall of fame, try the 'exp lost' command.

'You should be able to get 2 practices'

'You have 662052 till your next practice'

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Quick Question regarding placement of text

Post by AlterAeonUser »

(had this wrote up earlier and forgot to post it, but this is what the trigger code looks like)
Either I don't' understand how the moveCursor() function works, or I'm doing something wrong. Either I break the trigger or it doesn't move the cursor.
Pattern to match:
You have (\d+) experience points. <regex>
To see the lost exp hall of fame, try the 'exp lost' command. (begin of line substring)
Code to run on match:
Code: [show] | [select all] lua
PracExp=8800000
CurExp=tonumber(matches[2])
NumberPrac=0

moveCursor(0, getLineNumber()+5)
if CurExp>=PracExp then
  NumberPrac=CurExp/PracExp
  string.format("%1.0f",NumberPrac)
  if NumberPrac==1 then
    display("You can get 1 practice")
  else
    display("You should be able to get " .. string.format("%1.0f",NumberPrac) .. " practices")
	end
else 
  ExpNeed=PracExp-CurExp
  display("You Need " .. ExpNeed .. " experience till your next practice.")
end

NumberPrac=string.format("%1.0f",NumberPrac)
NextPrac=CurExp-(PracExp*NumberPrac)
display("You have " .. NextPrac .. " till your next practice")
I'm obviously not using it correctly, but with what I read, this: moveCursor(0, getLineNumber()+5) should move the cursor 5 lines down and then do the rest of the code, but it doesn't.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Quick Question regarding placement of text

Post by Vadi »

There's a variety of ways to do this. One would be to setup a multiline trigger - enable the AND checkbox, set the delta to 1. In the box 1 for a pattern (after box 0), type in 1 and select line spacer.

Your matches[2] will become multimatches[1][2], and otherwise the echoes should follow the second line.

The other way is to setup a tempLineTrigger().

Edit: unless you enabled multiline in your trigger, putting in two patterns means the code will go off when either of them matches. In your case it's going off twice, but the second one is probably failing because the pattern doesn't capture anything into matches[2].

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Quick Question regarding placement of text

Post by AlterAeonUser »

Had to set the delta as 3 instead of 1, but otherwise, it seems to work. Thank you Vadi. Once I got it working, decided to switch to cecho() instead of display() because I didn't like the ' ' surrounding the text. Also, cecho() let me color them so they are a tad bit easier to read.

Thank you so very much for helping a noob out.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Quick Question regarding placement of text

Post by Vadi »

Awesome!

Post Reply