Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mineunit tests load mod #5

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5605ed7
change <world>/technic.conf:enable_wrench_crafting -> minetest.conf:w…
nixnoxus Nov 29, 2021
8590d7b
add bones support
nixnoxus Nov 29, 2021
7ceec2a
add connected_chests support
nixnoxus Nov 29, 2021
c784eb9
add xdecor support
nixnoxus Nov 29, 2021
9e99f5d
add pipeworks support [WIP]
nixnoxus Nov 29, 2021
b776d6e
add "technic:injector" support
nixnoxus Nov 29, 2021
e67ce4d
update luacheck
nixnoxus Nov 30, 2021
803d391
update README.md
nixnoxus Nov 30, 2021
f646673
add "pipeworks:nodebreaker_*" support
nixnoxus Dec 1, 2021
c0fb5e0
Update README.md
nixnoxus Dec 1, 2021
2581e19
support node timers
OgelGames Dec 1, 2021
93c3806
adjust craft recipe
OgelGames Dec 1, 2021
45edd1b
fixes
OgelGames Dec 1, 2021
ca83ab2
`more_chests` support
OgelGames Dec 1, 2021
61b3b62
remove the use of translated()
nixnoxus Dec 1, 2021
468ac9c
update README.md
nixnoxus Dec 1, 2021
b4063a5
fix node timers
nixnoxus Dec 1, 2021
5453122
add "pipeworks:*filter" support
nixnoxus Dec 1, 2021
23af4f0
if timeout then
nixnoxus Dec 2, 2021
1fe5ea3
`3d_armor_stand` support
OgelGames Dec 2, 2021
8cf6a7a
add missing optional deps
OgelGames Dec 2, 2021
56d39bb
support node drop
nixnoxus Dec 2, 2021
6a4550b
drop pipeworks wielder in state "off" like digging
nixnoxus Dec 2, 2021
d449bda
add some "pipeworks:*tube*" support
nixnoxus Dec 2, 2021
91f9a8a
`def.drop` can be a string or a boolean
nixnoxus Dec 2, 2021
166d073
nodes/pipeworks.lua
nixnoxus Dec 2, 2021
f73a8da
update luacheck
nixnoxus Dec 2, 2021
26aa3a3
move handling for `def.drop` to `wrench.register_node()`
OgelGames Dec 3, 2021
42c6585
add `def.after_pickup` and always update tube nodes
OgelGames Dec 3, 2021
62f05cb
move api functions to api.lua
OgelGames Dec 3, 2021
25a0965
little code fixes
OgelGames Dec 3, 2021
5992fe1
`biofuel` refinery support
OgelGames Dec 3, 2021
b90694e
add setting wrench.enable_debug (very experimental)
nixnoxus Dec 3, 2021
538488f
add `xdecor:hive` support
nixnoxus Dec 3, 2021
179ac80
add `bees:hive_wild` support
nixnoxus Dec 3, 2021
bfba1b8
add `vessels:shelf` support
nixnoxus Dec 3, 2021
aaf9777
add `mesecons` support (WIP)
nixnoxus Dec 3, 2021
3cc3faf
fix mesecons disconnection
nixnoxus Dec 3, 2021
15a4729
update luacheck
nixnoxus Dec 3, 2021
836ab3f
add `digilines` support
nixnoxus Dec 3, 2021
c4ba022
add `mobs:spawner` support
nixnoxus Dec 3, 2021
3878f16
also update connections on place
OgelGames Dec 4, 2021
fddfbe4
meta:get_string always returns a string
OgelGames Dec 4, 2021
9e2e68d
fix metas
OgelGames Dec 4, 2021
b53d9ce
use `drop_node` in get_description()
nixnoxus Dec 4, 2021
17644a7
fix luacontroller* and descriptions added
nixnoxus Dec 4, 2021
7e5cfae
add `realchess:chessboard` support
nixnoxus Dec 4, 2021
99851e3
fix typo
nixnoxus Dec 4, 2021
3c1d8ba
rename functions "wrench.*" to "wrench:*" (#3)
nixnoxus Dec 4, 2021
e43ff07
fix crash when `wrench.enable_debug = true`
nixnoxus Dec 4, 2021
b0947f8
fix typo in description for `realchess:chessboard`
nixnoxus Dec 4, 2021
de87e79
Revert "rename functions "wrench.*" to "wrench:*" (#3)"
OgelGames Dec 5, 2021
3021731
add compatibility for `:`
OgelGames Dec 5, 2021
820b8d5
Revert "add compatibility for `:`"
OgelGames Dec 5, 2021
3a267e6
add `wrench.plus = true`
OgelGames Dec 5, 2021
d253340
fixes for lua nodes
OgelGames Dec 5, 2021
4dd385c
Update README.md
nixnoxus Dec 5, 2021
d662feb
list supported modnames and nodes
nixnoxus Dec 5, 2021
b2b48cc
Update README.md
nixnoxus Dec 5, 2021
f9da60c
fix and update translations
nixnoxus Dec 6, 2021
f71f2a3
fix luacheck warning
nixnoxus Dec 6, 2021
c16ae41
modname is always "wrench"
OgelGames Dec 6, 2021
472d316
Basic Mineunit tests for wrench
S-S-X Dec 6, 2021
cfcf490
Luacheck: exclude regression tests
S-S-X Dec 6, 2021
b105f31
Tests with drawers mod
S-S-X Dec 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/mineunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: mineunit

on: [push, pull_request]

jobs:
mineunit:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
path: wrench

- uses: actions/checkout@v2
with:
path: drawers
repository: minetest-mods/drawers

- id: mineunit
uses: mt-mods/mineunit-actions@master
with:
working-directory: wrench
badge-label: Test coverage

- uses: KeisukeYamashita/create-comment@v1
if: failure() && github.event_name == 'pull_request'
with:
check-only-first-line: true
comment: |
### Mineunit regression tests failed, test log follows:

```
${{ steps.mineunit.outputs.mineunit-stdout }}
```
24 changes: 17 additions & 7 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
unused_args = false
allow_defined_top = true
max_line_length = 999

-- Exclude regression tests / unit tests
exclude_files = {
"**/spec/**",
}

globals = {
"technic", "minetest",
"minetest",
}

read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}},
string = {fields = {"split"}},
table = {fields = {"copy"}},

