Artscrafter
New member
A clannie of mine is looking to start up a smithing bot for our clan. The bot would go something like this:
(Pseudo)
Question 1: How does one determine whether a given player is in the active character's clan? I'm aware that putting $clan into a buffbot's whitelist will allow all clan members to partake of that without the host having to constantly update, but is there any equivalent data type or method for a more general use?
Question 2: There's a handy extract_item(string) method that I've looked into, but the data type it returns is terrible for how I'd be using it - it's an array of ints where the index is a particular item. For example, if you parse a string that indicates receipt of two blue pixels, the way to find this out is to look at Returned_Array_Var[$item[blue pixel]] and see that its value is 2. Consequently, using this method to detect any of a large possible set of different items implies that I would have to check every possible smithable item's index and look for non-zero values. Is there any better way to do this?
Question 3: Is there any way to check whether two specific items can be smithed into something and what they make? Apart from checking creatable_amount results, since I want to allow the possibility that more than one request comes in between iterations of checking messages and I don't want one person's ingredients to interfere with another. At the moment I'm looking at writing a massive recipe lookup method that takes two items as inputs and checks them against a long, hardcoded string of if statements to return one item or a null - is there a better way to do this?
(Pseudo)
Code:
While (true) {
Check messages; parse kmails into an array of strings, one per kmail.
For each kmail string:
{
Verify that the sender is a member of the clan. // Question 1
If not: { Parse items and return them to the sender. }
Else:
{
Parse items. // Question 2
Find out what can be created from these items. // Question 3
Create item(s) and send the finished product(s) back.
}
}
}
Delete messages.
Pause for 60 seconds.
}
Question 1: How does one determine whether a given player is in the active character's clan? I'm aware that putting $clan into a buffbot's whitelist will allow all clan members to partake of that without the host having to constantly update, but is there any equivalent data type or method for a more general use?
Question 2: There's a handy extract_item(string) method that I've looked into, but the data type it returns is terrible for how I'd be using it - it's an array of ints where the index is a particular item. For example, if you parse a string that indicates receipt of two blue pixels, the way to find this out is to look at Returned_Array_Var[$item[blue pixel]] and see that its value is 2. Consequently, using this method to detect any of a large possible set of different items implies that I would have to check every possible smithable item's index and look for non-zero values. Is there any better way to do this?
Question 3: Is there any way to check whether two specific items can be smithed into something and what they make? Apart from checking creatable_amount results, since I want to allow the possibility that more than one request comes in between iterations of checking messages and I don't want one person's ingredients to interfere with another. At the moment I'm looking at writing a massive recipe lookup method that takes two items as inputs and checks them against a long, hardcoded string of if statements to return one item or a null - is there a better way to do this?