Finally a solution!
i was trying to figure out how could i clear the input buffer, so i come up with a kinda good solution and i decided to share it with you all.
So if anyone wonders how to clear the input buffer in LuaRT, the answer is... you cant
Well thats half true... since there is no built in way to clear the input buffer and i managed to do it somehow.
Alright here is what i did:
- I made a c++ code that clears the input buffer
- Turned it into a .dll file
- accessed the .dll file from LuaRT code
- Called the dll function when i needed that clears the buffer input.
the solution turned out to be pretty simple, yet it took me a while...
anyways, if anyone needs the dll file, here it is:
[Login to see the link]
Simple code example (with comments):
local c = require "c"
local console = require "console"
-- Adjust the filename to match your DLL (case doesn't matter on Windows)
local dll_name = "clearinput.dll"
-- Load the DLL
local lib = c.Library(dll_name)
-- Define the function signature: no args, returns BOOL
-- In the c module BOOL is represented with 'B' (as used earlier), so use "()B".
lib.ClearConsoleInputBuffer = "()B"
-- Call "lib.ClearConsoleInputBuffer()" to clear input buffer
while true do
print("HIIIII :3") --// dont mind the weird text, i was at my mental limits at this point...
sleep(1000)
lib.ClearConsoleInputBuffer()
console.readchar()
end
--// Result: if you spam any button during the "sleep" the input wont buffer.
--// Aka your input wont queue when you spam during the "sleep". The input will only start registering after the "sleep" ends
--// Y'll i was trying to find a solution all day, finally i managed to figure it out (with a little help on how to make dlls)
--// The dll is a simple c++ code to clear console input buffer. IT DOES NOT CONTAIN ANY VIRUS, feel free to check
(make sure the .dll file is in the same folder as your .lua file)
This is it. Hope it helps!
If you have any other solution im happy to hear it!