Skip to content

Instantly share code, notes, and snippets.

@sk89q
Created March 31, 2010 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk89q/350805 to your computer and use it in GitHub Desktop.
Save sk89q/350805 to your computer and use it in GitHub Desktop.
badges = ['boomerang', 'brown', 'champion', 'clean', 'green', 'handsoff',
'rodless', 'solved', 'sweep', 'unattractive', 'water']
types = ['WaterRod', 'WoodRod', 'PosMagnet', 'NegMagnet', 'UnpowWheel', 'CWWheel',
'CCWheel']
s1 = ""
s2 = ""
for badge in badges:
s1 = s1 + "local %s = 0\n" % badge
s1 = s1 + "local un%s = 0\n" % badge
s2 = s2 + "if env.badges.%s then score = score + %s end\n" % (badge, badge)
s2 = s2 + "if env.badges.%s then emoticons = emoticons .. \":%s: \" end\n" % (badge, badge)
s2 = s2 + "if not env.badges.%s then score = score + un%s end\n" % (badge, badge)
t1 = ""
s1 = s1 + "\n-- Objects, points for each object\n"
for t in types:
s1 = s1 + "local %s = 0\n" % t.lower()
t1 = t1 + " if obj.type == \"%s\" then score = score + %s end\n" % (t, t.lower())
print "-- Point values for badges"
print s1
print "-- STOP EDITING HERE --\n"
print "local score = 0"
print "local emoticons = \"\"\n";
print s2
print "for _, obj in pairs(env.objects) do"
print t1,
print "end"
print """
print("Final score is " .. score)
local paste = "[url=" .. env.url .. "]" .. env.name .. "[/url]" .. " " .. score .. " " .. emoticons
result.setcopypaste(paste)
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment