summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorrubenwardy <anjayward@gmail.com>2014-05-02 19:01:41 +0100
committerrubenwardy <anjayward@gmail.com>2014-05-02 19:01:41 +0100
commit8adf859127a3cf3218811c3e6d9ff4b6a3aff1a8 (patch)
tree216da5193d79c7d7e66c719b6c53f5dc79a1f1e5 /api.lua
parent8180ab6755816e68e136357631d1a306aef01e4f (diff)
On chat trigger and code style
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua47
1 files changed, 29 insertions, 18 deletions
diff --git a/api.lua b/api.lua
index dcef787..b0bf068 100644
--- a/api.lua
+++ b/api.lua
@@ -43,7 +43,7 @@ function awards.tbv(tb,value,default)
if not value then
value = "[NULL]"
end
- minetest.log("error", "awards.tbv - table '"..value.."' is null, or not a table! Dump: "..dump(tb))
+ minetest.log("error", "awards.tbv - table "..dump(value).." is null, or not a table! Dump: "..dump(tb))
return
end
if not value then
@@ -74,26 +74,32 @@ dofile(minetest.get_modpath("awards").."/config.txt")
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,
+ 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,
+ 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,
+ 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)
end
end
@@ -113,21 +119,26 @@ function awards.register_achievement(name,data_table)
awards.def[name] = data_table
end
--- this function adds a trigger function or table to the ondig table
+-- run a function when a node is dug
function awards.register_onDig(func)
table.insert(awards.onDig,func)
end
--- this function adds a trigger function or table to the ondig table
+-- run a function when a node is placed
function awards.register_onPlace(func)
table.insert(awards.onPlace,func)
end
--- this function adds a trigger function or table to the ondeath table
+-- 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
+
-- 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