we need more and more awesome mods, gauges, awards and sprint

This commit is contained in:
Jordach 2014-12-25 20:55:47 +00:00
parent 07402f3f7a
commit d0d6181435
51 changed files with 1630 additions and 0 deletions

22
mods/awards/.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

215
mods/awards/.gitignore vendored Normal file
View File

@ -0,0 +1,215 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

492
mods/awards/api.lua Normal file
View File

@ -0,0 +1,492 @@
-- AWARDS
-- by Rubenwardy
-------------------------------------------------------
-- this is api function file
-------------------------------------------------------
-- The global award namespace
awards = {
show_mode = "hud"
}
-- Table Save Load Functions
function awards.save()
local file = io.open(minetest.get_worldpath().."/awards.txt", "w")
if file then
file:write(minetest.serialize(awards.players))
file:close()
end
end
function awards.load()
local file = io.open(minetest.get_worldpath().."/awards.txt", "r")
if file then
local table = minetest.deserialize(file:read("*all"))
if type(table) == "table" then
return table
end
end
return {}
end
awards.players = awards.load()
function awards.player(name)
return awards.players[name]
end
-- A table of award definitions
awards.def = {}
function awards.tbv(tb,value,default)
if not default then
default = {}
end
if not tb or type(tb) ~= "table" then
if not value then
value = "[NULL]"
end
minetest.log("error", "awards.tbv - table "..dump(value).." is null, or not a table! Dump: "..dump(tb))
return
end
if not value then
error("[ERROR] awards.tbv was not used correctly!\n"..
"Value: '"..dump(value).."'\n"..
"Dump:"..dump(tb))
return
end
if not tb[value] then
tb[value] = default
end
end
function awards.assertPlayer(playern)
awards.tbv(awards.players, playern)
awards.tbv(awards.players[playern], "name", playern)
awards.tbv(awards.players[playern], "unlocked")
awards.tbv(awards.players[playern], "place")
awards.tbv(awards.players[playern], "count")
awards.tbv(awards.players[playern], "deaths", 0)
awards.tbv(awards.players[playern], "joins", 0)
awards.tbv(awards.players[playern], "chats", 0)
end
-- Load files
dofile(minetest.get_modpath("awards").."/triggers.lua")
-- API Functions
function awards._additional_triggers(name, data_table)
-- To add triggers in another mod, you should override this function
-- If the code can't handle the trigger passed, then call the last value of _additional_triggers
--[[
local add_trig = awards._additional_triggers
awards._additional_triggers = function(name, data_table)
if data_table.trigger.type == "trigger" then
local tmp = {
award = name,
node = data_table.trigger.node,
target = data_table.trigger.target,
}
table.insert(awards.onTrigger,tmp)
elseif data_table.trigger.type == "trigger2" then
local tmp = {
award = name,
node = data_table.trigger.node,
target = data_table.trigger.target,
}
table.insert(awards.onTrigger2,tmp)
else
add_trig(name, data_table)
end
end
]]--
end
function awards.register_achievement(name,data_table)
-- see if a trigger is defined in the achievement definition
if data_table.trigger and data_table.trigger.type then
if data_table.trigger.type == "dig" then
local tmp = {
award = name,
node = data_table.trigger.node,
target = data_table.trigger.target,
}
table.insert(awards.onDig,tmp)
elseif data_table.trigger.type == "place" then
local tmp = {
award = name,
node = data_table.trigger.node,
target = data_table.trigger.target,
}
table.insert(awards.onPlace,tmp)
elseif data_table.trigger.type == "death" then
local tmp = {
award = name,
target = data_table.trigger.target,
}
table.insert(awards.onDeath,tmp)
elseif data_table.trigger.type == "chat" then
local tmp = {
award = name,
target = data_table.trigger.target,
}
table.insert(awards.onChat,tmp)
elseif data_table.trigger.type == "join" then
local tmp = {
award = name,
target = data_table.trigger.target,
}
table.insert(awards.onJoin,tmp)
else
awards._additional_triggers(name, data_table)
end
end
-- check icon, background and custom_announce data
if data_table.icon == nil or data_table.icon == "" then
data_table.icon = "unknown.png"
end
if data_table.background == nil or data_table.background == "" then
data_table.background = "bg_default.png"
end
if data_table.custom_announce == nil or data_table.custom_announce == "" then
data_table.custom_announce = "Achievement Unlocked:"
end
-- add the achievement to the definition table
data_table.name = name
awards.def[name] = data_table
end
-- run a function when a node is dug
function awards.register_onDig(func)
table.insert(awards.onDig,func)
end
-- run a function when a node is placed
function awards.register_onPlace(func)
table.insert(awards.onPlace,func)
end
-- run a function when a player dies
function awards.register_onDeath(func)
table.insert(awards.onDeath,func)
end
-- run a function when a player chats
function awards.register_onChat(func)
table.insert(awards.onChat,func)
end
-- run a function when a player joins
function awards.register_onJoin(func)
table.insert(awards.onJoin,func)
end
-- This function is called whenever a target condition is met.
-- It checks if a player already has that achievement, and if they do not,
-- it gives it to them
----------------------------------------------
--awards.give_achievement(name,award)
-- name - the name of the player
-- award - the name of the award to give
function awards.give_achievement(name, award)
-- Access Player Data
local data = awards.players[name]
-- Perform checks
if not data then
return
end
if not awards.def[award] then
return
end
awards.tbv(data,"unlocked")
-- check to see if the player does not already have that achievement
if not data.unlocked[award] or data.unlocked[award]~=award then
-- Set award flag
data.unlocked[award]=award
-- Give Prizes
if awards.def[award] and awards.def[award].prizes then
for i = 1, #awards.def[award].prizes do
local itemstack = ItemStack(awards.def[award].prizes[i])
if itemstack:is_empty() or not itemstack:is_known() then
return
end
local receiverref = core.get_player_by_name(name)
if receiverref == nil then
return
end
receiverref:get_inventory():add_item("main", itemstack)
end
end
-- Get data from definition tables
local title = award
local desc = ""
local background = ""
local icon = ""
local custom_announce = ""
if awards.def[award].title then
title = awards.def[award].title
end
if awards.def[award].custom_announce then
custom_announce = awards.def[award].custom_announce
end
if awards.def[award].background then
background = awards.def[award].background
end
if awards.def[award].icon then
icon = awards.def[award].icon
end
if awards.def[award] and awards.def[award].description then
desc = awards.def[award].description
end
-- send the won award message to the player
if awards.show_mode == "formspec" then
-- use a formspec to send it
minetest.show_formspec(name, "achievements:unlocked", "size[4,2]"..
"image_button_exit[0,0;4,2;"..background..";close1; ]"..
"image_button_exit[0.2,0.8;1,1;"..icon..";close2; ]"..
"label[1.1,1;"..title.."]"..
"label[0.3,0.1;"..custom_announce.."]")
elseif awards.show_mode == "chat" then
-- use the chat console to send it
minetest.chat_send_player(name, "Achievement Unlocked: "..title)
if desc~="" then
minetest.chat_send_player(name, desc)
end
else
local player = minetest.get_player_by_name(name)
local one = player:hud_add({
hud_elem_type = "image",
name = "award_bg",
scale = {x = 1, y = 1},
text = background,
position = {x = 0.5, y = 0},
offset = {x = 0, y = 138},
alignment = {x = 0, y = -1}
})
local two = player:hud_add({
hud_elem_type = "text",
name = "award_au",
number = 0xFFFFFF,
scale = {x = 100, y = 20},
text = "Achievement Unlocked!",
position = {x = 0.5, y = 0},
offset = {x = 0, y = 40},
alignment = {x = 0, y = -1}
})
local three = player:hud_add({
hud_elem_type = "text",
name = "award_title",
number = 0xFFFFFF,
scale = {x = 100, y = 20},
text = title,
position = {x = 0.5, y = 0},
offset = {x = 30, y = 100},
alignment = {x = 0, y = -1}
})
local four = player:hud_add({
hud_elem_type = "image",
name = "award_icon",
scale = {x = 4, y = 4},
text = icon,
position = {x = 0.5, y = 0},
offset = {x = -81.5, y = 126},
alignment = {x = 0, y = -1}
})
minetest.after(3, function()
player:hud_remove(one)
player:hud_remove(two)
player:hud_remove(three)
player:hud_remove(four)
end)
end
-- record this in the log
minetest.log("action", name.." has unlocked award "..title)
-- save playertable
awards.save()
end
end
-- List a player's achievements
minetest.register_chatcommand("list_awards", {
params = "obsolete",
description = "list_awards: obsolete. Use /awards",
func = function(name, param)
minetest.chat_send_player(name, "This command has been made obsolete. Use /awards instead.")
awards.showto(name, name, nil, false)
end
})
minetest.register_chatcommand("awards", {
params = "",
description = "awards: list awards",
func = function(name, param)
awards.showto(name, name, nil, false)
end
})
minetest.register_chatcommand("cawards", {
params = "",
description = "awards: list awards in chat",
func = function(name, param)
awards.showto(name, name, nil, true)
end
})
minetest.register_chatcommand("awd", {
params = "award name",
description = "awd: Details of awd gotten",
func = function(name, param)
local def = awards.def[param]
if def then
minetest.chat_send_player(name,def.title..": "..def.description)
else
minetest.chat_send_player(name,"Award not found.")
end
end
})
--[[minetest.register_chatcommand("gawd", {
params = "award name",
description = "gawd: give award to self",
func = function(name, param)
awards.give_achievement(name,param)
end
})]]--
function awards._order_awards(name)
local done = {}
local retval = {}
local player = awards.player(name)
if player and player.unlocked then
for _,got in pairs(player.unlocked) do
if awards.def[got] then
done[got] = true
table.insert(retval,{name=got,got=true})
end
end
end
for _,def in pairs(awards.def) do
if not done[def.name] then
table.insert(retval,{name=def.name,got=false})
end
end
return retval
end
function awards.showto(name, to, sid, text)
if name == "" or name == nil then
name = to
end
if text then
if not awards.players[name] or not awards.players[name].unlocked then
minetest.chat_send_player(to, "You have not unlocked any awards")
return
end
minetest.chat_send_player(to, name.."'s awards:")
for _, str in pairs(awards.players[name].unlocked) do
local def = awards.def[str]
if def then
if def.title then
if def.description then
minetest.chat_send_player(to, def.title..": "..def.description)
else
minetest.chat_send_player(to, def.title)
end
else
minetest.chat_send_player(to, str)
end
end
end
else
if sid == nil or sid < 1 then
sid = 1
end
local formspec = "size[11,5]"
local listofawards = awards._order_awards(name)
-- Sidebar
if sid then
local item = listofawards[sid+0]
local def = awards.def[item.name]
if def and def.secret and not item.got then
formspec = formspec .. "label[1,2.75;Secret Award]"..
"image[1,0;3,3;unknown.png]"
if def and def.description then
formspec = formspec .. "label[0,3.25;Unlock this award to find out what it is]"
end
else
local title = item.name
if def and def.title then
title = def.title
end
local status = ""
if item.got then
status = " (got)"
end
local icon = ""
if def and def.icon then
icon = def.icon
end
formspec = formspec .. "label[1,2.75;"..title..status.."]"..
"image[1,0;3,3;"..icon.."]"
if def and def.description then
formspec = formspec .. "label[0,3.25;"..def.description.."]"
end
end
end
-- Create list box
formspec = formspec .. "textlist[4.75,0;6,5;awards;"
local first = true
for _,award in pairs(listofawards) do
local def = awards.def[award.name]
if def then
if not first then
formspec = formspec .. ","
end
first = false
if def.secret and not award.got then
formspec = formspec .. "#ACACACSecret Award"
else
local title = award.name
if def and def.title then
title = def.title
end
if award.got then
formspec = formspec .. minetest.formspec_escape(title)
else
formspec = formspec .. "#ACACAC".. minetest.formspec_escape(title)
end
end
end
end
formspec = formspec .. ";"..sid.."]"
-- Show formspec to user
minetest.show_formspec(to,"awards:awards",formspec)
end
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname~="awards:awards" then
return false
end
if fields.quit then
return true
end
local name = player:get_player_name()
if fields.awards then
local event = minetest.explode_textlist_event(fields.awards)
if event.type == "CHG" then
awards.showto(name,name,event.index,false)
end
end
return true
end)

