mirror of
https://gitlab.com/rubenwardy/awards.git
synced 2024-11-29 18:53:44 +01:00
Add award difficulty multipler
This commit is contained in:
parent
08f654cf94
commit
f0052386c8
20
README.md
20
README.md
@ -17,14 +17,19 @@ awards.register_award("mymod:myaward", {
|
|||||||
|
|
||||||
-- Optional:
|
-- Optional:
|
||||||
|
|
||||||
|
difficulty = 1.0, -- Difficulty multipler
|
||||||
|
|
||||||
requires = { "amod:an_award" }, -- don't show this award or allow it to be unlocked
|
requires = { "amod:an_award" }, -- don't show this award or allow it to be unlocked
|
||||||
-- until required awards are unlocked
|
-- until required awards are unlocked
|
||||||
|
|
||||||
sound = {}, -- SimpleSoundSpec or false to play no sound
|
sound = {}, -- SimpleSoundSpec or false to play no sound
|
||||||
-- if not provided, uses default sound
|
-- if not provided, uses default sound
|
||||||
|
|
||||||
image = "icon_image.png", -- uses default icon otherwise
|
image = "icon_image.png", -- uses default icon otherwise
|
||||||
|
|
||||||
background = "background_image.png", -- uses default background otherwise
|
background = "background_image.png", -- uses default background otherwise
|
||||||
|
|
||||||
|
|
||||||
trigger = { -- is only unlocked by direct calls to awards.unlock() otherwise
|
trigger = { -- is only unlocked by direct calls to awards.unlock() otherwise
|
||||||
type = "trigger_type",
|
type = "trigger_type",
|
||||||
-- see specific docs on the trigger to see what else goes here
|
-- see specific docs on the trigger to see what else goes here
|
||||||
@ -35,6 +40,21 @@ awards.register_award("mymod:myaward", {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
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
|
## Registering Trigger Types
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
6
gui.lua
6
gui.lua
@ -13,9 +13,13 @@ local function order_awards(name)
|
|||||||
if def then
|
if def then
|
||||||
hash_is_unlocked[awardname] = true
|
hash_is_unlocked[awardname] = true
|
||||||
local score = -100000
|
local score = -100000
|
||||||
|
|
||||||
|
local difficulty = def.difficulty or 1
|
||||||
if def.trigger and def.trigger.target then
|
if def.trigger and def.trigger.target then
|
||||||
score = score + def.trigger.target
|
difficulty = difficulty * def.trigger.target
|
||||||
end
|
end
|
||||||
|
score = score + difficulty
|
||||||
|
|
||||||
retval[#retval + 1] = {
|
retval[#retval + 1] = {
|
||||||
name = awardname,
|
name = awardname,
|
||||||
def = def,
|
def = def,
|
||||||
|
Loading…
Reference in New Issue
Block a user