Defining prompt line values

Post Reply
Janalon
Posts: 11
Joined: Mon Apr 20, 2009 8:53 pm

Defining prompt line values

Post by Janalon »

My current prompt line looks like:

5568h, 3396m, 3654e, 10p, 22760en, 15020w esSilrx-

where:

h = current health
m = current mana
e = current ego
p = current power
en = current endurance
w = current willpower

and all of those letters stand for various other balances and such.

SO... I want to define values for each pulling them from a trigger. Looking at Vadi's Sipper script, I get the idea that I should use a the perl regex to:

Code: Select all

^(\d+)h, (\d+)m,
[/b]

SO... carrying that logic through, would I

Code: Select all

^(\d+)h, (\d+)m, (\d)e, (\d)p, (\d)en, (\d)w,
[/b]

but then I am not sure how to finish out the line. To complicate matters even more, whenever I attack something, I gain a value called momentum. It would look something like this:

5568h, 3396m, 3654e, 10p, 22760en, 15020w, 1mo esSilrx-

Where momentum can go as high as 5mo.

Can anyone help me how to finish this line, accounting for both 15020w, esSilrx- (which is 0 momentum) and 15020w, 1mo esSilrx- (which starts 1 momentum).

Also... how would I convert both 0 and 1-5 momentum into a "currentmomentum = "

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Defining prompt line values

Post by Caled »

First:
http://www.regexpal.com/
http://www.regular-expressions.info/

The first is a web app that helps you create and test patterns, while the second has a whole lot of information and tutorials on regex.

Your prompt pattern:
(\d+)h, (\d+)m, (\d+)e, (\d+)p, (\d+)en, (\d+)w(, (\d+)mo)? (\w+)-

If you wish to anchor it, put ^ at the beginning.
You will see I have a group inside a group. A group being anything with (grouping brackets) around it.
The ? outside of this group makes the whole group optional.
The ?: on the inside of this group stops it from being a capture group (i.e. being stored in matches[7]). This isn't necessary, but it does make it easier to count which number belongs to which capture group.

So in the script for that prompt trigger:

Code: Select all

health=matches[2]
mana=matches[3]
ego=matches[4]
power=matches[5]
endurance=matches[6]
if matches[7] ~= nil then momentum=matches[7] else momentum=0 end
pstats=matches[8]

if string.find(matches[8], "e") then equilibrium=1 else equilibrium=0 end
if string.find(matches[8], "x") then balance=1 else balance=0 end

healScript()
--^ That being a function name for a script that sips health/mana/bromide automatically. I put it here just to show you where you might put something like that into your prompt trigger.
A note:
You should create a script object, perhaps just called "Variables" or maybe you have some other way to organise it all. In this script object, put:

health=6000
mana=6000
ego=6000
power=10
willpower=30000
endurance=30000
maxhealth=6000
maxmana=6000
maxego=6000
maxwillpower=30000
maxendurance=30000
momentum=0
pstats="ex"


I picked figures that I knew would be higher than I'd ever have (I have a relatively unknown character in Lusternia that I occasionally play, so I just copied most of that directly, the only difference being the momentum part as my character is a bard).

Janalon
Posts: 11
Joined: Mon Apr 20, 2009 8:53 pm

Re: Defining prompt line values

Post by Janalon »

AWESOME! I love the way you explained the whole thing. You are so logical and clear in your description. Anyway, this prompt line accompanies a Score trigger.

Three multi-line perl regex:

Health : \d+/(\d+)\s+Endurance : \d+/(\d+)

Mana : \d+/(\d+)\s+Willpower : \d+/(\d+)

Ego : \d+/(\d+)\s+Mindset : (\w+)


where each line is a separate pattern.

Then, here is the code I was given:

Code: Select all

if scorecapturing == 1 then
	scorecapturing = 0
	maxhealth = tonumber (multimatches[1][2])
	maxendurance = tonumber (multimatches[1][3])
	maxmana = tonumber (multimatches[2][2])
	maxwillpower = tonumber (multimatches[2][3])
	maxego = tonumber (multimatches[3][2])
	currentmindset = multimatches[3][3]
	scorecaptured = 1
end
That should give the compliment to the prompt line.

Janalon
Posts: 11
Joined: Mon Apr 20, 2009 8:53 pm

Re: Defining prompt line values

Post by Janalon »

I continued your logic and defined the rest of the balance lines where:

Code: Select all

   if matches[7] ~= nil then momentum=matches[7] 
      else momentum=0 end
pstats=matches[8]
   if string.find(matches[8], "e") then bals.equilibrium=1 
      else bals.equilibrium=0 end
   if string.find(matches[8], "x") then bals.balance=1 
      else bals.balance=0 end
   if string.find(matches[8], "p") then bals.proned=1 
      else bals.proned=0 end
   if string.find(matches[8], "l") then bals.larm=1 
      else bals.larm=0 end
   if string.find(matches[8], "l") then bals.rarm=1 
      else bals.rarm=0 end
Next two questions based on your response. Knowing that I can use the prompt line balances 5568h, 3396m, 3654e, 10p, 22760en, 15020w esSilrxd- where p = prone and b=balance, how would I define a prompt line address to

if balanced NOT proned, do nothing
if prone AND no balance, do nothing
if prone AND if balanced, STAND.


Where would I put that?

SECONDLY...

I want to create an offense alias to check for two things.

IF I do not have spit balance, then do nothing
IF I have spit balance, THEN sip poison


following that, and in the same alias...

IF momentum = 0 THEN send kata perform kick0 kick1 kick2 kick3
ELSEIF momentum = 1 THEN send kata perform kick1 kick 2 kick 3 kick 4
ELSEIF momentum = 2 THEN send kata perform kick2 kick3 kick4 kick5


etc...

Any suggestions? I am just starting to learn LUA and don't quite know how to code IF / THEN / ELSEIF / END statements with confidence, but I understand the logic.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Defining prompt line values

Post by Caled »

THe multiline regex question - I can't answer sorry. I'm still new to this non-zmud scripting and I haven't played with the multi line stuff yet.


For the stand when balanced thing - this is how I do it.

Code: Select all

In the start of the prompt trigger:
local eq = "-"
local bal = "-"
local larm = "-"
local rarm = "-"

if string.find(matches[8], "e") then eq = "e" end
^ follow the logic to complete the rest like that


Then:
eqbal = eq .. bal .. larm .. rarm

if checkEqbal() == 1 then onBalance() end

In a script object:
function checkBalance()
	local x = 0
	if eqbal == "exlr" then x = 1 end
	return x
end


function onBalance()
	prone()
	fillPipes()
	lightPipes()
	doOtherCrap()
end

function prone()
	if canStand() == 1 then send("stand") end
end

function canStand()
	local x = 1
	if affs["paralysed"] == true then x=0 end
	return x
end

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Defining prompt line values

Post by Caled »

Sorry, in a hurry

if momentum == 0 then send("kata perform kick0 kick1 kick2 kick3")
elseif momentum == 1 then send kata perform kick1 kick 2 kick 3 kick 4
elseif momentum == 2 then send kata perform kick2 kick3 kick4 kick5
end

Basically, that should work.

Post Reply