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

How do you write a script that uses aliases and waits for equilibrium/balance in the HTML5 client?

AntreusAntreus Member Posts: 131 ✭✭✭ - Distinguished
edited November 2014 in Client Help
I've scripted/coded before, just HTML. I understand the concepts, but I don't know how to write script. I mostly just replace variables or aliases.

I wanted to try and copy pasta something from a experienced scripter that I might jerry-rig onto the Achaea Client. I have so many things I need to do and I think this would help me. A simple alias that does an action, WAITS, then carries out another, but off of one command. I want to see it in an advanced way via scripting, so that I could  apply it elsewhere and learn.

What does the format look like?

A male voice is heard through the membrane, "Hey, girl."

A male voice is heard through the membrane, "Are you an Apostate? ..because you just tore my heart out."

Best Answers

  • TaelTael Posts: 1,197 @ - Epic Achaean
    edited November 2014 Accepted Answer
    Addama said:
    No.

    You can literally just write that as a command.

    E: Make sure you do CONFIG USEQUEUEING ON first, though.
    Actually no, you don't need to do CONFIG USEQUEUEING ON. The queue still works without it via QUEUE ADD - USEQUEUEING is an option that makes it so any command you send while off-balance will automatically act as if you had sent it as a QUEUE ADD, it isn't just a way of enabling or disabling the queue.

    @Antreus: What you are describing, if I understand correctly (and I definitely don't understand some of it, like what "making functions to my wait queues" means), is more difficult to do than it would seem on the surface. This isn't necessarily a "simple" example .

    Here are a few different solutions to this problem:

    (1) If you really just want to do an action, wait, then do another action, the function you're looking for is setTimeout(function,time). You pass it a function and how long to wait before executing the function. So if you wanted to sip health, wait 10 seconds, then sip health again, it would look like this.
    client.send_direct("sip health");
    setTimeout(
        function () {
            client.send_direct("sip health");
        },
        10000
    );
    It's 10000 because the time has to be in milliseconds. The first argument has to be an actual function, not a function call so you can't just put slient.send_direction("sip health") in there, you have to wrap it in an anonymous function like this. If you already have a function for sipping health called sipHealth, you could replace it with setTimeout(sipHealth,10000).

    Note that it isn't busy wait. If you added client.send_direct("writhe"); to the end of that script above, it would sip health immediately, then writhe, then in 10 seconds, sip health again. setTimeout isn't a "pause button" for your script, it's a timer for whatever function you pass it.

    (2) If you want to just do one action, then do another on balance, this is really easy with the queue commands built in. All you do is:
    client.send_direct("writhe");
    client.send_direct("queue add bal writhe");
    The problem with this is that the queue built into the game isn't much of a "queue" in that everything you add to it tries to fire at once on the next balance recovery. You can't actually throw five things into it and have it run one at a time, on each of the next five balance recoveries. If you want to do something like that, things get tricky. You can do things like have your alias enable a trigger for the line that results from the first queued action's success, and then that trigger adds the next thing to the queue and disables itself. Building an actual queueing system isn't really "simple" though, and it's a lot harder in HTML5 since there isn't a simple way (or at least any documented way) to create temporary triggers. I can think of a way you could build a real queueing system for HTML5 similar to svo's do system, and I might get around to doing it someday, but it isn't totally trivial.

    (3) If what you're after is to repeat something over and over on balance rather than after a specific amount of time, things get a bit more complicated. Your best bet here is probably to actually make a trigger for the balance line. So if you want to be transmuting, you're going to have three things: (1) a trigger for the balance line that does client.send("whatever your transmutation commands are") (2) an alias to toggle that trigger on and off and get the ball rolling with the first transmute and (3) a failsafe in case you get disconnected or save the client while the balance trigger is turned on.

    The trigger works exactly how you think it would (it just triggers on the balance line and runs your command). We'll assume it's named "Repeat Transmute".

    Then you have an alias that works as a toggle to turns it on and off. It would look something like this:
    if (transmuting) {
        client.reflex_disable(client.reflex_find_by_name("trigger","Repeat Transmute"));
    } else {
        client.reflex_enable(client.reflex_find_by_name("trigger","Repeat Transmute"));
    client.send_direct("transmutation command that I don't remember"); } transmuting = !transmuting;
    So what this does is check to see if the "transmuting" variable is true. If it is, that means you're currently transmuting, which means that you're using the alias because you want to stop transmuting, so it disables the balance trigger that makes your transmutation repeat. Otherwise (if transmuting is false), it means you want to start transmuting, so it enables the trigger and sends the first transmutation command. The last line just toggles the transmuting variable whenever you use the alias.

    Note that if this isn't in the main package, you need to add some things to client.reflex_find_by_name, it ends up looking like client.reflex_find_by_name("trigger","Repeat Transmute", true, false, "MyPackage"). The first true tells it to be case sensitive, the false tells it that it shouldn't only look at triggers that are already enabled, and the last string is the package name.

    Then you need your failsafe, which is going to go into the onLoad "function". Just add this to your existing onLoad:
    var transmuting = false;
    client.reflex_disable(client.reflex_find_by_name("trigger","Repeat Transmute"));
    
    The first line declares the transmuting variable and initializes it to false (since, by definition, you aren't in the process of transmuting when you log in). The second line makes sure the trigger is disabled whenever you log in, in case you logged out with it enabled.

    If you wanted to make this more generic so you could use it for any transmutation you want to do, you can make a few small modifications. First, have the trigger call something like: client.send_direct("transmute " + reagent); instead of having the reagent baked into the string. Make the same change to the alias script where it sends the command. Then add a line to your onLoad to declare the reagent variable: var reagent;. Then add a line to the top of your alias to save whatever you typed after the alias's actual text in the "reagent" variable: reagent = args[1];.

    Then if your alias is "tr", you use "tr bisemutum" to transmute bisemutum, and you just use "tr" again to stop.
    AddamaAntreus

Answers

  • TectonTecton The Garden of the GodsAdministrator Posts: 2,506 Admin
    You could use the in-built QUEUE system to do this for you! If it's something you want to do when balance comes back, simply QUEUE ADD BAL <command>, and the server will execute it for you next time you get balance!
    Addama
  • AddamaAddama Member Posts: 947 ✭✭✭✭✭ - Grand Achaean
    So, for instance, if your attack is doubleslash, you'd code something like this:

    QUEUE ADD BAL DSL @tar

    ~Kresslack's obsession~
  • AddamaAddama Member Posts: 947 ✭✭✭✭✭ - Grand Achaean
    Or if you wanted to queue a command that jumps in front of any queued commands, QUEUE PREPEND (BAL/EQ/EQBAL).
    ~Kresslack's obsession~
  • AntreusAntreus Member Posts: 131 ✭✭✭ - Distinguished
    Addama said:
    So, for instance, if your attack is doubleslash, you'd code something like this:

    QUEUE ADD BAL DSL @tar

    So to do this I would need to use the "execute script" option, and type this in, followed by creating a variable for BAL to mean a "wait" function of 2-3 seconds?

    A male voice is heard through the membrane, "Hey, girl."

    A male voice is heard through the membrane, "Are you an Apostate? ..because you just tore my heart out."

  • AntreusAntreus Member Posts: 131 ✭✭✭ - Distinguished
    edited November 2014

    Tecton said:
    You could use the in-built QUEUE system to do this for you! If it's something you want to do when balance comes back, simply QUEUE ADD BAL <command>, and the server will execute it for you next time you get balance!
    Yes, but what if I wanted to create a variable that I use across all the things I make. Such as a variable that has my equivalent equilibrium or balance (factoring in the delay from the server), so I don't have to continually add in WAIT queues, and just script them all in one go. I find it becomes tedious fast.

    I have been able to make queue systems, but I wondered if there was a more advance way to script what the queue system manages, but makes unwieldy due to the need to add and order action events, which is time consuming when you're an Alchemist trying to synthesise, transmutate, and decant. I'm finding myself wanting a way to copy and paste a script I make, just filling in the blanks with a new balm, tonic, or mineral. Is there a way to copy?

    How do I start making functions to my wait queues: do this, this many times.

    A male voice is heard through the membrane, "Hey, girl."

    A male voice is heard through the membrane, "Are you an Apostate? ..because you just tore my heart out."

  • AntreusAntreus Member Posts: 131 ✭✭✭ - Distinguished
    edited November 2014
    @Tael‌ ;
    You sir are a gentleman and a scholar. This is exactly what I needed. You can draw a horse to water, but will he drink. You can give a man a fish, but you can teach him how to fish. I found this positively liberating, thank you! I didn't have the right words to describe my problem but you covered everything I was trying to express - how positively wonderful. I could almost give you money, but definitely a big hug.

    A male voice is heard through the membrane, "Hey, girl."

    A male voice is heard through the membrane, "Are you an Apostate? ..because you just tore my heart out."

Sign In to Comment.