Compare commits
7 Commits
nalc-1.2.0
...
code-quali
Author | SHA1 | Date | |
---|---|---|---|
f81cb10f20 | |||
f3ad7ec6f1 | |||
fccd4d8b15 | |||
e5b2cf3a34 | |||
d2608351f6 | |||
a05eae3782 | |||
2ac90f8d19 |
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 preview = armor:get_preview(name)
|
||||
local texture = "3d_armor_trans.png"
|
||||
local textures = {}
|
||||
local physics = {}
|
||||
local attributes = {}
|
||||
local levels = {}
|
||||
@ -279,6 +278,11 @@ armor.set_player_armor = function(self, player)
|
||||
if use_armor_monoid then
|
||||
armor_monoid.monoid:add_change(player, change, "3d_armor:armor")
|
||||
else
|
||||
-- Preserve immortal group (damage disabled for player)
|
||||
local immortal = player:get_armor_groups().immortal
|
||||
if immortal and immortal ~= 0 then
|
||||
groups.immortal = 1
|
||||
end
|
||||
player:set_armor_groups(groups)
|
||||
end
|
||||
if use_player_monoids then
|
||||
@ -319,8 +323,8 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili
|
||||
local list = armor_inv:get_list("armor")
|
||||
for i, stack in pairs(list) do
|
||||
if stack:get_count() == 1 then
|
||||
local name = stack:get_name()
|
||||
local use = minetest.get_item_group(name, "armor_use") or 0
|
||||
local itemname = stack:get_name()
|
||||
local use = minetest.get_item_group(itemname, "armor_use") or 0
|
||||
local damage = use > 0
|
||||
local def = stack:get_definition() or {}
|
||||
if type(def.on_punched) == "function" then
|
||||
@ -368,7 +372,7 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili
|
||||
end
|
||||
end
|
||||
if damage == true and hitter == "fire" then
|
||||
damage = minetest.get_item_group(name, "flammable") > 0
|
||||
damage = minetest.get_item_group(itemname, "flammable") > 0
|
||||
end
|
||||
if damage == true then
|
||||
self:damage(player, i, stack, use)
|
||||
|
@ -15,19 +15,23 @@ local F = minetest.formspec_escape
|
||||
|
||||
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
|
||||
|
||||
local input = io.open(modpath.."/armor.conf", "r")
|
||||
if input then
|
||||
dofile(modpath.."/armor.conf")
|
||||
input:close()
|
||||
input = nil
|
||||
end
|
||||
input = io.open(worldpath.."/armor.conf", "r")
|
||||
if input then
|
||||
dofile(worldpath.."/armor.conf")
|
||||
input:close()
|
||||
input = nil
|
||||
end
|
||||
for name, _ in pairs(armor.config) do
|
||||
local global = "ARMOR_"..name:upper()
|
||||
@ -99,17 +103,27 @@ armor.formspec = armor.formspec..
|
||||
if armor.config.fire_protect then
|
||||
armor.formspec = armor.formspec.."label[5,2;"..F(S("Fire"))..": armor_attr_fire]"
|
||||
end
|
||||
armor:register_on_damage(function(player, index, stack)
|
||||
local name = player:get_player_name()
|
||||
local def = stack:get_definition()
|
||||
if name and def and def.description and stack:get_wear() > 60100 then
|
||||
minetest.chat_send_player(name, S("Your @1 is almost broken!", def.description))
|
||||
minetest.sound_play("default_tool_breaks", {to_player = name, gain = 2.0})
|
||||
end
|
||||
end)
|
||||
armor:register_on_destroy(function(player, index, stack)
|
||||
local name = player:get_player_name()
|
||||
local def = stack:get_definition()
|
||||
if name and def and def.description then
|
||||
minetest.chat_send_player(name, S("Your @1 got destroyed!", def.description))
|
||||
minetest.sound_play("default_tool_breaks", {to_player = name, gain = 2.0})
|
||||
end
|
||||
end)
|
||||
|
||||
local function validate_armor_inventory(player)
|
||||
-- Workaround for detached inventory swap exploit
|
||||
local _, inv = armor:get_valid_player(player, "[validate_armor_inventory]")
|
||||
local pos = player:get_pos()
|
||||
if not inv then
|
||||
return
|
||||
end
|
||||
@ -140,6 +154,7 @@ local function validate_armor_inventory(player)
|
||||
elements[element] = true;
|
||||
else
|
||||
inv:remove_item("armor", stack)
|
||||
minetest.item_drop(stack, player, pos)
|
||||
-- The following code returns invalid items to the player's main
|
||||
-- inventory but could open up the possibity for a hacked client
|
||||
-- to receive items back they never really had. I am not certain
|
||||
@ -158,9 +173,9 @@ local function validate_armor_inventory(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function init_player_armor(player)
|
||||
local name = player:get_player_name()
|
||||
local pos = player:get_pos()
|
||||
local function init_player_armor(initplayer)
|
||||
local name = initplayer:get_player_name()
|
||||
local pos = initplayer:get_pos()
|
||||
if not name or not pos then
|
||||
return false
|
||||
end
|
||||
@ -203,20 +218,20 @@ local function init_player_armor(player)
|
||||
end,
|
||||
}, name)
|
||||
armor_inv:set_size("armor", 6)
|
||||
if not armor:load_armor_inventory(player) and armor.migrate_old_inventory then
|
||||
local player_inv = player:get_inventory()
|
||||
if not armor:load_armor_inventory(initplayer) and armor.migrate_old_inventory then
|
||||
local player_inv = initplayer:get_inventory()
|
||||
player_inv:set_size("armor", 6)
|
||||
for i=1, 6 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
armor_inv:set_stack("armor", i, stack)
|
||||
end
|
||||
armor:save_armor_inventory(player)
|
||||
armor:save_armor_inventory(initplayer)
|
||||
player_inv:set_size("armor", 0)
|
||||
end
|
||||
for i=1, 6 do
|
||||
local stack = armor_inv:get_stack("armor", i)
|
||||
if stack:get_count() > 0 then
|
||||
armor:run_callbacks("on_equip", player, i, stack)
|
||||
armor:run_callbacks("on_equip", initplayer, i, stack)
|
||||
end
|
||||
end
|
||||
armor.def[name] = {
|
||||
@ -252,7 +267,7 @@ local function init_player_armor(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
armor:set_player_armor(player)
|
||||
armor:set_player_armor(initplayer)
|
||||
return true
|
||||
end
|
||||
|
||||
@ -280,24 +295,31 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if not name then
|
||||
return
|
||||
end
|
||||
local player_name = player:get_player_name()
|
||||
for field, _ in pairs(fields) do
|
||||
if string.find(field, "skins_set") then
|
||||
minetest.after(0, function(player)
|
||||
local skin = armor:get_player_skin(name)
|
||||
armor.textures[name].skin = skin
|
||||
armor:set_player_armor(player)
|
||||
end, player)
|
||||
minetest.after(0, function()
|
||||
local pplayer = minetest.get_player_by_name(player_name)
|
||||
if player then
|
||||
local skin = armor:get_player_skin(name)
|
||||
armor.textures[name].skin = skin
|
||||
armor:set_player_armor(pplayer)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_set_model(player, "3d_armor_character.b3d")
|
||||
minetest.after(0, function(player)
|
||||
if init_player_armor(player) == false then
|
||||
pending_players[player] = 0
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
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, player)
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
@ -330,8 +352,8 @@ if armor.config.drop == true or armor.config.destroy == true then
|
||||
if pos and armor.config.destroy == false then
|
||||
minetest.after(armor.config.bones_delay, function()
|
||||
local meta = nil
|
||||
local maxp = vector.add(pos, 8)
|
||||
local minp = vector.subtract(pos, 8)
|
||||
local maxp = vector.add(pos, 16)
|
||||
local minp = vector.subtract(pos, 16)
|
||||
local bones = minetest.find_nodes_in_area(minp, maxp, {"bones:bones"})
|
||||
for _, p in pairs(bones) do
|
||||
local m = minetest.get_meta(p)
|
||||
|
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: 389 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 347 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: 361 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 414 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: 431 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 493 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 469 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 343 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: 343 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 478 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 350 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 473 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 337 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 379 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: 414 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 430 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 365 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 381 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: 366 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 365 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 365 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 359 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 414 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: 363 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 2.9 KiB |