[Home] [Downloads] [Search] [Help/forum]

Log on
Register forum user name Search FAQ

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Equipment analyzer/sorting plugin/script help needed!

Equipment analyzer/sorting plugin/script help needed!

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  3  

Posted by Sephiran   (16 posts)  [Biography] bio
Date Fri 31 May 2019 06:04 PM (UTC)

Amended on Fri 31 May 2019 07:09 PM (UTC) by Fiendish

Message
I'm newbie at that this just trying to learn... problem is i can't figure it out why i came here for help/guidance. Trying to may a plugin or script that sorts eq in inv by three stats then wears the best one of each piece... i got something made that detects if a number is greater or lower than a certain number here is that trigger.. not the best but i am still learning... slowly getting better.. this is in lua... A and 10 was just used as a test to see if it would work it worked...
Now how would i take this and let's say compare it to another item in my inv? or even add another stat and compare two stats against each item? my goal is to have a script or plugin i can use to automatically sort 1000's of pieces of eq and wear the best of each slot... any help/advice will be much appreciated... thanks in advance sorry if this is a stupid question or something really simple to do i may just be over thinking it... the trigger part is all i have for right now slowly adding to it as i learn. Like i said i am very new to this... This is a example of the text in game i will use to match on: Affects spellpower by 420. i just choose to match on spellpower but could also match on the whole line and use a * or this (.*?) for the number?


<triggers>
  <trigger
   expand_variables="y"
   keep_evaluating="y"
   match="spellpower by (.*?)."
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if x &gt; 10 then
  Send("a")
end</send>
  </trigger>
</triggers>
[Go to top] top