398
mods/awards/init.lua Normal file
View File

@ -0,0 +1,398 @@
-- AWARDS
-- by Rubenwardy
-------------------------------------------------------
-- this is the init file for the award mod
-------------------------------------------------------
local S
if (intllib) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
dofile(minetest.get_modpath("awards").."/api.lua")
-- Light it up
awards.register_achievement("award_lightitup",{
title = S("Light It Up"),
description = S("Place 100 torches."),
prizes = {"moreblocks:super_glow_glass 5"},
icon = "novicebuilder.png",
trigger = {
type = "place",
node = "default:torch",
target = 100
}
})
-- Light ALL the things!
awards.register_achievement("award_light_all_the_things",{
title = S("Light ALL The Things!"),
description = S("Place 1,000 torches."),
prizes = {"moreblocks:super_glow_glass 25"},
icon = "novicebuilder.png",
trigger = {
type = "place",
node = "default:torch",
target = 1000
}
})
-- Saint-Maclou
if minetest.get_modpath("moreblocks") then
awards.register_achievement("award_saint_maclou",{
title = S("Saint-Maclou"),
description = S("Place 20 coal checkers."),
prizes = {"default:mese 2"},
icon = "novicebuilder.png",
trigger = {
type = "place",
node = "moreblocks:coal_checker",
target = 20
}
})
-- Castorama
awards.register_achievement("award_castorama",{
title = S("Castorama"),
description = S("Place 20 iron checkers."),
prizes = {"default:mese 2"},
icon = "novicebuilder.png",
trigger = {
type = "place",
node = "moreblocks:iron_checker",
target = 20
}
})
-- Sam the Trapper
awards.register_achievement("award_sam_the_trapper",{
title = S("Sam the Trapper"),
description = S("Place 2 trap stones."),
prizes = {"default:stonebrick 10"},
icon = "novicebuilder.png",
trigger = {
type = "place",
node = "moreblocks:trap_stone",
target = 2
}
})
end
-- Obsessed with Obsidian
awards.register_achievement("award_obsessed_with_obsidian",{
title = S("Obsessed with Obsidian"),
description = S("Mine 50 obsidian."),
prizes = {"default:obsidian 10"},
icon = "miniminer.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:obsidian",
target = 50
}
})
-- On the way
awards.register_achievement("award_on_the_way",{
title = S("On The Way"),
description = S("Place 100 rails."),
prizes = {"default:rail 10"},
icon = "novicebuilder.png",
trigger = {
type = "place",
node = "default:rail",
target = 100
}
})
-- Lumberjack
awards.register_achievement("award_lumberjack",{
title = S("Lumberjack"),
description = S("Dig 100 tree blocks."),
prizes = {"default:axe_bronze"},
icon = "default_tree.png",
trigger = {
type = "dig",
node = "default:tree",
target = 100
}
})
-- Semi-pro Lumberjack
awards.register_achievement("award_lumberjack_semipro",{
title = S("Semi-pro Lumberjack"),
description = S("Dig 1,000 tree blocks."),
prizes = {"default:wood 99", "default:axe_mese"},
icon = "default_tree.png",
trigger = {
type = "dig",
node = "default:tree",
target = 1000
}
})
-- Professional Lumberjack
awards.register_achievement("award_lumberjack_professional",{
title = S("Professional Lumberjack"),
description = S("Dig 10,000 tree blocks."),
prizes = {"default:stick 999"},
icon = "default_tree.png",
trigger = {
type = "dig",
node = "default:tree",
target = 10000
}
})
-- L33T Lumberjack
awards.register_achievement("award_lumberjack_leet",{
title = S("L33T Lumberjack"),
description = S("Dig 100,000 tree blocks."),
prizes = {"default:axe_diamond"},
icon = "default_tree.png",
trigger = {
type = "dig",
node = "default:tree",
target = 100000
}
})
-- Junglebaby
awards.register_achievement("award_junglebaby",{
title = S("Junglebaby"),
description = S("Dig 100 jungle tree blocks."),
prizes = {"default:wood 10"},
icon = "default_jungletree.png",
trigger = {
type = "dig",
node = "default:jungletree",
target = 100
}
})
-- Jungleman
awards.register_achievement("award_jungleman",{
title = S("Jungleman"),
description = S("Dig 1,000 jungle tree blocks."),
prizes = {"default:wood 99"},
icon = "default_jungletree.png",
trigger = {
type = "dig",
node = "default:jungletree",
target = 1000
}
})
-- Found some Mese!
awards.register_achievement("award_mesefind",{
title = S("First Mese Find"),
description = S("Find some Mese."),
icon = "default_mese_block.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:stone_with_mese",
target = 1
}
})
-- You're a copper
awards.register_achievement("award_youre_a_copper",{
title = S("You're a copper"),
description = S("Dig 1,000 copper ores."),
prizes = {"default:copper_ingot 20"},
icon = "miniminer.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:stone_with_copper",
target = 1000
}
})
-- You're winner
awards.register_achievement("award_youre_winner",{
title = S("YOU'RE A WINNER!"),
description = S("Dig 1 mossy cobblestone."),
icon = "miniminer.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:mossycobble",
target = 1
},
secret = true,
})
-- Found a Nyan cat!
awards.register_achievement("award_nyanfind",{
title = S("OMG, Nyan Cat!"),
description = S("Find a nyan cat."),
icon = "default_nc_rb.png",
trigger = {
type = "dig",
node = "default:nyancat",
target = 1
}
})
-- Mini Miner
awards.register_achievement("award_mine2",{
title = S("Mini Miner"),
description = S("Dig 100 stone blocks."),
prizes = {"default:steel_ingot"},
icon = "miniminer.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:stone",
target = 100
}
})
-- Hardened Miner
awards.register_achievement("award_mine3",{
title = S("Hardened Miner"),
description = S("Dig 1,000 stone blocks"),
prizes = {"default:pick_mese"},
icon = "miniminer.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:stone",
target = 1000
}
})
-- Master Miner
awards.register_achievement("award_mine4",{
title = S("Master Miner"),
description = S("Dig 10,000 stone blocks."),
prizes = {"default:pick_diamond"},
icon = "miniminer.png",
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:stone",
target = 10000
}
})
-- Marchand de sable
awards.register_achievement("award_marchand_de_sable",{
title = S("Marchand De Sable"),
description = S("Dig 1,000 sand."),
prizes = {"default:shovel_mese"},
background = "bg_mining.png",
trigger = {
type = "dig",
node = "default:sand",
target = 1000
}
})
-- Join
awards.register_achievement("award_join2",{
title = S("Frequent Visitor"),
description = S("Connect to the server 50 times."),
prizes = {"default:sword_mese"},
trigger = {
type = "join",
target = 50
},
secret = true
})
-- Dying Spree
awards.register_achievement("award_dying_spree",{
title = S("Dying Spree"),
description = S("Die 5 times."),
prizes = {"maptools:superapple 2"},
trigger = {
type = "death",
target = 5
}
})
-- Bot-like
awards.register_achievement("award_bot_like",{
title = S("Bot-like"),
description = S("Die 10 times."),
prizes = {"maptools:superapple 4"},
trigger = {
type = "death",
target = 10
}
})
-- You Suck!
awards.register_achievement("award_you_suck",{
title = S("You Suck!"),
description = S("Die 100 times."),
prizes = {"3d_armor:boots_diamond"},
trigger = {
type = "death",
target = 100
},
secret = true
})
-- Burned to death
awards.register_achievement("award_burn",{
title = S("You're a witch!"),
description = S("Burn to death in a fire.")
--prizes = {"default:water_source"}, NE MARCHE PAS
})
awards.register_onDeath(function(player,data)
local pos = player:getpos()
if pos and minetest.find_node_near(pos, 2, "fire:basic_flame") ~= nil then
return "award_burn"
end
return nil
end)
-- Died in flowing lava
awards.register_achievement("award_in_the_flow",{
title = S("In the Flow"),
description = S("Die in flowing lava.")
--prizes = {"default:obsidian"}, NE MARCHE PAS ICI
})
awards.register_onDeath(function(player,data)
local pos = player:getpos()
if pos and minetest.find_node_near(pos, 2, "default:lava_flowing") ~= nil then
return "award_in_the_flow"
end
return nil
end)
-- Die near diamond ore
awards.register_achievement("award_this_is_sad",{
title = S("This is Sad"),
description = S("Die near diamond ore.")
--prizes = {"default:diamond 2"}, NE MARCHE PAS
})
awards.register_onDeath(function(player,data)
local pos = player:getpos()
if pos and minetest.find_node_near(pos, 5, "default:stone_with_diamond") ~= nil then
return "award_this_is_sad"
end
return nil
end)
-- Die near diamond ore
awards.register_achievement("award_the_stack",{
title = S("The Stack"),
description = S("Die near bones.")
})
awards.register_onDeath(function(player,data)
local pos = player:getpos()
if pos and minetest.find_node_near(pos, 5, "bones:bones") ~= nil then
return "award_the_stack"
end
return nil
end)

