Compare commits
1 Commits
imgbot
...
code-quali
Author | SHA1 | Date | |
---|---|---|---|
f81cb10f20 |
14
.github/workflows/integration-test.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: integration-test
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: integration-test
|
||||||
|
run: ./integration-test.sh
|
17
.github/workflows/luacheck.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: luacheck
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: apt
|
||||||
|
run: sudo apt-get install -y luarocks
|
||||||
|
- name: luacheck install
|
||||||
|
run: luarocks install --local luacheck
|
||||||
|
- name: luacheck run
|
||||||
|
run: $HOME/.luarocks/bin/luacheck ./
|
34
.luacheckrc
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
unused_args = false
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"wieldview",
|
||||||
|
"armor",
|
||||||
|
"armor_i18n",
|
||||||
|
"inventory_plus"
|
||||||
|
}
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
-- Stdlib
|
||||||
|
string = {fields = {"split"}},
|
||||||
|
table = {fields = {"copy", "getn"}},
|
||||||
|
|
||||||
|
-- Minetest
|
||||||
|
"vector", "ItemStack",
|
||||||
|
"dump", "VoxelArea",
|
||||||
|
|
||||||
|
-- deps
|
||||||
|
"default",
|
||||||
|
"minetest",
|
||||||
|
"unified_inventory",
|
||||||
|
"intllib",
|
||||||
|
"wardrobe",
|
||||||
|
"player_monoids",
|
||||||
|
"armor_monoid",
|
||||||
|
"sfinv",
|
||||||
|
"ARMOR_MATERIALS",
|
||||||
|
"ARMOR_FIRE_NODES",
|
||||||
|
"pova",
|
||||||
|
"skins",
|
||||||
|
"u_skins"
|
||||||
|
}
|
@ -185,7 +185,6 @@ armor.set_player_armor = function(self, player)
|
|||||||
local material = {count=1}
|
local material = {count=1}
|
||||||
local preview = armor:get_preview(name)
|
local preview = armor:get_preview(name)
|
||||||
local texture = "3d_armor_trans.png"
|
local texture = "3d_armor_trans.png"
|
||||||
local textures = {}
|
|
||||||
local physics = {}
|
local physics = {}
|
||||||
local attributes = {}
|
local attributes = {}
|
||||||
local levels = {}
|
local levels = {}
|
||||||
@ -324,8 +323,8 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili
|
|||||||
local list = armor_inv:get_list("armor")
|
local list = armor_inv:get_list("armor")
|
||||||
for i, stack in pairs(list) do
|
for i, stack in pairs(list) do
|
||||||
if stack:get_count() == 1 then
|
if stack:get_count() == 1 then
|
||||||
local name = stack:get_name()
|
local itemname = stack:get_name()
|
||||||
local use = minetest.get_item_group(name, "armor_use") or 0
|
local use = minetest.get_item_group(itemname, "armor_use") or 0
|
||||||
local damage = use > 0
|
local damage = use > 0
|
||||||
local def = stack:get_definition() or {}
|
local def = stack:get_definition() or {}
|
||||||
if type(def.on_punched) == "function" then
|
if type(def.on_punched) == "function" then
|
||||||
@ -373,7 +372,7 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if damage == true and hitter == "fire" then
|
if damage == true and hitter == "fire" then
|
||||||
damage = minetest.get_item_group(name, "flammable") > 0
|
damage = minetest.get_item_group(itemname, "flammable") > 0
|
||||||
end
|
end
|
||||||
if damage == true then
|
if damage == true then
|
||||||
self:damage(player, i, stack, use)
|
self:damage(player, i, stack, use)
|
||||||
|
@ -15,19 +15,23 @@ local F = minetest.formspec_escape
|
|||||||
|
|
||||||
dofile(modpath.."/api.lua")
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
|
-- integration test
|
||||||
|
if minetest.settings:get_bool("enable_3d_armor_integration_test") then
|
||||||
|
dofile(modpath.."/integration_test.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Legacy Config Support
|
-- Legacy Config Support
|
||||||
|
|
||||||
local input = io.open(modpath.."/armor.conf", "r")
|
local input = io.open(modpath.."/armor.conf", "r")
|
||||||
if input then
|
if input then
|
||||||
dofile(modpath.."/armor.conf")
|
dofile(modpath.."/armor.conf")
|
||||||
input:close()
|
input:close()
|
||||||
input = nil
|
|
||||||
end
|
end
|
||||||
input = io.open(worldpath.."/armor.conf", "r")
|
input = io.open(worldpath.."/armor.conf", "r")
|
||||||
if input then
|
if input then
|
||||||
dofile(worldpath.."/armor.conf")
|
dofile(worldpath.."/armor.conf")
|
||||||
input:close()
|
input:close()
|
||||||
input = nil
|
|
||||||
end
|
end
|
||||||
for name, _ in pairs(armor.config) do
|
for name, _ in pairs(armor.config) do
|
||||||
local global = "ARMOR_"..name:upper()
|
local global = "ARMOR_"..name:upper()
|
||||||
@ -169,9 +173,9 @@ local function validate_armor_inventory(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init_player_armor(player)
|
local function init_player_armor(initplayer)
|
||||||
local name = player:get_player_name()
|
local name = initplayer:get_player_name()
|
||||||
local pos = player:get_pos()
|
local pos = initplayer:get_pos()
|
||||||
if not name or not pos then
|
if not name or not pos then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -214,20 +218,20 @@ local function init_player_armor(player)
|
|||||||
end,
|
end,
|
||||||
}, name)
|
}, name)
|
||||||
armor_inv:set_size("armor", 6)
|
armor_inv:set_size("armor", 6)
|
||||||
if not armor:load_armor_inventory(player) and armor.migrate_old_inventory then
|
if not armor:load_armor_inventory(initplayer) and armor.migrate_old_inventory then
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = initplayer:get_inventory()
|
||||||
player_inv:set_size("armor", 6)
|
player_inv:set_size("armor", 6)
|
||||||
for i=1, 6 do
|
for i=1, 6 do
|
||||||
local stack = player_inv:get_stack("armor", i)
|
local stack = player_inv:get_stack("armor", i)
|
||||||
armor_inv:set_stack("armor", i, stack)
|
armor_inv:set_stack("armor", i, stack)
|
||||||
end
|
end
|
||||||
armor:save_armor_inventory(player)
|
armor:save_armor_inventory(initplayer)
|
||||||
player_inv:set_size("armor", 0)
|
player_inv:set_size("armor", 0)
|
||||||
end
|
end
|
||||||
for i=1, 6 do
|
for i=1, 6 do
|
||||||
local stack = armor_inv:get_stack("armor", i)
|
local stack = armor_inv:get_stack("armor", i)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
armor:run_callbacks("on_equip", player, i, stack)
|
armor:run_callbacks("on_equip", initplayer, i, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
armor.def[name] = {
|
armor.def[name] = {
|
||||||
@ -263,7 +267,7 @@ local function init_player_armor(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
armor:set_player_armor(player)
|
armor:set_player_armor(initplayer)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -291,24 +295,31 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if not name then
|
if not name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local player_name = player:get_player_name()
|
||||||
for field, _ in pairs(fields) do
|
for field, _ in pairs(fields) do
|
||||||
if string.find(field, "skins_set") then
|
if string.find(field, "skins_set") then
|
||||||
minetest.after(0, function(player)
|
minetest.after(0, function()
|
||||||
local skin = armor:get_player_skin(name)
|
local pplayer = minetest.get_player_by_name(player_name)
|
||||||
armor.textures[name].skin = skin
|
if player then
|
||||||
armor:set_player_armor(player)
|
local skin = armor:get_player_skin(name)
|
||||||
end, player)
|
armor.textures[name].skin = skin
|
||||||
|
armor:set_player_armor(pplayer)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
default.player_set_model(player, "3d_armor_character.b3d")
|
default.player_set_model(player, "3d_armor_character.b3d")
|
||||||
minetest.after(0, function(player)
|
local player_name = player:get_player_name()
|
||||||
if init_player_armor(player) == false then
|
|
||||||
pending_players[player] = 0
|
minetest.after(0, function()
|
||||||
|
local pplayer = minetest.get_player_by_name(player_name)
|
||||||
|
if pplayer and init_player_armor(pplayer) == false then
|
||||||
|
pending_players[pplayer] = 0
|
||||||
end
|
end
|
||||||
end, player)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
25
3d_armor/integration_test.lua
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
minetest.log("warning", "[TEST] integration-test enabled!")
|
||||||
|
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
|
minetest.after(1, function()
|
||||||
|
|
||||||
|
local data = minetest.write_json({ success = true }, true);
|
||||||
|
local file = io.open(minetest.get_worldpath().."/integration_test.json", "w" );
|
||||||
|
if file then
|
||||||
|
file:write(data)
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
file = io.open(minetest.get_worldpath().."/registered_nodes.txt", "w" );
|
||||||
|
if file then
|
||||||
|
for name in pairs(minetest.registered_nodes) do
|
||||||
|
file:write(name .. '\n')
|
||||||
|
end
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.log("warning", "[TEST] integration tests done!")
|
||||||
|
minetest.request_shutdown("success")
|
||||||
|
end)
|
||||||
|
end)
|
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 383 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 376 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 383 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 383 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 393 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 500 B After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 504 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 514 B After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 437 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 476 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 468 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 464 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 476 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 476 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 433 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 400 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 423 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 2.9 KiB |