Move version handling into base API.

This commit is contained in:
Aaron Suen 2019-02-04 20:15:33 -05:00
parent a8009f4c0c
commit d39b3a3949
4 changed files with 58 additions and 50 deletions

View File

@ -1,33 +1,44 @@
-- LUALOCALS < ---------------------------------------------------------
-- SKIP: nodecore
local dofile, minetest, rawget, rawset
= dofile, minetest, rawget, rawset
local dofile, minetest, rawget, rawset, table
= dofile, minetest, rawget, rawset, table
local table_concat, table_insert
= table.concat, table.insert
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local nodecore = rawget(_G, "nodecore") or {}
rawset(_G, "nodecore", nodecore)
local path = minetest.get_modpath(modname)
local include = rawget(_G, "include") or function(...)
local parts = {...}
table_insert(parts, 1, minetest.get_modpath(minetest.get_current_modname()))
if parts[#parts]:sub(-4) ~= ".lua" then
parts[#parts] = parts[#parts] .. ".lua"
end
minetest.log(table_concat(parts, "/"))
return dofile(table_concat(parts, "/"))
end
rawset(_G, "include", include)
dofile(path .. "/issue7020.lua")
nodecore.version = include("version")
dofile(path .. "/util_misc.lua")
dofile(path .. "/util_scan_flood.lua")
dofile(path .. "/util_logtrace.lua")
dofile(path .. "/util_node_is.lua")
dofile(path .. "/util_toolcaps.lua")
include("issue7020")
dofile(path .. "/register_craft.lua")
dofile(path .. "/register_limited_abm.lua")
include("util_misc")
include("util_scan_flood")
include("util_logtrace")
include("util_node_is")
include("util_toolcaps")
dofile(path .. "/item_on_register.lua")
dofile(path .. "/item_drop_in_place.lua")
dofile(path .. "/item_falling_repose.lua")
dofile(path .. "/item_alternate_loose.lua")
dofile(path .. "/item_group_visinv.lua")
dofile(path .. "/item_oldnames.lua")
dofile(path .. "/item_tool_wears_to.lua")
include("register_craft")
include("register_limited_abm")
dofile(path .. "/action_node_pummel.lua")
include("item_on_register")
include("item_drop_in_place")
include("item_falling_repose")
include("item_alternate_loose")
include("item_group_visinv")
include("item_oldnames")
include("item_tool_wears_to")
include("action_node_pummel")

View File

@ -6,10 +6,7 @@ local math_floor
-- LUALOCALS > ---------------------------------------------------------
local stamp = tonumber("$Format:%at$")
if not stamp then
return "DEVELOPMENT VERSION"
end
if not stamp then return end
stamp = math_floor((stamp - 1540612800) / 60)
stamp = ("00000000" .. stamp):sub(-8)
return "Version " .. stamp .. "-$Format:%h$"
return stamp .. "-$Format:%h$"

View File

@ -6,23 +6,23 @@ local minetest
local health_bar_definition =
{
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
position = {x = 0.5, y = 1},
text = "heart_bg.png",
number = 20,
direction = 0,
size = { x=24, y=24 },
offset = { x=(-10*24)-25, y=-(48+24+16)},
size = {x = 24, y = 24},
offset = { x = (-10 * 24) - 25, y = -(48 + 24 + 16)},
}
local breath_bar_definition =
{
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
position = {x = 0.5, y = 1},
text = "bubble_bg.png",
number = 20,
direction = 0,
size = { x=24, y=24 },
offset = {x=25,y=-(48+24+16)},
size = {x = 24, y = 24},
offset = {x = 25, y = -(48 + 24 + 16)},
}
local reg_bubbles = {}

View File

@ -1,12 +1,24 @@
-- LUALOCALS < ---------------------------------------------------------
local dofile, minetest, nodecore
= dofile, minetest, nodecore
local minetest, nodecore
= minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local path = minetest.get_modpath(modname)
local version = nodecore.version
version = version and ("Version " .. version) or "DEVELOPMENT VERSION"
local version = dofile(path .. "/version.lua")
local formspec = "size[8,5]"
.. "bgcolor[#000000C0;true]"
.. "background[0,0;8,5;nc_player_invbg.png;true]"
.. "listcolors[#00000000;#00000000;#00000000;#000000FF;#FFFFFFFF]"
.. "list[current_player;main;0,4;8,5;]"
.. "box[-0.25,-0.25;8.5,3.25;#000000C0]"
.. "label[0,0;NodeCore - "
.. minetest.formspec_escape(version)
.. "\n\n"
.. "(C)2018-2019 by Aaron Suen <warr1024@gmail.com>\n"
.. "MIT License: http://www.opensource.org/licenses/MIT\n\n"
.. "GitLab: https://gitlab.com/sztest/nodecore\n"
.. "Discord: https://discord.gg/SHq2tkb]"
minetest.register_on_joinplayer(function(player)
player:set_properties({
@ -21,19 +33,7 @@ minetest.register_on_joinplayer(function(player)
player:hud_set_hotbar_image("nc_hud_bg.png")
player:hud_set_hotbar_selected_image("nc_hud_sel.png")
player:set_inventory_formspec("size[8,5]"
.. "bgcolor[#000000C0;true]"
.. "background[0,0;8,5;nc_player_invbg.png;true]"
.. "listcolors[#00000000;#00000000;#00000000;#000000FF;#FFFFFFFF]"
.. "list[current_player;main;0,4;8,5;]"
.. "box[-0.25,-0.25;8.5,3.25;#000000C0]"
.. "label[0,0;NodeCore - "
.. minetest.formspec_escape(version)
.. "\n\n"
.. "(C)2018-2019 by Aaron Suen <warr1024@gmail.com>\n"
.. "MIT License: http://www.opensource.org/licenses/MIT\n\n"
.. "GitLab: https://gitlab.com/sztest/nodecore\n"
.. "Discord: https://discord.gg/SHq2tkb]")
player:set_inventory_formspec(formspec)
end)
minetest.register_on_dieplayer(function(player)