55
mods/awards/readme.md Normal file
View File

@ -0,0 +1,55 @@
Awards
------
by Andrew "Rubenwardy" Ward, GPL 3.0 or later.
This mod adds achievements to Minetest.
Majority of awards are back ported from Calinou's
old fork in Carbone, under same license.
Code Reference
--------------
The API
=======
* awards.register_achievement(name,data_table)
* name
* desciption
* sound [optional]
* image [optional]
* trigger [optional] [table]
* type - "dig", "place", "death", "chat" or "join"
* (for dig/place type) node - the nodes name
* (for all types) target - how many to dig / place
* secret [optional] - if true, then player needs to unlock to find out what it is.
* awards.give_achievement(name,award)
* -- gives an award to a player
* awards.register_onDig(func(player,data))
* -- return award name or null
* awards.register_onPlace(func(player,data))
* -- return award name or null
* awards.register_onDeath(func(player,data))
* -- return award name or null
* awards.register_onChat(func(player,data))
* -- return award name or null
* awards.register_onJoin(func(player,data))
* -- return award name or null
Player Data
===========
A list of data referenced/hashed by the player's name.
* player name
* name [string]
* count [table] - dig counter
* modname [table]
* itemname [int]
* place [table] - place counter
* modname [table]
* itemname [int]
* deaths
* chats
* joins

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

