Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

HTML5 Client Questions and Such

1356715

Comments

  • AlcaroAlcaro Member Posts: 153 ✭✭✭ - Distinguished
    Omg, thank you <3333333 Ilu so much.
    (XXXX): Peak says, "You worry me."
    Cromm
  • MurashkaMurashka Member Posts: 1
    Hi!

    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?
  • AchimrstAchimrst NatureMember Posts: 3,608 @@ - Legendary Achaean
    Murashka said:
    Hi!

    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.
  • JaikoJaiko Member Posts: 15 ✭✭ - Stalwart
    Is there any documentation on the websocket implementation for Achaea?
    Mishgul
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    Is there a way to use the hilight and gag features outside of the temporary triggers?
  • EddardEddard Member Posts: 8
    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 :)
  • OrzaansynOrzaansyn Member Posts: 663 @@ - Legendary Achaean
    image
    image
    Mannimar
  • RiplakishRiplakish Member Posts: 19
    Cromm said:
    Eiredhel said:
    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.
  • RiplakishRiplakish Member Posts: 19
    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.
  • CrommCromm Member Posts: 41 ✭✭ - Stalwart
    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!

    - Cromm
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    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.
  • BlazagaBlazaga Member Posts: 1
    edited November 2013
    Murashka said:
    Hi!

    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.
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    edited November 2013
    I have a question about when you create custom functions and trying to use the args[1] matching for regex.

    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:

    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.

  • AntoniusAntonius Member Posts: 4,907 @@ - Legendary Achaean
    edited November 2013
    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
        }
    }
    
    Cidusii
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    edited November 2013
    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
    Post edited by Cidusii on
  • TeghaineTeghaine Cape Town - South Africa - Africa (thatcontinentthatlookslikesouthamerica)Member Posts: 116 ✭✭✭ - Distinguished
    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...

    ..


    What is regex...
    :D
  • XliXli Member Posts: 354 ✭✭✭ - Distinguished
    Teghaine said:
    What is regex...
    REGular EXpression - http://en.wikipedia.org/wiki/Regular_expression
    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."
    Teghaine
  • SiduriSiduri Member Posts: 1,587 @@ - Legendary Achaean
    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?

    image
  • OrzaansynOrzaansyn Member Posts: 663 @@ - Legendary Achaean
    your regex should be buy (\w+)

    your script should be

    direct_send("take gold from pack");
    direct_send("buy "+args[1]);

    I have not had a look at aliases yet, but it should be very close of it.
    image
    SiduriAnaidiana
  • SiduriSiduri Member Posts: 1,587 @@ - Legendary Achaean
    edited January 2014
    Can we put temptriggers in an alias? If yes, how?

    image
  • OrzaansynOrzaansyn Member Posts: 663 @@ - Legendary Achaean
    What is a temptrigger?
    image
  • YamatoYamato Member Posts: 62 ✭✭ - Stalwart
    how do you log things in HTML again? There used to be a log button, but I can't find it no more.
  • YamatoYamato Member Posts: 62 ✭✭ - Stalwart
    also, say I want a trigger saying
    pipe45512   slippery elm           (  4 puffs)
    now I wanna store that 4 into a variable called elmpuffs
    pipe(\d+)     slippery elm           (  (\d+) puffs)

    this aint working.. anyone got any idea why?
  • YamatoYamato Member Posts: 62 ✭✭ - Stalwart
    I was wondering, why is this not working?


    // If the GMCP method being called right now is the one that //
    // tells us our vital stats... //
    if (args.gmcp_method == "Char.Vitals")
    {
        // Record our current HP and our max HP from the GMCP message //
        // Note: Be careful to use the parseInt() and parseFloat() functions //
        // when calculating numeric values to avoid errors! //
        var current_hp = parseInt(args.gmcp_args.hp);
        var max_hp = parseInt(args.gmcp_args.maxhp);
        var current_hp_percent = parseFloat(current_hp/max_hp) * 100;
         
        // If our current health is below 80% of our maximum health, //
        // print a message telling us to heal //
        if (current_hp_percent < 80 && get_variable("anorexia") =="0" && get_variable("healthbalance")=="1" && get_variable("stunned"=="0"))
        {
            send_direct("sip health");
            set_variable ("healthbalance","0")
        }
    }
    Ashii
  • AntoniusAntonius Member Posts: 4,907 @@ - Legendary Achaean
    edited January 2014
    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.
    Yamato
  • OrzaansynOrzaansyn Member Posts: 663 @@ - Legendary Achaean

    Is there anything refused in the code for seurity reasons?

    I tried to build a custom UI for my iPhone using the jQuery css() function, but it keeps refusing to save my code. 

    Any idea?
    image
  • YamatoYamato Member Posts: 62 ✭✭ - Stalwart
    edited January 2014
    Antonius said:
    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
  • PaikPaik Member Posts: 12 ✭✭ - Stalwart

    Linian said:
        send_direct("generosity");
    setTimeout(function () {
        send_direct("give " + args, false);
        send_direct("selfishness");
            }, 1000);

    But now it sends the give command as 'give [object Object]', so I have absolutely no clue what it's doing now, unless I've messed up somewhere else.

    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?
  • AntoniusAntonius Member Posts: 4,907 @@ - Legendary Achaean
    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).
  • TectonTecton The Garden of the GodsAdministrator Posts: 2,507 Admin
    edited February 2014
    You can wrap things in <pre> or <code> tags!
Sign In to Comment.