deaznracer wrote:is there an input command using micromacro?
like
get user input()
if userInput = Y then
Do this
end
If the user press X then it will do this function. Because I found some interesting offset that I want to be able to switch off and on without restarting micromacro
Depends what you mean. You can setup your own 'hotkeys', or you can collect information from the standard input stream. Hotkeys are simple.
Code: Select all
function hotkeys()
if( keyPressed(key.VK_<whatever>) ) then
do_something();
end
end
registerTimer("hotkeys", 10, hotkeys);
I just used an automatic timer in this example, that way you don't have to bother checking inside any sub-loops. It's cheap, but it works.
Now, reading from the standard input stream is fine, however, you need to be aware that it is a blocking procedure. This means that the script execution will not continue until the user has completed their input and pressed enter.
Code: Select all
function get_input()
printf("What is your name?\nName> ");
io.stdin:flush(); -- always flush the buffer before you try to read in
local name = io.stdin:read(); -- ask the user to input their name.
printf("\n\nDo you like the color blue? [Y/N]> ");
io.stdin:flush(); -- flush again
local colorchoice = io.stdin:read(1);
while( not (colorchoice == 'y' or colorchoice == 'n') ) do
printf("\nInvalid choice. You chose %s. Try again> ", colorchoice);
io.stdin:flush();
colorchoice = io.stdin:read(1);
end
local colorstr = "like blue";
if( colorchoice ~= 'y' ) then colorstr = "do not like blue"; end
printf("\n\nOk! %s, you %s.\n", name, colorstr);
io.stdin:flush();
end
There is a few things you should be aware of before using this. If you have this pop up right away when they start the script, you could notice some strange things. That is, if execution start is not automatic (they need to press F5 or whatever), F5 is also the "use previous input" hotkey for standard input. Try it and you'll see what I mean. To overcome this, you can do something like this:
Code: Select all
while( keyPressedLocal(key.VK_F5) ) rest(1); end; -- wait till they let go of F5
io.stdin:flush();
get_input();
im not a big expert and I dont have understand good what you explain me, Im sure my bot dont run good cuz I dont have tilde in switch key on my keyboard, I've tired US setting too but nothing change, maybe if I know how is called this key ( \ ) in US english keyboard I can use that name
That key is key.VK_BACKSLASH under the en_us keyboard layout. Actually, the only keyboard layout that is implemented is the en_us layout. If you want to help out, it'd be appreciated if you could create a layout script for your region. Just make a copy of micromacro/lib/mods/keyboards/en_us.lua and modify it to fit your keyboard. If you come up with something workable, I'll include it in the next release of MicroMacro.