summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-04-17 22:25:53 +0100
committerrubenwardy <rw@rubenwardy.com>2018-04-17 22:25:53 +0100
commitf0052386c8f70857a2dfdb3f1c8de229f89e4cb5 (patch)
treedd48c1c165229c32db2732ed19ddc16e55985b77
parent08f654cf949a395c1745b779687469870f3d40ab (diff)
Add award difficulty multipler
-rw-r--r--README.md22
-rw-r--r--gui.lua6
2 files changed, 26 insertions, 2 deletions
diff --git a/README.md b/README.md
index c2ac1c4..28bf8bd 100644
--- a/README.md
+++ b/README.md
@@ -17,24 +17,44 @@ awards.register_award("mymod:myaward", {
-- Optional:
+ difficulty = 1.0, -- Difficulty multipler
+
requires = { "amod:an_award" }, -- don't show this award or allow it to be unlocked
-- until required awards are unlocked
sound = {}, -- SimpleSoundSpec or false to play no sound
-- if not provided, uses default sound
+
image = "icon_image.png", -- uses default icon otherwise
+
background = "background_image.png", -- uses default background otherwise
+
trigger = { -- is only unlocked by direct calls to awards.unlock() otherwise
type = "trigger_type",
-- see specific docs on the trigger to see what else goes here
},
-
+
-- Callback. award_def is this table (plus some additional methods/members added by register_award)
on_unlock = function(name, award_def) end,
})
```
+If the award is counted, ie: there's a trigger.target property, then the difficulty
+multipler is timesd by target to get the overal difficulty. If the award isn't a
+counted type then the difficulty multiplier is used as the overal difficulty.
+Award difficulty affects how awards are sorted in a list - more difficult awards
+are further down the list.
+
+Actual code used to calculate award difficulty:
+
+```lua
+local difficulty = def.difficulty or 1
+if def.trigger and def.trigger.target then
+ difficulty = difficulty * def.trigger.target
+end
+```
+
## Registering Trigger Types
```lua
diff --git a/gui.lua b/gui.lua
index 374217b..21d0d37 100644
--- a/gui.lua
+++ b/gui.lua
@@ -13,9 +13,13 @@ local function order_awards(name)
if def then
hash_is_unlocked[awardname] = true
local score = -100000
+
+ local difficulty = def.difficulty or 1
if def.trigger and def.trigger.target then
- score = score + def.trigger.target
+ difficulty = difficulty * def.trigger.target
end
+ score = score + difficulty
+
retval[#retval + 1] = {
name = awardname,
def = def,