commit 4d94752ae3854c969211d8d5a10f644cd45315ac Author: A. Demant Date: Wed Jan 9 16:23:44 2019 +0100 initial commit diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..6bf080a --- /dev/null +++ b/README.txt @@ -0,0 +1,25 @@ +Minetest Game mod: XPFW +========================== +See license.txt for license information. + +XPFW provide an API for storing values relevant for experience mechanism into player metadata. It also stores several statistic values during playtime: +- Walked distances calculated out of velocity (important: teleporting does not influence this value) +- accumulated distance out of comparing with last known position (important: teleporting is included in this value) +- whole playtime on the server +- amount of dug nodes +- amount of build nodes +- amount of crafted items +- amount of occured deahts +- amount of text messages +- amount of logins + +For several amounts also a kind of speed is calculated, like walking speed or crafting speed. + +Authors of source code +---------------------- +ademant (MIT) + +Authors of media (textures) +--------------------------- + +Created by ademant (CC BY 3.0): diff --git a/chat_commands.lua b/chat_commands.lua new file mode 100644 index 0000000..d95c6b9 --- /dev/null +++ b/chat_commands.lua @@ -0,0 +1,16 @@ + +minetest.register_chatcommand("cd", { + params = "", + description = "Start a countdown", + func = function(name, param) +-- print(name,param) + local countdown=timer.countdown_default + local xp= string.split(param, " ") + if #xp == 1 then + countdown=tonumber(xp[1]) + elseif #xp >1 then + countdown=tonumber(xp[2]) + end + timer.player[name]=countdown + end +}) diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..adc3ff3 --- /dev/null +++ b/config.lua @@ -0,0 +1,8 @@ + +timer.precision=tonumber(minetest.settings:get("timer.precision")) or 1 +timer.countdown_default=tonumber(minetest.settings:get("timer.countdown_default")) or 120 +timer.prefix="timer:countdown" +timer.player={} +timer.dtime=0 + +--xpfw.register_attribute(timer.prefix,{min=0,max=math.huge,default=timer.countdown_default,hud=1}) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..2f2bdfa --- /dev/null +++ b/init.lua @@ -0,0 +1,16 @@ + +timer = {} +timer.path = minetest.get_modpath("timer") +timer.modname=minetest.get_current_modname() +timer.mod_storage=minetest.get_mod_storage() + +minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- start loading from "..minetest.get_modpath(minetest.get_current_modname())) +-- Load files + +-- import settingtypes.txt +basic_functions.import_settingtype(timer.path .. "/settingtypes.txt") + +dofile(timer.path .. "/config.lua") -- API +dofile(timer.path .. "/chat_commands.lua") + +minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded ") diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..d0b0299 --- /dev/null +++ b/license.txt @@ -0,0 +1,15 @@ +License of source code +---------------------- + +The MIT License (MIT) +Copyright 2019 ademant + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more details: +https://opensource.org/licenses/mit-license.php + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..10614cd --- /dev/null +++ b/mod.conf @@ -0,0 +1,7 @@ +name = timer +title = timer +author = ademant +description = Use Countdown timer +depends = default,basic_functions,xpfw +license = MIT +version = 1.0.0 diff --git a/register.lua b/register.lua new file mode 100644 index 0000000..612030a --- /dev/null +++ b/register.lua @@ -0,0 +1,22 @@ +local M=timer + +minetest.register_on_joinplayer(function(player) + xpfw.player_set_attribute(player,timer.prefix,0) +end +) + +minetest.register_on_leaveplayer(function(player) + if player ~= nil then +-- xpfw.player_set_attribute(player,timer.prefix,0) + end +end) + + +minetest.register_globalstep(function(dtime) + timer.dtime=timer.dtime+dtime + if timer.dtime>timer.precision then + timer.dtime=0 + + end +-- print("xpfw_abm: "..1000*(os.clock()-starttime)) +end) diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..ab00143 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +timer.precision (precision of the timer in real time seconds) float 1 +timer.countdown_default (default value of countdown in seconds) float 120