paste event

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

ExampleUsing paste event
Printing everything the user pastes.
Code
<nowiki>
while true do
  local event, text = os.pullEvent('paste')
  print('Player pasted ' .. text)
end
    </nowiki>
ExampleUsing paste event
Saves everything that the user pastes to a file.
Code
<nowiki>
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()
    </nowiki>
paste
Event
Returns
  • text : string The pasted text

Source CC:Tweaked
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.