Alias and Targeting in Achaea

Kyle
Posts: 30
Joined: Fri May 14, 2010 5:39 am

Re: Alias and Targeting in Achaea

Post by Kyle »

Achaea.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Alias and Targeting in Achaea

Post by tsuujin »

It's been some ten years since I played Achaea, so I can't provide you with what you need offhand.

You're going to need to create a table containing all of the armor you want to wear (if you're not trying to just do a re-wear of something forcibly taken off). Then you're going to need to determine if you have balance or not. The prompt provides this information regularly, you can parse it from there. From there, it's a simple process or wearing it when you do have balance and not trying when you don't.

Of course, if you could provide lines of all relevant text, I may be able to help you out.

WillFa
Posts: 19
Joined: Mon May 10, 2010 4:16 pm

Re: Alias and Targeting in Achaea

Post by WillFa »

tsuujin wrote:
Wennef wrote:
tsuujin wrote:pattern: ^sst (\w+)$
you can substitute "sst" with whatever you want

body: send(string.format("strike %s sternum",matches[2]))
How is this different from:
send("strike " .. matches[s] .. " sternum") is it better or quicker?
it's really not different, except that using string.format makes things easier to read in large strings so I've gotten into the habit of using it for everything. using the concatenation operator ("..") works fine but looks clunky and makes it harder to debug later on in a lot of circumstances.

I don't believe there's much of a speed difference one way or the other. The concatenation operator does fewer processes on the string so would likely be faster, but the degree of which would be infinitesimal.
They are different. Lua strings are immutable, so each concat operation allocates a new string with both values. Since string.format works from the C side of things, it just uses a single buffer to assemble the final string.

Take a look at http://www.lua.org/pil/11.6.html

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Alias and Targeting in Achaea

Post by tsuujin »

Yeah, over thousands of concurrent concatenations the performance issue of concatenation becomes a problem. I've dealt with this before, with Lua taking several minutes to complete what I thought to be simple concats. That said, there's only a couple of operations per string if you only concatenate once or twice and the memory usage isn't horrible.
I haven't seen any recent benchmarks, but I know back in the day there was some concern over the speed of passing information out of the lua interpreter to be handled by external functions. I have to imagine that this is no longer an issue (if it ever really was to start).

However, for the Lua novice (to whom my comment was directed) it really doesn't matter and is simply personal preference. I like string.format, because I can see the string without being broken down into small segments over, potentially, multiple lines. That said, I still use the concat. operator for simple joins from time to time.

Kyle
Posts: 30
Joined: Fri May 14, 2010 5:39 am

Re: Alias and Targeting in Achaea

Post by Kyle »

I'm just trying to employ something that makes me re-wear my armor when it's forcibly taken off.

You remove a suit of ring mail.

A trigger that would see that, understand when I have balance, and re-wear as soon as possible.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Alias and Targeting in Achaea

Post by tsuujin »

ok, here's what you want to do. Create a trigger for your prompt, and use regex to parse out the last few characters where your balances are stored.

Here is my prompt trigger for Midkemia Online. It won't work for you, but you can use it as a reference:
Code: [show] | [select all] lua
^\d+h, \d+e, \d+f, \d+m(?:, \d+g)? ([xbdp]*)\-?(?: A:\d+\% \-)?(?: (.+)\: (\S+) -)?$
i use this to figure out if I have balance:
Code: [show] | [select all] lua
if string.find(matches[2],"b") then bals:gain("physical") else bals:lose("physical") end
if string.find(matches[2],"x") then bals:gain("defensive") else bals:lose("defensive") end
Play around with that for a bit and see if you can get it working for you, or ask for more help if you need it.

then, for your rewear trigger, you're going to check to see if you have balance when you get the item removed, and if you do you're going to simply rewear it. Otherwise, you're going to set up a tempTrigger (or something else of your choosing) to rewear it when you do have balance.

Kyle
Posts: 30
Joined: Fri May 14, 2010 5:39 am

Re: Alias and Targeting in Achaea

Post by Kyle »

I'm not even sure what command to use that identifies I've regained balance or sees that I've regained balance so that it re-wears the armor.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Alias and Targeting in Achaea

Post by tsuujin »

Kyle wrote:I'm not even sure what command to use that identifies I've regained balance or sees that I've regained balance so that it re-wears the armor.
your balances are at the end of your prompt. it's probably an "e" and an "x" that appear when you do have balance. The idea is to capture your prompt with a trigger and basically ask if you have balance of not.

Whenever you regain balance, you'll see a line from the MUD that states you have regained it. you can use this to determine that you do, indeed, have balance again.

Kyle
Posts: 30
Joined: Fri May 14, 2010 5:39 am

Re: Alias and Targeting in Achaea

Post by Kyle »

I think I may have found a solution. I setup a trigger that works off a timer and immediately puts on the armor just as I gain balance.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Alias and Targeting in Achaea

Post by tsuujin »

Kyle wrote:I think I may have found a solution. I setup a trigger that works off a timer and immediately puts on the armor just as I gain balance.
But what if you already have balance when you lose the armor? It'd be a waste not to just wear it right away.

Post Reply