walking and death awards
This commit is contained in:
commit
5b00f38d78
16
README.txt
Normal file
16
README.txt
Normal file
@ -0,0 +1,16 @@
|
||||
Minetest Game mod: Statistic Farming
|
||||
==========================
|
||||
See license.txt for license information.
|
||||
|
||||
Mod with several awards based on statistical data from mod xpfw:
|
||||
- Hiker: For walking miles and miles and miles....
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by ademant (MIT)
|
||||
|
||||
Authors of media (textures)
|
||||
---------------------------
|
||||
Created by ademant (CC BY 3.0):
|
||||
statistic_awards_hiker based on Art by Joel Lee
|
||||
statistic_awards_death based on illustration by Paul Kidby
|
79
abm.lua
Normal file
79
abm.lua
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
statistic_awards.globaltimer=0
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
statistic_awards.globaltimer=statistic_awards.globaltimer+dtime
|
||||
if statistic_awards.globaltimer > 1 then
|
||||
statistic_awards.globaltimer = 0
|
||||
local players = minetest.get_connected_players()
|
||||
for i=1, #players do
|
||||
local player=players[i]
|
||||
local player_awards=awards.player(player:get_player_name())
|
||||
-- print(dump2(player_awards))
|
||||
local player_walked=xpfw.player_get_attribute(player,"walked")
|
||||
local hike_award=statistic_awards.hiking[1]
|
||||
if player_walked ~= nil then
|
||||
if player_walked > 0 then
|
||||
local hike_i=1
|
||||
local bhike = true
|
||||
local aw_def=statistic_awards.hiking[hike_i]
|
||||
while bhike do
|
||||
local aw_def=statistic_awards.hiking[hike_i]
|
||||
if aw_def ~= nil then
|
||||
|
||||
if basic_functions.has_value(player_awards.unlocked,aw_def.basename..aw_def.level) == false then
|
||||
bhike=false
|
||||
hike_award=aw_def
|
||||
end
|
||||
else
|
||||
bhike = false
|
||||
end
|
||||
hike_i=hike_i+1
|
||||
end
|
||||
if aw_def ~= nil then
|
||||
if aw_def.threshold<player_walked then
|
||||
awards.unlock(player:get_player_name(),aw_def.basename..aw_def.level)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
if player ~= nil then
|
||||
if xpfw.player_get_attribute(player,"deaths") > 0 then
|
||||
|
||||
local player_awards=awards.player(player:get_player_name())
|
||||
print(dump2(player_awards))
|
||||
local death_award=statistic_awards.deaths[1]
|
||||
|
||||
|
||||
local death_i=1
|
||||
local bdeath = true
|
||||
local aw_def=statistic_awards.deaths[death_i]
|
||||
while bdeath do
|
||||
local aw_def=statistic_awards.deaths[death_i]
|
||||
if aw_def ~= nil then
|
||||
if basic_functions.has_value(player_awards.unlocked,aw_def.basename..aw_def.level) == false then
|
||||
bdeath=false
|
||||
death_award=aw_def
|
||||
end
|
||||
else
|
||||
bdeath = false
|
||||
end
|
||||
death_i=death_i+1
|
||||
end
|
||||
if aw_def ~= nil then
|
||||
if aw_def.threshold<xpfw.player_get_attribute(player,"deaths") then
|
||||
print(player:get_player_name())
|
||||
print(dump2(aw_def))
|
||||
awards.unlock(player:get_player_name(),aw_def.basename..aw_def.level)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
30
awards.lua
Normal file
30
awards.lua
Normal file
@ -0,0 +1,30 @@
|
||||
if minetest.get_modpath("awards") and minetest.get_modpath("xpfw") then
|
||||
|
||||
for i,aw_def in ipairs(statistic_awards.hiking) do
|
||||
local awdef={
|
||||
title=aw_def.titel,
|
||||
description=aw_def.description,
|
||||
icon=aw_def.baseicon.."^awards_level"..aw_def.level..".png",
|
||||
background = "awards_bg_mining.png",
|
||||
}
|
||||
if aw_def.level > 1 then
|
||||
awdef.requires=aw_def.basename..(aw_def.level-1)
|
||||
awdef.secret=true
|
||||
end
|
||||
awards.register_achievement(aw_def.basename..aw_def.level,awdef)
|
||||
end
|
||||
for i,aw_def in ipairs(statistic_awards.deaths) do
|
||||
local awdef={
|
||||
title=aw_def.titel,
|
||||
description=aw_def.description,
|
||||
icon=aw_def.baseicon.."^awards_level"..aw_def.level..".png",
|
||||
background = "awards_bg_mining.png",
|
||||
}
|
||||
if aw_def.level > 1 then
|
||||
awdef.requires=aw_def.basename..(aw_def.level-1)
|
||||
awdef.secret=true
|
||||
end
|
||||
awards.register_achievement(aw_def.basename..aw_def.level,awdef)
|
||||
end
|
||||
end
|
||||
|
68
config.lua
Normal file
68
config.lua
Normal file
@ -0,0 +1,68 @@
|
||||
statistic_awards.hiking={
|
||||
{basename="statisticawards_hiking",
|
||||
level=1,
|
||||
title="Walked 1000 miles",
|
||||
description="You walked quite far. Keep going.",
|
||||
baseicon = "statistic_awards_hiking.png",
|
||||
threshold=1000,
|
||||
difficulty=0.001,},
|
||||
{basename="statisticawards_hiking",
|
||||
level=2,
|
||||
title="Walked 10000 miles",
|
||||
description="You walked quite far. Keep going.",
|
||||
baseicon = "statistic_awards_hiking.png",
|
||||
threshold=10000,
|
||||
difficulty=0.005,},
|
||||
{basename="statisticawards_hiking",
|
||||
level=3,
|
||||
title="Walked 50000 miles",
|
||||
description="You walked quite far. Keep going.",
|
||||
baseicon = "statistic_awards_hiking.png",
|
||||
threshold=50000,
|
||||
difficulty=0.01,},
|
||||
{basename="statisticawards_hiking",
|
||||
level=4,
|
||||
title="Walked 100000 miles",
|
||||
description="You walked quite far. Keep going.",
|
||||
baseicon = "statistic_awards_hiking.png",
|
||||
threshold=100000,
|
||||
difficulty=0.1,},
|
||||
{basename="statisticawards_hiking",
|
||||
level=5,
|
||||
title="Walked 500000 miles",
|
||||
description="You walked quite far. Keep going.",
|
||||
baseicon = "statistic_awards_hiking.png",
|
||||
threshold=500000,
|
||||
difficulty=1,},
|
||||
}
|
||||
|
||||
statistic_awards.deaths={
|
||||
{basename="statisticawards_deaths",
|
||||
level=1,
|
||||
title="Died 7 times",
|
||||
description="You're cat is jealous about you.",
|
||||
baseicon = "statistic_awards_death.png",
|
||||
threshold=7,
|
||||
difficulty=0.001,},
|
||||
{basename="statisticawards_deaths",
|
||||
level=2,
|
||||
title="Died 100 times",
|
||||
description="You like the danger.",
|
||||
baseicon = "statistic_awards_death.png",
|
||||
threshold=100,
|
||||
difficulty=0.01,},
|
||||
{basename="statisticawards_deaths",
|
||||
level=3,
|
||||
title="Died 1000 times",
|
||||
description="Expert in death",
|
||||
baseicon = "statistic_awards_death.png",
|
||||
threshold=1000,
|
||||
difficulty=0.1,},
|
||||
{basename="statisticawards_deaths",
|
||||
level=4,
|
||||
title="Died 5000 times",
|
||||
description="Life is boring?",
|
||||
baseicon = "statistic_awards_death.png",
|
||||
threshold=5000,
|
||||
difficulty=1,},
|
||||
}
|
8
init.lua
Normal file
8
init.lua
Normal file
@ -0,0 +1,8 @@
|
||||
statistic_awards = {}
|
||||
statistic_awards.path = minetest.get_modpath("statistic_awards")
|
||||
statistic_awards.modname = minetest.get_current_modname()
|
||||
|
||||
dofile(statistic_awards.path .. "/config.lua")
|
||||
dofile(statistic_awards.path .. "/awards.lua")
|
||||
dofile(statistic_awards.path .. "/abm.lua")
|
||||
|
7
mod.conf
Normal file
7
mod.conf
Normal file
@ -0,0 +1,7 @@
|
||||
name = statistic_awards
|
||||
title = statistic_awards
|
||||
author = ademant
|
||||
description = Awards based on statistic like walked miles
|
||||
depends = default,awards,xpfw,basic_functions
|
||||
license = MIT
|
||||
version = 1.0.0
|
1
settingtypes.txt
Normal file
1
settingtypes.txt
Normal file
@ -0,0 +1 @@
|
||||
|
BIN
textures/src/Death_Discworld.png
Executable file
BIN
textures/src/Death_Discworld.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 148 KiB |
BIN
textures/src/Over_Hill_-_Bilbo_and_Gandalf_by_Joel_Lee.jpg
Executable file
BIN
textures/src/Over_Hill_-_Bilbo_and_Gandalf_by_Joel_Lee.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
textures/statistic_awards_death.png
Executable file
BIN
textures/statistic_awards_death.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
textures/statistic_awards_hiking.png
Executable file
BIN
textures/statistic_awards_hiking.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
x
Reference in New Issue
Block a user