paste event

From ComputerCraft
Jump to: navigation, search
paste
Event
Returns
  • text : string The pasted text

Source CC:Tweaked

Occurs every time the user pastes text into a terminal, with Ctrl-V

ExampleExampleUsing paste event
Printing everything the user pastes.
Code
while true do
  local event, text = os.pullEvent('paste')
  print('Player pasted ' .. text)
end
ExampleExampleUsing paste event
Saves everything that the user pastes to a file.
Code
local f = fs.open("pasted_contents","w")
while true do
  local event, text = os.pullEventRaw()
  if event == 'paste' then
    f.writeLine(text)
  elseif event == 'terminate' then
    break
  end
end
f.close()