Tool: Stop Or Edit

I have made my first (and very simple but useful) tool, and thought some experienced coder could just see that it’s OK before i release it. It works but maybe it’s too ugly?

  
-- My first simple script, making a keyboard shortcut working like Milkytrackers spacebar. It stops if playing, and toggles editmode if stopped.  
  
function stop_or_edit()  
 if renoise.song().transport.playing == true then   
 renoise.song().transport:stop()  
 elseif not renoise.song().transport.edit_mode then  
 renoise.song().transport.edit_mode = true  
 else  
 renoise.song().transport.edit_mode = false  
 end  
end  
  
renoise.tool():add_keybinding {  
name = "Pattern Editor:Play:Stop or Edit",  
invoke = function() stop_or_edit() end  
}  
  

Looks good to me. You dont really need the == true in the first if statement, but maybe you already knew that.

Looks good, and don’t want to discourage you, but there is an option in Renoise to get the old FTII space key behavior:
http://tutorials.renoise.com/wiki/Preferences#Misc -> Space rec/stop mode

Thanks taktik, I will use this feature instead.

I am already working on a new and more serious tool. Even for non-coders it’s quite easy to just copy+paste from the API reference :)