commit 5b00f38d7836d133d19734a577cdbcdbf4d3c5c4 Author: ademant Date: Thu Dec 6 14:05:40 2018 +0100 walking and death awards diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..af9b508 --- /dev/null +++ b/README.txt @@ -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 diff --git a/abm.lua b/abm.lua new file mode 100644 index 0000000..49fe85b --- /dev/null +++ b/abm.lua @@ -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 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 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 + diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..f332762 --- /dev/null +++ b/config.lua @@ -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,}, +} diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..2893e96 --- /dev/null +++ b/init.lua @@ -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") + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..8bf8d69 --- /dev/null +++ b/mod.conf @@ -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 diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1 @@ + diff --git a/textures/src/Death_Discworld.png b/textures/src/Death_Discworld.png new file mode 100755 index 0000000..1db07bf Binary files /dev/null and b/textures/src/Death_Discworld.png differ diff --git a/textures/src/Over_Hill_-_Bilbo_and_Gandalf_by_Joel_Lee.jpg b/textures/src/Over_Hill_-_Bilbo_and_Gandalf_by_Joel_Lee.jpg new file mode 100755 index 0000000..35c2af2 Binary files /dev/null and b/textures/src/Over_Hill_-_Bilbo_and_Gandalf_by_Joel_Lee.jpg differ diff --git a/textures/statistic_awards_death.png b/textures/statistic_awards_death.png new file mode 100755 index 0000000..9b5737a Binary files /dev/null and b/textures/statistic_awards_death.png differ diff --git a/textures/statistic_awards_hiking.png b/textures/statistic_awards_hiking.png new file mode 100755 index 0000000..1332d4f Binary files /dev/null and b/textures/statistic_awards_hiking.png differ