Author Topic: Can you pass variables to commands?  (Read 7638 times)

Saiasanc

  • Guest
Can you pass variables to commands?
« on: June 11, 2016, 08:43:54 PM »
Sorry if this has been addressed before. But I tried searching and couldn't find anything similar.

I would like to be able to pass a variable as output in a command.  I am using VA to control my twitch bot.  One of the commands available in my bot is "makeitrain".  I can pass that command to the bot along with a static number. But I would like to make it more random so that every time I say "make it rain" it sends the command with a random number between 10 and 1000.  So it would be like "makeitrain 10", "makeitrain 50", etc.  I know I could just set up a bunch of separate makeitrain commands with different numbers after them. But I would prefer to have just one command that uses a random number.

Now I know I can use "Set small int (condition)" to randomly generate a number from 10 - 1000. But I cannot figure out how to pass that variable value to my bot's command console.  Knowing me, I am completely overthinking this and it is something really simple. But my brain is fried after a couple of hours trying different things.  Here is what I have right now as the sequence:

Code: [Select]
Set small int (condition) [saiberCheddar] value as random from 10 to 1000
Press down M key
Pause 0.1 seconds
Release M key
Pause 0.1 seconds
Press down A key
Pause 0.1 seconds
Release A key
Pause 0.1 seconds
Press down K key
Pause 0.1 seconds
Release K key
Pause 0.1 seconds
Press down E key
Pause 0.1 seconds
Release E key
Pause 0.1 seconds
Press down I key
Pause 0.1 seconds
Release I key
Pause 0.1 seconds
Press down T key
Pause 0.1 seconds
Release T key
Pause 0.1 seconds
Press down R key
Pause 0.1 seconds
Release R key
Pause 0.1 seconds
Press down A key
Pause 0.1 seconds
Release A key
Pause 0.1 seconds
Press down I key
Pause 0.1 seconds
Release I key
Pause 0.1 seconds
Press down N key
Pause 0.1 seconds
Release N key
Pause 0.1 seconds
Press down Space key
Pause 0.1 seconds
Release Space key
Pause 0.1 seconds
Set Windows clipboard to '(saiberCheddar)'
Pause 0.1 seconds
Execute command, 'paste' (and wait until it completes)
Pause 0.1 seconds
Press down Enter key
Pause 0.1 seconds
Release Enter key

It is attached to the correct process target and executes the parts that type out "makeitrain" and the Enter. But when it hits the part about setting the Windows Clipboard to the 'saiberCheddar' variable/condition and pasting it, I keep getting multiple errors in the VA log of "Key send exception : It appears that the process has been closed."  Even though the process is still open/running.

Note that in the following steps I have tried surrounding the "saiberCheddar" variable in parentheses, square brackets and curly brackets. All three possible ways end up in the same error:

Code: [Select]
Set Windows clipboard to '(saiberCheddar)'
Pause 0.1 seconds
Execute command, 'paste' (and wait until it completes)

Any help or insight anyone can provide would be greatly appreciated.

--Sai

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4757
  • RTFM
Re: Can you pass variables to commands?
« Reply #1 on: June 11, 2016, 09:52:33 PM »
If you're typing it out anyways, just use quick input:
Code: [Select]
Set small int (condition) [saiberCheddar] value as random from 10 to 1000
Quick Input, 'makeitrain {SMALL:saiberCheddar}[ENTER]'

If you're trying to set the clipboard to a variable, you need to use the same token:
Code: [Select]
Set Windows clipboard to '{SMALL:saiberCheddar}'


Don't know why you'd get errors trying to paste though. What does that command look like?

Saiasanc

  • Guest
Re: Can you pass variables to commands?
« Reply #2 on: June 11, 2016, 10:15:13 PM »
If you're typing it out anyways, just use quick input:
Code: [Select]
Set small int (condition) [saiberCheddar] value as random from 10 to 1000
Quick Input, 'makeitrain {SMALL:saiberCheddar}[ENTER]'

If you're trying to set the clipboard to a variable, you need to use the same token:
Code: [Select]
Set Windows clipboard to '{SMALL:saiberCheddar}'



Don't know why you'd get errors trying to paste though. What does that command look like?

See I knew it was probably something simple that I was overlooking. Thank you so much, Pfeil. The first option worked like a dream! TY TY TY TY TY  ;D

And it got rid of the errors as well! WOOHOO!  Now to go back and reconfigure ALL of my commands using Quick Input instead of recording keystrokes. This will make things soooo much easier.

--Sai