Posted by Fiendish   USA  (2,315 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Fri 31 May 2019 08:43 PM (UTC)
Message
Oof. That's quite a wall of text. I believe this is the salient question:
Quote:
Now how would i take this and let's say compare it to another item in my inv


Ok, so you made a trigger that looks at one item's spellpower value. The simplest way to do what you want would be to store that value in a variable, and then, when you subsequently look at another item, compare the value from the new item to the value that you stored. If the new item's value is better, wear that item and then store its value instead of the old one.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #2 on Fri 31 May 2019 09:23 PM (UTC)
Message
thank you, Fiendish! But, that's beyond my knowledge right now could you be so kind to give a example of what you mean? storing a variable would be like what the targeting alias dose right? think i know what you mean just not how to go bout writing the code for it. Again thank you for your answer. what bout it being random value on every piece? could i make it so it just gets the highest one out of every item i compare, or would i have to have a set value for it to work? Plus how would i add another stat to be compared alone with spellpower? new trigger, or could i do it in the same one?
[Go to top] top

Posted by Nick Gammon   Australia  (22,556 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 01 Jun 2019 (UTC)
Message
The first thing you can do is take that wildcard (the thing in brackets) and use that in your code. For example:


if %1 > 10 then
  Send("Spellpower increased by more than 10!")
end


To make sure you get a number (otherwise the comparison won't work) you could change your regular expression to:


spellpower by (\d+?)\.


I put a backslash in front of the final dot, because an unescaped dot matches any cahracter.

The \d matches a digit, and therefore \d+ matches one or more digits.




As for the rest of your question, you need to collect your inventory somehow. FAQ 37 might help.

Template:faq=37 Please read the MUSHclient FAQ - point 37.


There are ways of sorting in Lua, so you could find your entire inventory, and then sort it based on some criteria.

I suggest a bit of playing around with Lua to get more familiar with it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #4 on Sat 01 Jun 2019 01:22 AM (UTC)
Message
Thanks Nick! i'll look into tables... i thought bout them before but was hoping what i wanted could be done without them... i thought it would be something simple like for ex
lore/ID an item as soon as i pick it up then if the stats are over certain numbers put in bag... then i thought bout it. Realized even then i'd have to use a table for when it came time to actually wanting to equip the best pieces out of the ones i collected. The faq section you pointed me to will help out a lot. again, thanks.
[Go to top] top

Posted by Fiendish   USA  (2,315 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Sat 01 Jun 2019 01:58 AM (UTC)
Message
A quite good tutorial on Lua tables is http://www.phailed.me/2011/02/learn-lua-the-hard-way-tables/

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #6 on Sat 01 Jun 2019 02:20 AM (UTC)

Amended on Sat 01 Jun 2019 02:22 AM (UTC) by Sephiran

Message
thanks fiendish, i'll be sure to check it out... guess it won't be as simple as what i thought going off a post in reddit i found i thought i could just do something like this
 (.*)Affects (spellpower|intelligence|damroll) by (.*?).


then just put this in to the send box:
 If ((%3 == "spellpower" or %3 == "intelligence" or %3 == "damroll")  and %4 > 17) then
    Send("put %1 in the bag")
else
    Send("drop %1")


guess it is little trickier then that post made it seem... Thanks again to both you for your help. I've learned quite a bit since i first started.
[Go to top] top

Posted by Fiendish   USA  (2,315 posts)  [Biography] bio   Global Moderator
Date Reply #7 on Sat 01 Jun 2019 02:36 AM (UTC)

Amended on Sat 01 Jun 2019 02:41 AM (UTC) by Fiendish

Message
That's very similar to what I suggested you do before. I only gave you the link on tables because you brought it up for some reason.

You'll need to put quotation marks around any of your %1, %2, etc that aren't numbers if you want them to be parsed properly. And checking for the words "spellpower", "intelligence", or "damroll" makes no sense because your pattern already only matched on those anyway. And you'd want to compare %3 (not %4 in that pattern) against some previously seen value, not 17.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #8 on Sat 01 Jun 2019 03:05 AM (UTC)
Message
Ok thanks again fiendish. Only reason i brought up tables was because i thought that is what i would have to do at first, when i could not get what i posted that was like your idea you suggested i thought i would of needed a table to do what i wanted. Not sure i follow you with this line: "checking for the words "spellpower", "intelligence", or "damroll" makes no sense because your pattern already only matched on those anyway." i added them cause those are the other two stats i want to compare on items.. that's how the reddit post had the code i just switched the words to what i needed could not get it to work. I'll try what you said maybe i can get it to work, first time i tired it gave me an error of expected a = sign near >? and a few more i can't remember off the top of my head. this is the post where i got the code from: https://www.reddit.com/r/MUD/comments/6qis5r/help_with_mushclient_triggers/
[Go to top] top

Posted by Fiendish   USA  (2,315 posts)  [Biography] bio   Global Moderator
Date Reply #9 on Sat 01 Jun 2019 04:53 AM (UTC)

Amended on Sat 01 Jun 2019 04:54 AM (UTC) by Fiendish

Message
Quote:
Not sure i follow you with this line: "checking for the words "spellpower", "intelligence", or "damroll" makes no sense because your pattern already only matched on those anyway."


If your regular expression looks like:

 (.*)Affects (spellpower|intelligence|damroll) by (.*?).


Then by definition it will only match on lines where "%2" is one of "spellpower", "intelligence" or "damroll", so also putting

if (("%2" == "spellpower" or "%2" == "intelligence" or "%2" == "damroll")
is redundant.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #10 on Sat 01 Jun 2019 08:02 AM (UTC)

Amended on Sat 01 Jun 2019 08:09 AM (UTC) by Sephiran

Message
Maybe i've took away something i should not have here is the error i get with


<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="(.*)Affects (spellpower|intelligence|damroll) by (.*?)."
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if (("%2" and "%2" and "%2") and %3 &gt; 100) then
    Send("a")
end</send>
  </trigger>
</triggers>


[string "Trigger: "]:1: attempt to compare number with string
stack traceback:
[string "Trigger: "]:1: in main chunk


this error i get if i have "" around the %3
[string "Trigger: "]:1: unexpected symbol near '>'

i even changed the match text to have (\d+?)\. at the end and still same two errors... I have a feeling maybe i'm over complicating this?
[Go to top] top

Posted by Nick Gammon   Australia  (22,556 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Sat 01 Jun 2019 10:21 AM (UTC)

Amended on Sat 01 Jun 2019 10:23 AM (UTC) by Nick Gammon

Message
Computer languages in general do not work like that. I know what you mean, but something like:


if Tom and Dick and Harry > 40 then ...


That isn't parsed how you might think. "and" is a boolean operation, so it reads as:

If Tom "is true" and Dick "is true" and Harry "is true" and if all that is true then if "true" > 40 then ...

You really want something like:


if Tom > 40 and Dick > 40 and Harry > 40 then ...

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,556 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Sat 01 Jun 2019 10:27 AM (UTC)
Message
You will find it much easier if, instead of trying to do complex triggers and regular expressions, you take a few days to learn the basics of programming, particularly in Lua.

I don't mean that in an insulting way, but getting comfortable with how the language works, and programming in general, will be easier if you take small steps with some tutorials.

I have a couple of posts about tables on this site:

http://www.gammon.com.au/forum/?id=4903

and:

http://www.gammon.com.au/forum/?id=6036

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #13 on Sat 01 Jun 2019 05:55 PM (UTC)

Amended on Sat 01 Jun 2019 06:23 PM (UTC) by Sephiran

Message
thanks nick, and no i didn't take it as a insult and thank you for your words cause that is what i should of being doing from the start is the basic and simple stuff first to learn not complex like i jumped into. I'll do what u suggest that's my problem normally i tend to try complex things and just learn as i go. I'm the type to learn better if shown/video or trial and error... i don't know it seems strange but that's how i am.. thanks again to both you for your help and understanding.
[Go to top] top

Posted by Sephiran   (16 posts)  [Biography] bio
Date Reply #14 on Sat 01 Jun 2019 06:37 PM (UTC)

Amended on Sat 01 Jun 2019 08:38 PM (UTC) by Sephiran

Message
i got it working had to remove (.*) from start of trigger

is there a way to make it so it only puts the item that's lored in to something or dropped? by name or something? i tried to just have put 1. box but if an item matches on more the one stat it puts not only the item that i'm loring into a box but the other two after it that is in my inv. ex from game:

 if an item has two like this Affects intelligence by 402.
put 1. love
Affects damroll by 1251.
put 1. love


then it puts the item i IDed into a box like: You put (Spiffed) A Wyldfae's chilled polearm of rain calling in BRoM'S SaCK oF LoVe.

but then it also put the next item that became first in my inv into box: You put (Spiffed) Soratami Seer's glittery sword of crack in BRoM'S SaCK oF LoVe.

not all of my eq is going have the same name..
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


6,939 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]