229
mods/awards/triggers.lua Normal file
View File

@ -0,0 +1,229 @@
-- AWARDS
-- by Rubenwardy
-------------------------------------------------------
-- this is the trigger handler file for the awards mod
-------------------------------------------------------
-- Function and table holders for Triggers
awards.onDig = {}
awards.onPlace = {}
awards.onChat = {}
awards.onDeath = {}
awards.onJoin = {}
-- Trigger Handles
minetest.register_on_dignode(function(pos, oldnode, digger)
if not digger or not pos or not oldnode then
return
end
local nodedug = string.split(oldnode.name, ":")
if #nodedug ~= 2 then
--minetest.log("error","Awards mod: "..oldnode.name.." is in wrong format!")
return
end
local mod = nodedug[1]
local item = nodedug[2]
local playern = digger:get_player_name()
if (not playern or not nodedug or not mod or not item) then
return
end
awards.assertPlayer(playern)
awards.tbv(awards.players[playern].count, mod)
awards.tbv(awards.players[playern].count[mod], item, 0)
-- Increment counter
awards.players[playern].count[mod][item]=awards.players[playern].count[mod][item] + 1
-- Run callbacks and triggers
local player=digger
local data=awards.players[playern]
for i=1,# awards.onDig do
local res = nil
if type(awards.onDig[i]) == "function" then
-- Run trigger callback
res = awards.onDig[i](player,data)
elseif type(awards.onDig[i]) == "table" then
-- Handle table trigger
if not awards.onDig[i].node or not awards.onDig[i].target or not awards.onDig[i].award then
-- table running failed!
print("[ERROR] awards - onDig trigger "..i.." is invalid!")
else
-- run the table
local tnodedug = string.split(awards.onDig[i].node, ":")
local tmod=tnodedug[1]
local titem=tnodedug[2]
if tmod==nil or titem==nil or not data.count[tmod] or not data.count[tmod][titem] then
-- table running failed!
elseif data.count[tmod][titem] > awards.onDig[i].target-1 then
res=awards.onDig[i].award
end
end
end
if res then
awards.give_achievement(playern,res)
end
end
end)
minetest.register_on_placenode(function(pos,node,digger)
if not digger or not pos or not node or not digger:get_player_name() or digger:get_player_name()=="" then
return
end
local nodedug = string.split(node.name, ":")
if #nodedug ~= 2 then
--minetest.log("error","Awards mod: "..node.name.." is in wrong format!")
return
end
local mod=nodedug[1]
local item=nodedug[2]
local playern = digger:get_player_name()
-- Run checks
if (not playern or not nodedug or not mod or not item) then
return
end
awards.assertPlayer(playern)
awards.tbv(awards.players[playern].place, mod)
awards.tbv(awards.players[playern].place[mod], item, 0)
-- Increment counter
awards.players[playern].place[mod][item] = awards.players[playern].place[mod][item] + 1
-- Run callbacks and triggers
local player = digger
local data = awards.players[playern]
for i=1,# awards.onPlace do
local res = nil
if type(awards.onPlace[i]) == "function" then
-- Run trigger callback
res = awards.onPlace[i](player,data)
elseif type(awards.onPlace[i]) == "table" then
-- Handle table trigger
if not awards.onPlace[i].node or not awards.onPlace[i].target or not awards.onPlace[i].award then
print("[ERROR] awards - onPlace trigger "..i.." is invalid!")
else
-- run the table
local tnodedug = string.split(awards.onPlace[i].node, ":")
local tmod = tnodedug[1]
local titem = tnodedug[2]
if tmod==nil or titem==nil or not data.place[tmod] or not data.place[tmod][titem] then
-- table running failed!
elseif data.place[tmod][titem] > awards.onPlace[i].target-1 then
res = awards.onPlace[i].award
end
end
end
if res then
awards.give_achievement(playern,res)
end
end
end)
minetest.register_on_dieplayer(function(player)
-- Run checks
local name = player:get_player_name()
if not player or not name or name=="" then
return
end
-- Get player
awards.assertPlayer(name)
local data = awards.players[name]
-- Increment counter
data.deaths = data.deaths + 1
-- Run callbacks and triggers
for _,trigger in pairs(awards.onDeath) do
local res = nil
if type(trigger) == "function" then
res = trigger(player,data)
elseif type(trigger) == "table" then
if trigger.target and trigger.award then
if data.deaths and data.deaths >= trigger.target then
res = trigger.award
end
end
end
if res ~= nil then
awards.give_achievement(name,res)
end
end
end)
minetest.register_on_joinplayer(function(player)
-- Run checks
local name = player:get_player_name()
if not player or not name or name=="" then
return
end
-- Get player
awards.assertPlayer(name)
local data = awards.players[name]
-- Increment counter
data.joins = data.joins + 1
-- Run callbacks and triggers
for _,trigger in pairs(awards.onJoin) do
local res = nil
if type(trigger) == "function" then
res = trigger(player,data)
elseif type(trigger) == "table" then
if trigger.target and trigger.award then
if data.joins and data.joins >= trigger.target then
res = trigger.award
end
end
end
if res ~= nil then
awards.give_achievement(name,res)
end
end
end)
minetest.register_on_chat_message(function(name, message)
-- Run checks
local idx = string.find(message,"/")
if not name or (idx ~= nil and idx <= 1) then
return
end
-- Get player
awards.assertPlayer(name)
local data = awards.players[name]
local player = minetest.get_player_by_name(name)
-- Increment counter
data.chats = data.chats + 1
-- Run callbacks and triggers
for _,trigger in pairs(awards.onChat) do
local res = nil
if type(trigger) == "function" then
res = trigger(player,data)
elseif type(trigger) == "table" then
if trigger.target and trigger.award then
if data.chats and data.chats >= trigger.target then
res = trigger.award
end
end
end
if res ~= nil then
awards.give_achievement(name,res)
end
end
end)
minetest.register_on_newplayer(function(player)
local playern = player:get_player_name()
awards.assertPlayer(playern)
end)
minetest.register_on_shutdown(function()
awards.save()
end)

