Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.
Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
-
zer0
- Posts: 213
- Joined: Sat Feb 16, 2008 11:55 pm
#1
Post
by zer0 » Fri Apr 17, 2009 7:11 am
Hey Elv, and sailor.
I've got this curious issue. In my scripts I'm going to allow a menu driven system.
I'm using the following function for input
However when I call it for the first time, the script value that was entered is automatically entered.
For example MM loads, then I enter: "my_test.lua" then when calling the io.stdin:read function the script name shows.
I show u a nice quick example of what I mean:
Code: Select all
function main()
local l_option = io.stdin:read'*l'
print("l_option: \'" .. l_option .. "\'")
end
startMacro(main)
Displays:
Any ideas how I can remove the script name from the buffer before I start asking for input? It is not a big deal for me since my scripts get called by batch files so nothing is in the buffer then, but just thought it's worth mentioning.
-
zer0
- Posts: 213
- Joined: Sat Feb 16, 2008 11:55 pm
#2
Post
by zer0 » Fri Apr 17, 2009 7:35 am
Nevermind I answered my own question, guess I should have looked in the MicroMacro manual harder.
Code: Select all
keyboardBufferClear(); -- clear keyboard buffer
io.stdin:flush(); -- clear standard input buffer
Fixes it, thanks.
-
Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
#3
Post
by Administrator » Fri Apr 17, 2009 9:33 am
Indeed. This can be confusing for people who are not familiar with working with console input. Generally, it's good practice to clear both the standard IO buffer and keyboard buffer directly before trying to read any information. In your example, you could get away with just clearing the keyboard buffer, since that information has already been popped from the IO buffer.
Who is online
Users browsing this forum: No registered users and 6 guests