"intllib", "ItemStack", "drawers",
}
-- Minetest
"ItemStack",

files["init.lua"].ignore = { "name", "stack" }
-- Mods
"digilines",
"drawers",
"mesecon",
"pipeworks",
"xdecor",
}
120 changes: 120 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,122 @@
![](https://github.com/mt-mods/wrench/workflows/luacheck/badge.svg)
[![License](https://img.shields.io/badge/license-LGPLv2.0%2B-purple.svg)](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html)

<!--
[![ContentDB](https://content.minetest.net/packages/mt-mods/wrench/shields/downloads/)](https://content.minetest.net/packages/mt-mods/wrench/)
-->

# Wrench

<img src="textures/technic_wrench.png"/>

The wrench tool allows you to left-click on nodes with inventories to pick them up.

This mod is a fork from wrench/ in https://github.com/mt-mods/technic

# Supported Mods and Nodes

* https://github.com/minetest/minetest_game
- bones:bones
- default:chest
- default:chest_locked
- default:furnace
- default:sign_wall_wood
- default:sign_wall_steel
- vessels:shelf
* https://github.com/minetest-mods/3d_armor
- 3d_armor_stand:armor_stand
- 3d_armor_stand:locked_armor_stand
* https://notabug.org/TenPlus1/bees
- bees:hive_wild
* https://github.com/Lokrates/Biofuel
- biofuel:refinery
* https://github.com/HybridDog/connected_chests
* https://github.com/minetest-mods/digtron
- digtron:battery_holder
- digtron:inventory
- digtron:fuelstore
- digtron:combined_storage
* https://github.com/minetest-mods/drawers
- drawers:wood
- drawers:acacia_wood
- drawers:aspen_wood
- drawers:junglewood
- drawers:pine_wood
* https://github.com/minetest-mods/mesecons
- mesecons_commandblock:commandblock_\*
- mesecons_detector:node_detector_\*
- mesecons_detector:object_detector_\*
- mesecons_luacontroller:luacontroller\*
- mesecons_microcontroller:microcontroller\*
* https://notabug.org/tenplus1/mobs_redo
- mobs:spawner
* https://github.com/minetest-mods/more_chests
- more_chests:cobble
- more_chests:dropbox
- more_chests:fridge
- more_chests:big_fridge
- more_chests:shared
- more_chests:secret
- more_chests:toolbox_\*
* https://github.com/mt-mods/pipeworks
- pipeworks:autocrafter
- pipeworks:deployer_\*
- pipeworks:dispenser_\*
- pipeworks:nodebreaker_\*
- pipeworks:\*filter
- pipeworks:lua_tube*
- pipeworks:mese_sand_tube_\*
- pipeworks:mese_tube_\*
- pipeworks:teleport_tube_\*
* https://github.com/mt-mods/technic
- technic:cnc\*
- technic:coal_alloy_furnace\*
- technic:\*chest\*
- technic:injector
- technic:tool_workshop
- technic:\*_alloy_furnace\*
- technic:\*_battery_box\*
- technic:\*_centrifuge\*
- technic:\*_compressor\*
- technic:\*_electric_furnace\*
- technic:\*_extractor\*
- technic:\*_freezer\*
- technic:\*_grinder\*
* https://github.com/minetest-mods/xdecor
- realchess:chessboard
- xdecor:cabinet
- xdecor:cabinet_half
- xdecor:empty_shelf
- xdecor:multishelf
- xdecor:cauldron_\*
- xdecor:enchantment_table
- xdecor:itemframe
- xdecor:mailbox

# Settings in `minetest.conf`
```ini
# Allows the wrench to be crafted if either the 'technic' or 'default' mod is installed.
wrench.enable_crafting = true
```

# Contributors (originally technic modpack)

* kpoppel
* Nekogloop
* Nore/Ekdohibs
* ShadowNinja
* VanessaE
* BuckarooBanzay
* OgelGames
* int-ua
* S-S-X
* H-V-Smacker
* groxxda
* SwissalpS
* And many others...

# License (originally technic modpack)

Unless otherwise stated, all components of this modpack are licensed under the
LGPL, V2 or later. See also the individual mod folders for their
secondary/alternate licenses, if any.
42 changes: 42 additions & 0 deletions api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

function wrench.register_node(name, def)
assert(type(name) == "string", "wrench.register_node invalid type for name")
assert(type(def) == "table", "wrench.register_node invalid type for def")
local node_def = minetest.registered_nodes[name]
if node_def then
local old_after_place = node_def.after_place_node
minetest.override_item(name, {
after_place_node = function(...)
if not wrench.restore_node(...) and old_after_place then
return old_after_place(...)
end
end
})
def = table.copy(def)
if def.drop == true and type(node_def.drop) == "string" then
def.drop = node_def.drop
elseif def.drop and type(def.drop) ~= "string" then
minetest.log("warning", "Ignoring invalid type for drop in definition for "..name)
def.drop = nil
end
if def.drop and not wrench.registered_nodes[def.drop] then
if def.drop ~= name then
minetest.log("warning", "Ignoring unsupported node for drop in definition for "..name)
end
def.drop = nil
end
wrench.registered_nodes[name] = def
else
minetest.log("warning", "Attempt to register unknown node for wrench. "..name)
end
end

function wrench.blacklist_item(name)
assert(type(name) == "string", "wrench.blacklist_item invalid type for name")
local node_def = minetest.registered_items[name]
if node_def then
wrench.blacklisted_items[name] = true
else
minetest.log("warning", "Attempt to blacklist unknown item for wrench. "..name)
end
end
123 changes: 123 additions & 0 deletions debug.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

local get_keys = function(list)
local keys = {}
for k, _ in pairs(list) do
keys[#keys+1] = k
end
return keys
end

local spairs = function(tbl, order_func)
local ptrs = {}
for p in pairs(tbl) do ptrs[#ptrs +1] = p end
table.sort(ptrs, order_func and function(a, b) return order_func(a, b) end)
local i = 0
return function()
i = i +1
if ptrs[i] then return ptrs[i], tbl[ptrs[i]] end
end
end

local strip_esc = function(text)
text = minetest.strip_colors(text)
-- strip translation foo
text = string.gsub(text, "^.*T@.*%)", "")
return string.gsub(text, "%c.", "")
end

-- use wrench with sneak to show node propperies (useful to add new nodes)

local orig_wrench_pickup_node = wrench.pickup_node
wrench.pickup_node = function(pos, player)
if not player:get_player_control().sneak then
return orig_wrench_pickup_node(pos, player)
end
local node = minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
print("wrench.register_node(\"" .. node.name .. "\", {");
-- timer
local timer = minetest.get_node_timer(pos)
if timer:get_timeout() ~= 0 then
print("\ttimer = true,")
end
-- drop
if def.drop then
if type(def.drop) ~= "string" then
print("\t-- has drop " .. type(def.drop) .. "!")
elseif def.drop == node.name or def.drop == node.name .. " 1" then
print("\t-- drop = \"" .. def.drop .. "\",")
else
print("\tdrop = \"" .. def.drop .. "\",")
end
end
if def.after_place_node then
print("\t-- has after_place " .. type(def.after_place_node))
end
if def.after_dig_node then
print("\t-- has after_dig " .. type(def.after_dig_node))
end
if def.can_dig then
print("\t-- has can_dig " .. type(def.can_dig) .. " " ..
((type(def.can_dig) == "function") and
(def.can_dig(pos, player) and ', returns true' or ', returns false') or ""
)
)
end
local meta = minetest.get_meta(pos)
-- owner
local owner = meta:get_string("owner")
if owner and owner ~= "" then
print("\towner = true, -- '" .. owner .. "' FIXME:?")
end
-- lists
local inventory = meta:get_inventory()
-- print(dump(inventory))
local lists = get_keys(inventory:get_lists())
if #lists > 0 then
print("\tlists = {\"" .. table.concat(lists, "\", \"") .. "\"},")
end
-- metas
local metatable = meta:to_table()
local metas = get_keys(metatable.fields)
-- print(dump(metatable))
if #metas > 0 then
print("\tmetas = {")
for k, v in pairs(metatable.fields) do
local t = "--[[FIXME:!]]--"
if meta:get_int(k) .. "" == v .. "" then
t = "wrench.META_TYPE_INT"
elseif meta:get_float(k) .. "" == v .. "" then
t = "wrench.META_TYPE_FLOAT"
elseif meta:get_string(k) == v then
t = "wrench.META_TYPE_STRING"
end
local x = (k ~= "infotext" and k ~= "formspec") and
(" -- " .. v) or ""
print("\t\t" .. k .. " = " .. t .. "," .. x)
end
print("\t},")
end
print("})")
end

-- list supported modnames and nodes (useful to update README.md)

minetest.register_on_mods_loaded(function()
print("wrench registered_nodes:")
local last_mod = "?"
for name, def in spairs(wrench.registered_nodes, function(a,b)
-- return minetest.registered_nodes[a].mod_origin < minetest.registered_nodes[b].mod_origin or a < b
return a < b
end) do
if not def.drop then
local node = minetest.registered_nodes[name]
local mod = node.mod_origin
if last_mod ~= mod then
last_mod = mod
print("* "..mod)
end
local desc = strip_esc(node.description or "")
print(string.format(" - %-40s %q", name, desc))
end
end
end)
Loading