Created
March 31, 2010 03:04
-
-
Save sk89q/349886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This example ruleset implements Hap's scoring ruleset (1.0). It also | |
-- generates forum emoticons for the copy and paste text! | |
local finalscore = 0 | |
local paste = "" | |
-- Go through the list of provided designs | |
for _, design in pairs(params.designs) do | |
local score = 0 | |
local emoticons = "" | |
if not design.badges.solved then | |
score = -90 | |
end | |
-- Go through all the objects | |
for _, obj in pairs(design.objects) do | |
if obj.type == "WoodRod" or obj.type == "WaterRod" then | |
score = score + 1 | |
elseif obj.type == "UnpowWheel" then | |
score = score + 2 | |
elseif obj.type == "CWWheel" or obj.type == "CWWheel" then | |
score = score + 4 | |
end | |
end | |
-- Green badge | |
if design.badges.green then | |
-- If subtracting 10 lowers the score more than halving it... | |
if score - 10 < score / 2 then | |
score = score - 10 | |
else | |
score = score / 2 | |
end | |
emoticons = emoticons .. ":green: " | |
end | |
-- Boomerang badge | |
if design.badges.boomerang then | |
score = score - 7 | |
emoticons = emoticons .. ":boomerang: " | |
end | |
-- Champion badge | |
if design.badges.champion then | |
score = score - 5 | |
emoticons = emoticons .. ":champion: " | |
end | |
-- Brown badge | |
if design.badges.brown then | |
score = score - 4 | |
emoticons = emoticons .. ":brown: " | |
end | |
-- Lightning badge | |
if design.badges.lightning then | |
score = score - 4 | |
emoticons = emoticons .. ":lightning: " | |
end | |
-- Clean badge | |
if design.badges.clean then | |
score = score - 3 | |
emoticons = emoticons .. ":clean: " | |
end | |
-- To implement Hap Scoring 2.0, add the newer badges here | |
print("#" .. design.id .. " score: " .. score) | |
finalscore = finalscore + score | |
paste = paste .. "[url=" .. design.url .. "]" .. design.name .. "[/url]" .. | |
" " .. score .. " " .. emoticons .. "\n" | |
end | |
print("Final score: " .. finalscore) | |
result.setcopypaste(paste) | |
result.setscore(finalscore) -- This will be used for contest management |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment