diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua b/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua index 16afddd29..8860d8bde 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua @@ -39,6 +39,8 @@ local function resume( ... ) return param end +local timers = {} + local ok, param = pcall( function() local sFilter = resume() while coroutine.status( co ) ~= "dead" do @@ -48,6 +50,7 @@ local ok, param = pcall( function() end if coroutine.status( co ) ~= "dead" and (sFilter == nil or sFilter == "mouse_click") then if tEvent[1] == "monitor_touch" and tEvent[2] == sName then + timers[os.startTimer( 0.1 )] = { tEvent[3], tEvent[4] } sFilter = resume( "mouse_click", 1, table.unpack( tEvent, 3, tEvent.n ) ) end end @@ -56,6 +59,12 @@ local ok, param = pcall( function() sFilter = resume( "term_resize" ) end end + if coroutine.status( co ) ~= "dead" and (sFilter == nil or sFilter == "mouse_up") then + if tEvent[1] == "timer" and timers[tEvent[2]] then + sFilter = resume( "mouse_up", 1, table.unpack( timers[tEvent[2]], 1, 2 ) ) + timers[tEvent[2]] = nil + end + end end end )