Using Lua + Love2D? I wrote a small module that let’s you easily create Twitter share links!

Lot of high score games let you share your successes to Twitter and stuff, so why should LD games be any different?

Here’s the module. Just download the file as “twitterer.lua” and require it into your game.

Here’s how you use it (after the break):

 function love.load()
 local url = ""
 
 -- just a basic tweet
 url = Twitterer{text="Hello Twitter!"}
 
 -- tweet a url, it'll be autoshortened if necessary
 url = Twitterer{url="http://ludumdare.com"}
 
 -- via adds a " via @account" to the end the tweet
 -- related lets you suggest twitter accounts for the user to follow,
 --  some optional description text
 url = Twitterer{text="Using this awesome Twitter URL generator!!",
 via="@y2bd",
 related={{"@y2bd", "Developer of the library."}}}
 
 -- autoappend hashtags to the end of your tweet
 url = Twitterer{text="Getting ready for Ludum Dare!",
 hashtags={"#ld48", "#ld30"}}
 
 -- putting it all together
 url = Twitterer{text="Quickly, get ready for Ludum Dare! I'm using Love2D!",
 url="http://ludumdare.com",
 hashtags={"#ld48", "#gamejam"},
 related={{"@ludumdare", "Official Ludum Dare Twitter Account"},
 {"@mikekasprzak"},
 {"@philhassey"}}}
 
 -- open with love2d
 -- success is a bool that'll tell you if the url was opened successfully
 success = love.system.openURL(url)
 end
 

I plan on using it in my game, so I guess this counts as disclosing my libraries. Feel free to use it, no credit needed!

Tags: basecode, free code, love2d, lua