mirror of
https://gitlab.com/rubenwardy/awards.git
synced 2024-11-22 15:23:44 +01:00
Add award difficulty multipler
This commit is contained in:
parent
08f654cf94
commit
f0052386c8
22
README.md
22
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
|
||||
|
6
gui.lua
6
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,
|
||||
|
Loading…
Reference in New Issue
Block a user