46
mods/gauges/init.lua Normal file
View File

@ -0,0 +1,46 @@
-- Adds health bars above players.
-- Code by 4aiman, textures by Calinou. Licensed under CC0.
local hp_bar = {
physical = false,
collisionbox = {x = 0, y = 0, z = 0},
visual = "sprite",
textures = {"20.png"}, -- The texture is changed later in the code.
visual_size = {x = 1.5, y = 0.09375, z = 1.5}, -- Y value is (1 / 16) * 1.5.
wielder = nil,
}
function hp_bar:on_step(dtime)
local wielder = self.wielder
if wielder == nil then
self.object:remove()
return
elseif minetest.get_player_by_name(wielder:get_player_name()) == nil then
self.object:remove()
return
end
hp = wielder:get_hp()
breath = wielder:get_breath()
self.object:set_properties({textures = {"health_" .. tostring(hp) .. ".png^breath_" .. tostring(breath) .. ".png"}})
end
minetest.register_entity("gauges:hp_bar", hp_bar)
function add_HP_gauge(pl)
local pos = pl:getpos()
local ent = minetest.add_entity(pos, "gauges:hp_bar")
if ent ~= nil then
ent:set_attach(pl, "", {x = 0, y = 10, z = 0}, {x = 0, y = 0, z = 0})
ent = ent:get_luaentity()
ent.wielder = pl
end
end
if minetest.setting_getbool("health_bars") ~= false -- “If not defined or set to true then”
and minetest.setting_getbool("enable_damage") then -- Health bars only display when damage is enabled.
minetest.register_on_joinplayer(add_HP_gauge)
end
if minetest.setting_getbool("log_mods") then
minetest.log("action", "Carbone: [gauges] loaded.")
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

