Creating a Repeating Macro that only sends to one instance

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
Reverage
GamingTools Subscriber
Posts: 31
Joined: Fri Jun 13, 2008 12:26 pm

Creating a Repeating Macro that only sends to one instance

Post by Reverage » Mon Feb 16, 2009 1:12 pm

I am looking at replacing a G15 macro I made that essentially presses "1" every 0.5 seconds. It works fine, it's just that in a second instance of the game, it echoes there, rather than the first instance, where I started it.

So I got thinking that I could likely do this with IS.

I could make a global macro on G1, that toggles this echoing of "1" to instance 1 of the game, and I'd never see it in instance 2, or 3, etc.

Not too sure if this is doable at the script level; my limited knowledge of your scripting language (ie, tearing open the .is files) hasn't revealed a repeat or similar option.

Any hints on how I would approach this? Just a direction, and maybe some documentation should be enough, I hope. :)

BTW, this ISBoxer Toolkit looks really promising, keep up the awesome work!

(Hmm, maybe I should examine this Key Maps mod.)

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Mon Feb 16, 2009 1:42 pm

Code: Select all

bind mybind g1 run somescript
somescript.iss

Code: Select all

function main()
{
   while 1
   {
      press 1
      wait 5
   }
}
The scripting language has fairly standard control structures. http://www.lavishsoft.com/wiki/index.ph ... e_Overview

Reverage
GamingTools Subscriber
Posts: 31
Joined: Fri Jun 13, 2008 12:26 pm

Post by Reverage » Mon Feb 16, 2009 3:27 pm

Nice, thanks! Some great reading there.

In order to make it toggleable, I did the following (I am at work and haven't tested, but I am fairly confident it will work):

(**global** is pseudocode to remind me to make that bind global - I forget how off hand, but it's at home)

main.iss:

Code: Select all

    bind mybind **global** g1 run spam1

spam1.iss:

Code: Select all

unbind mybind
bind mybind **global** g1 doIt = !doIt

variable(script) bool doIt=TRUE

function main()
{
    while 1
    {
        if doIt == TRUE
        {
            press 1
            wait 5
        }
    }
}
The idea is I hit G1 the first time, and 1 begins to be spammed, every 0.5 seconds. I hit it again, and it turns it off. Hitting it a second time turns it back on.

Reverage
GamingTools Subscriber
Posts: 31
Joined: Fri Jun 13, 2008 12:26 pm

Post by Reverage » Mon Feb 16, 2009 5:10 pm

Bit of refinement, but getting an error.

main.iss:

Code: Select all

    GlobalBind mybind g1 run spam1
spam1.iss:

Code: Select all

variable(global) bool doIt=TRUE;

function main()
{
    bind -delete mybind
    GlobalBind mybind g1 doIt = !doIt
    
    while 1
    {
        if doIt == TRUE
        {
            press 1
            wait 5
        }
    }
}

Oh, the error:

Code: Select all

Error:Unparsable in calculation of "doIt == TRUE" at: 'doIt' @run spam1
Error:Unparsable in Calculation of "doIt == 1.00": 'd' @run spam1
Could not calculate "doIt == 1.00"
Bind 'mybind' not found
[mybind] [g1] Command: doIt "=" "!doIt"
LavishScript Internal Error: Script 'spam1' corrupted, aborting script.
Dumping script stack
--------------------
-->C:/Program Files (x86)/InnerSpace/Scripts/spam1.iss:11 main() if doIt == TRUE

Reverage
GamingTools Subscriber
Posts: 31
Joined: Fri Jun 13, 2008 12:26 pm

Post by Reverage » Mon Feb 16, 2009 5:16 pm

And more refinement:

spam1.iss

Code: Select all

variable bool doIt=TRUE

function main()
{
    bind -delete mybind
    GlobalBind mybind g1 "${doIt} = !${doIt}"

    while 1
    {
        if ${doIt}==TRUE
        {
            press 1
            wait 5
        }
    }
}
Now to figure out how to access that object from the bind.

Code: Select all

    GlobalBind mybind g1 "${doIt} = !${doIt}"
Oh, and to figure out why if I turn off my G15 profile program, it still insists on hitting F1 when I hit G1. :)

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Mon Feb 16, 2009 5:42 pm

Clear the G15 profile first, it gets stored in the hardware

You can't make a globalbind with G1, because it's implemented using a registered windows hotkey, and that means only "normal" keys allowed ;)
You can relay a command to the session from the other sessions when you hit g1 instead.

To set the value of the bool, you would need to do doIt:Set[!${doIt}]

here's an example...

Code: Select all

atom(global) mycommand()
{
   doIt:Set[!${doIt}]
}

.
.
.

bind mybind g1 relay is1 mycommand

Reverage
GamingTools Subscriber
Posts: 31
Joined: Fri Jun 13, 2008 12:26 pm

Post by Reverage » Mon Feb 16, 2009 5:54 pm

Thanks! For the curious, here's the final result:

main.iss

Code: Select all

    bind spam1 g1 run spam1

spam1.iss

Code: Select all

variable(global) bool doIt = TRUE

atom(global) toggleSpam()
{
   doIt:Set[!${doIt}]
}

function main()
{
    squelch bind -delete spam1
    bind spam1 g1 relay is1 toggleSpam

    while 1
    {
        if ${doIt}==TRUE
        {
            press 1
            wait 5
        }
    }
}

Post Reply