I read through all the previous posts and I don't think this has been addressed, but maybe it has. Is there any way to store or refer to the match criteria of a trigger in a function? So if I have a trigger that catches the criteria:
"Foobar slaps you in the face."
is there a way of accessing that string so that I can take any given substring (say, "Foobar") and use it in a function?
I read through all the previous posts and I don't think this has been addressed, but maybe it has. Is there any way to store or refer to the match criteria of a trigger in a function? So if I have a trigger that catches the criteria:
"Foobar slaps you in the face."
is there a way of accessing that string so that I can take any given substring (say, "Foobar") and use it in a function?
Yes, I think. I could be reading it wrong but I am very sure you can do this.
I wish there was a way to download it similar to mudlet, or at least I dont like opening settings and such in another tab, Id prefer it to be in a window
I was always a little confused as to how to set up delays on it... But I'm not very savvy with this stuff at all, so that may be why... I read the manual and tried what it suggested and it didn't work. (this was about two months or so ago though)
Assuming you just mean "do something in 2.5 seconds" or something similar, you can do something as simple as this (in a function or trigger's script block):
setTimeout(function () {
// Do something useful here //
send_direct("em drops it to the flo'."); // Send a command to the game //
print("You just dropped it to the flo'.", "red"); // Print something locally (in red) //
run_function("apply_frost"); // Cause it's getting hot in here //
}, 2500); // That's 2500 milliseconds, or 2.5 seconds //
Likewise, if you want to run something every 2.5 seconds, just do something like this:
var health_timer = setInterval(function () {
// Check your current health, send a sip command if necessary, etc. //
}, 2500);
Then, if you want to stop that function from running every 2.5 seconds, run:
clearInterval(health_timer);
Let me know if that helps clear it up (and I'll be updating the manual pretty extensively soon -- I'll try to make sure this is covered there).
- Cromm
So I can just put the bolded directly into the function window? Sorry I am totally a newbie at this.
I am really green at this can someone please very basically explain how to create a timed action.that responds to a trigger for the IRE client? I am very inexperienced so it needs to be explained carefully. For pvp I would much rather just have my balance recovery times so I can line up several commands during combat. Thanks for the patience with my inability to grasp this.
Sorry for the absence, folks. Lemme get some answers out.
@Riplakish - You should be able to just copy/paste the bolded part into the script section of a trigger. Just change the 2500 to whatever timing you want (just remember it's in milliseconds). Then, within the setTimeout (after the // Do something useful here // bit), add whatever code you want to execute.
@Murashka - Should be the "args" variable (try console.log(args) to see what you'll have to work with in a trigger script).
@Jaiko - It's been through many iterations, but currently, the client is built atop a customized version of the Websockify library (a Python backend with some basic wrapping of the native javascript websocket protocol). Websockify is at: https://github.com/kanaka/websockify
@Cidusii - Not sure what you mean... There are checkboxes and settings for highlighting/gagging in the regular trigger interface within the settings window. Is that not what you're after?
@Eddard - Yeah... not entirely feasible to have a downloaded version as is. And we've tried the Settings window within the interface before, but it's a PAIN to maintain across the browsers. Simpler and more robust to have it in a separate tab for now. Sorry!
I think that's everyone. Let me know if you have any other trouble or questions!
I'm just wondering if those functions are also available for use in functions and custom scripts etc. . I'm also curious if there's a way to parse what we input text like we do for the output text to the client with the message.match() function as shown in the IRE_AutoSipper source code.
I read through all the previous posts and I don't think this has been addressed, but maybe it has. Is there any way to store or refer to the match criteria of a trigger in a function? So if I have a trigger that catches the criteria:
"Foobar slaps you in the face."
is there a way of accessing that string so that I can take any given substring (say, "Foobar") and use it in a function?
Put this in the trigger box: (.+)\ slaps you in the face.
Then in the function box at the bottom you will have to put your code. the substring is args[1]. args is the entire sting AND the substring. and args[0] is just the entire string.
parse: function (event, message) {
if (message.match(/^The (elixir|tonic) heals and soothes you\.$/gm) ||
message.match(/^Your mind feels stronger and more alert\.$/gm) ||
message.match(/^The (elixir|tonic) flows down your throat without effect.$/gm))
{
IRE_AutoSipper.can_sip = false;
}
if (message.match(/^You may drink another health or mana elixir or tonic\.$/gm))
{
IRE_AutoSipper.can_sip = true;
IRE_AutoSipper.check();
}
How do I access the information bracketed? Or the full string itself? I've tried args[0] and args[1], but they're undefined. I've also tried message.args, parse.args, IRE_Autosipper.args, IRE_Autosipper.parse.args etc. to no avail. I can get it working with the trigger boxes, but not functions like that.
You'd need to use the RegExp.exec function if you wanted access to the groups from the regular expression. Something like this:
parse: function (event, message) {
var groups;
if((groups = /^The (elixir|tonic) heals and soothes you\.$/gm.exec(message)) || ...) {
// use groups[0] for the entire line, groups[1] for the first group, etc
}
}
Woot! Thanks heaps @Antonius! Looks like a long night of coding ahead of me soon to change everything to that!
Edit: Uh oh, new problem! Now the word args pops up in red each time it sees that line.
Second edit: Nevermind the new problem was unrelated it seems
0
TeghaineCape Town - South Africa - Africa (thatcontinentthatlookslikesouthamerica)
I realise I'm unmasking my complete idiocy here, but I really need to know, and I'm quite a fast learner. I want to be able to create my own system In html5. Something that will suit my play style. Only problem is, I have no idea how to code functions. As it is, I've got a pretty decent triggers system for anything I can think of, but I would like more. Also...
Hiroma tells you, "I just got to listen to someone complain about your deadly axekick being the bane of their existence." Archdragon Mizik Corten, Herald of Ruin says, "Man, that was a big axk." Hellrazor Cain de Soulis, Sartan's Hammer says, "Your [sic] a beast."
I'm helping a novice here setting up some anti-theft in HTML5, and I'm puzzled.
We're trying to set an alias that captures the argument after "buy", and sends "take gold from pack" followed by "buy (argument)". Anyone know how to do this with the tiny line?
Slight mixup with your parenthesis at the end of the if condition. get_variable("stunned"=="0") should be get_variable("stunned")=="0"
EDIT: To address the question about pipelist, you'll need to escape the actual brackets in the pattern, so: pipe(\d+)\s+slippery elm\s+\(\s+(\d+) puffs\)
The \s+ are one or more whitespace characters (spaces). The \( and \) means treat it actually as a bracket in the string, rather than indicating that it's part of a group in the regular expression.
Slight mixup with your parenthesis at the end of the if condition. get_variable("stunned"=="0") should be get_variable("stunned")=="0"
EDIT: To address the question about pipelist, you'll need to escape the actual brackets in the pattern, so: pipe(\d+)\s+slippery elm\s+\(\s+(\d+) puffs\)
The \s+ are one or more whitespace characters (spaces). The \( and \) means treat it actually as a bracket in the string, rather than indicating that it's part of a group in the regular expression.
That might work, thanks!
edit: changed it, now I get
Error in Function [onGMCP]: SyntaxError: Unexpected identifier
In that code args is an object, so trying to concatenate it with a string will implicitly call its toString() function. The result of calling toString() on an object that doesn't explicitly declare its own version of that function is [object Object]. You probably want to be using something like send_direct("give " + args[1], false); instead but I'm not familiar enough with the HTML5 client to be positive about that.
Also, minor semi-related rant: I hate, hate, hate writing posts that include code on the forums; I keep wanting to use Markdown syntax and then remember it's not supported (because we can't have nice things, apparently).
Comments
(.+)\ slaps you in the face.
Then in the function box at the bottom you will have to put your code. the substring is args[1]. args is the entire sting AND the substring. and args[0] is just the entire string.
So say I copy pasted http://client.achaea.com/reflexes/achaea/ire_autosipper.js into a new function.
The parse function there is as follows:
Results of disembowel testing | Knight limb counter | GMCP AB files
Edit: Uh oh, new problem! Now the word args pops up in red each time it sees that line.
Second edit: Nevermind the new problem was unrelated it seems
Also...
..
What is regex...
Archdragon Mizik Corten, Herald of Ruin says, "Man, that was a big axk."
Hellrazor Cain de Soulis, Sartan's Hammer says, "Your [sic] a beast."
EDIT: To address the question about pipelist, you'll need to escape the actual brackets in the pattern, so: pipe(\d+)\s+slippery elm\s+\(\s+(\d+) puffs\)
The \s+ are one or more whitespace characters (spaces). The \( and \) means treat it actually as a bracket in the string, rather than indicating that it's part of a group in the regular expression.
Results of disembowel testing | Knight limb counter | GMCP AB files
SyntaxError: Unexpected identifier
I'm trying to set up a 'give X to Y' function too, and running into this same 'give [object Object]' problem. How did we eventually fix this?
Also, minor semi-related rant: I hate, hate, hate writing posts that include code on the forums; I keep wanting to use Markdown syntax and then remember it's not supported (because we can't have nice things, apparently).
Results of disembowel testing | Knight limb counter | GMCP AB files