13
mods/sprint/LICENSE Normal file
View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

52
mods/sprint/README.md Normal file
View File

@ -0,0 +1,52 @@
Sprint Mod For Minetest by GunshipPenguin
Allows the player to sprint by double tapping w. By default,
sprinting will make the player travel 50% faster and allow him/her
to jump 10% higher.
Licence: WTFPL (see LICENCE file)
---
This mod can be configured by changing the variables declared in
the start of init.lua. The following is a brief explanation of each
one.
SPRINT_SPEED (default 1.5)
How fast the player will move when sprinting as opposed to normal
movement speed. 1.0 represents normal speed so 1.5 would mean that a
sprinting player would travel 50% faster than a walking player and
2.4 would mean that a sprinting player would travel 140% faster than
a walking player.
SPRINT_JUMP (default 1.1)
How high the player will jump when sprinting as opposed to normal
jump height. Same as SPRINT_SPEED, just controls jump height while
sprinting rather than speed.
SPRINT_STAMINA (default 20)
How long the player can sprint for in seconds. Each player has a
stamina variable assigned to them, it is initially set to
SPRINT_STAMINA and can go no higher. When the player is sprinting,
this variable ticks down once each second, and when it reaches 0,
the player stops sprinting and may be sent a warning depending on
the value of SPRINT_WARN. It ticks back up when the player isn't
sprinting and stops at SPRINT_STAMINA. Set this to a huge value if
you want unlimited sprinting.
SPRINT_TIMEOUT (default 0.5)
How much time the player has after releasing w, to press w again and
start sprinting. Setting this too high will result in unwanted
sprinting and setting it too low will result in it being
difficult/impossible to sprint.
SPRINT_WARN (default true)
If the player should be warned that his/her stamina has run out via
the in game chat system. You may want to set this to false if the
notifications get annoying.

