Remove [awards], to be eventually replaced by quests
22
mods/awards/.gitattributes
vendored
|
@ -1,22 +0,0 @@
|
|||
# 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
|
@ -1,215 +0,0 @@
|
|||
#################
|
||||
## 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
|
|
@ -1,510 +0,0 @@
|
|||
-- 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()
|
||||
minetest.sound_play("award_award_won", {to_player = name, gain = soundset.get_gain(name,"other")})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--MFF crabman(20/07/2015) add button inventory
|
||||
if (minetest.get_modpath("unified_inventory")) then
|
||||
unified_inventory.register_button("menu_award", {
|
||||
type = "image",
|
||||
image = "miniminer.png",
|
||||
tooltip = "List My Award",
|
||||
show_with = false,
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if not name then return end
|
||||
awards.showto(name, name, nil, false)
|
||||
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)
|
||||
|
|
@ -1 +0,0 @@
|
|||
soundset
|
|
@ -1,398 +0,0 @@
|
|||
-- AWARDS
|
||||
-- by Rubenwardy
|
||||
-------------------------------------------------------
|
||||
-- this is the init file for the award mod
|
||||
-------------------------------------------------------
|
||||
|
||||
local S
|
||||
if (minetest.get_modpath("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)
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
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
|
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 204 B |
|
@ -1,229 +0,0 @@
|
|||
-- 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)
|
|
@ -154,7 +154,6 @@ load_mod_mana = true
|
|||
load_mod_solarmana = true
|
||||
load_mod_runes = false
|
||||
load_mod_broomstick = true
|
||||
load_mod_awards = true
|
||||
load_mod_fail = true
|
||||
|
||||
load_mod_unified_inventory = true
|
||||
|
|