108
mods/sprint/init.lua Normal file
View File

@ -0,0 +1,108 @@
--Sprint mod for Minetest by GunshipPenguin
--Configuration variables, these are all explained in README.md
local SPRINT_SPEED = 1.35
local SPRINT_JUMP = 1.1
local SPRINT_STAMINA = 10
local SPRINT_TIMEOUT = 0.5
local SPRINT_WARN = true
STOP_ON_CLICK = true --If true, sprinting will stop when either the left mouse button or the right mouse button is pressed
local players = {}
minetest.register_on_joinplayer(function(player)
players[player:get_player_name()] = {state = 0, timeOut = 0, stamina = SPRINT_STAMINA, moving = false}
end)
minetest.register_on_leaveplayer(function(player)
playerName = player:get_player_name()
players[playerName] = nil
end)
minetest.register_globalstep(function(dtime)
--Get the gametime
local gameTime = minetest.get_gametime()
--Loop through all connected players
for playerName,playerInfo in pairs(players) do
local player = minetest.get_player_by_name(playerName)
if player ~= nil then
--Check if they are moving or not
players[playerName]["moving"] = player:get_player_control()["up"]
-- s'arrete si le joueur fait un clique gauche ou droit
if player:get_player_control()["RMB"] or player:get_player_control()["LMB"] and STOP_ON_CLICK == true then
players[playerName]["state"] = 0
player:set_physics_override({speed=1.0, jump=1.0})
end
--If the player has tapped w longer than SPRINT_TIMEOUT ago, set his/her state to 0
if playerInfo["state"] == 2 then
if playerInfo["timeOut"] + SPRINT_TIMEOUT < gameTime then
players[playerName]["timeOut"] = nil
setState(playerName, 0)
end
--If the player is sprinting, create particles behind him/her
elseif playerInfo["state"] == 3 and gameTime % 0.1 == 0 then
local numParticles = math.random(1, 2)
local playerPos = player:getpos()
local playerNode = minetest.get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]})
if playerNode["name"] ~= "air" then
for i=1, numParticles, 1 do
minetest.add_particle({
pos = {x=playerPos["x"]+math.random(-1,1)*math.random()/2,y=playerPos["y"]+0.1,z=playerPos["z"]+math.random(-1,1)*math.random()/2},
vel = {x=0, y=5, z=0},
acc = {x=0, y=-13, z=0},
expirationtime = math.random(),
size = math.random()+0.5,
collisiondetection = true,
vertical = false,
texture = "default_dirt.png",
})
end
end
end
--Adjust player states
if players[playerName]["moving"] == false and playerInfo["state"] == 3 then --Stopped
setState(playerName, 0)
elseif players[playerName]["moving"] == true and playerInfo["state"] == 0 then --Moving
setState(playerName, 1)
elseif players[playerName]["moving"] == false and playerInfo["state"] == 1 then --Primed
setState(playerName, 2)
elseif players[playerName]["moving"] == true and playerInfo["state"] == 2 then --Sprinting
setState(playerName, 3)
end
--Lower the player's stamina by dtime if he/she is sprinting and set his/her state to 0 if stamina is zero
if playerInfo["state"] == 3 then
playerInfo["stamina"] = playerInfo["stamina"] - dtime
if playerInfo["stamina"] <= 0 then
playerInfo["stamina"] = 0
setState(playerName, 0)
if SPRINT_WARN then
minetest.chat_send_player(playerName, "Votre sprint s'arrete, plus d'endurance ! Your sprint stamina has run out !")
end
end
--Increase player's stamina if he/she is not sprinting and his/her stamina is less than SPRINT_STAMINA
elseif playerInfo["state"] ~= 3 and playerInfo["stamina"] < SPRINT_STAMINA then
playerInfo["stamina"] = playerInfo["stamina"] + dtime
end
end
end
end)
function setState(playerName, state) --Sets the state of a player (0=stopped, 1=moving, 2=primed, 3=sprinting)
local player = minetest.get_player_by_name(playerName)
local gameTime = minetest.get_gametime()
if players[playerName] then
players[playerName]["state"] = state
if state == 0 then--Stopped
player:set_physics_override({speed=1.0,jump=1.0})
elseif state == 2 then --Primed
players[playerName]["timeOut"] = gameTime
elseif state == 3 then --Sprinting
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
end
return true
end
return false
end