Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: buckaroobanzay/mtt@main
with:
modname: pipeworks
git_dependencies: |
https://github.com/BuckarooBanzay/mtt
https://github.com/OgelGames/fakelib
https://github.com/mt-mods/xcompat
https://github.com/mt-mods/basic_materials
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ read_globals = {
"screwdriver", "unified_inventory",
"i3", "mcl_experience", "awards",
"xcompat", "fakelib", "vizlib",
"mcl_redstone",
"mcl_redstone","mtt"
}
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
mtt:
image: ghcr.io/buckaroobanzay/mtt:latest
volumes:
- "./:/github/workspace"
environment:
INPUT_MODNAME: "pipeworks"
INPUT_TEST_MODE: "mod"
INPUT_MAPGEN: "singlenode"
INPUT_GIT_GAME_REPO: "https://github.com/minetest/minetest_game"
INPUT_GIT_DEPENDENCIES: |
https://github.com/BuckarooBanzay/mtt
https://github.com/OgelGames/fakelib
https://github.com/mt-mods/xcompat
https://github.com/mt-mods/basic_materials
5 changes: 5 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,9 @@ if core.get_modpath("unified_inventory") and unified_inventory.registered_catego
unified_inventory.add_category_items("automation", pipeworks.ui_cat_tube_list)
end

if core.get_modpath("mtt") and mtt.enabled then
dofile(pipeworks.modpath.."/mtt/smoketests.spec.lua")
dofile(pipeworks.modpath.."/mtt/network.spec.lua")
end

core.log("info", "Pipeworks loaded!")
2 changes: 1 addition & 1 deletion mod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name = pipeworks
title = Pipeworks
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
depends = basic_materials, xcompat, fakelib
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_blast_furnace, mcl_smoker, mcl_experience, vizlib, mapgen
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_blast_furnace, mcl_smoker, mcl_experience, vizlib, mapgen, mtt
min_minetest_version = 5.10.0
39 changes: 39 additions & 0 deletions mtt/network.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- chest -> filter-injector -> tube -> chest, running along the x-axis
mtt.register_with_area("chest -> injector -> tube -> chest", {
size = { x = 5, y = 3, z = 3 },
emerged = true
}, function(pos1, _, callback)
local chest = "default:chest"

local y, z = pos1.y + 1, pos1.z + 1
local chest_in = { x = pos1.x, y = y, z = z }
local injector = { x = pos1.x + 1, y = y, z = z }
local tube = { x = pos1.x + 2, y = y, z = z }
local chest_out = { x = pos1.x + 3, y = y, z = z }

core.set_node(chest_in, { name = chest, param2 = 0 })
core.set_node(injector, { name = "pipeworks:filter", param2 = 0 })
core.set_node(tube, { name = "pipeworks:tube_1" })
core.set_node(chest_out, { name = chest, param2 = 0 })
pipeworks.scan_for_tube_objects(tube)

core.get_meta(injector):set_string("owner", "singleplayer")
core.get_meta(chest_in):get_inventory():add_item("main", "default:dirt 3")

local node = core.get_node(injector)
core.registered_nodes["pipeworks:filter"].on_punch(injector, node, nil)

-- itemwise injector, the item travels through the tube asynchronously
local inv_out = core.get_meta(chest_out):get_inventory()
local function check()
if inv_out:contains_item("main", "default:dirt") then
-- exactly one item moved per punch
assert(core.get_meta(chest_in):get_inventory():contains_item("main", "default:dirt 2"))
assert(not inv_out:contains_item("main", "default:dirt 2"))
callback()
else
core.after(0.2, check)
end
end
check()
end)
23 changes: 23 additions & 0 deletions mtt/smoketests.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- mtt tests, only loaded if the "mtt" mod is present and enabled

mtt.register("registered nodes", function(callback)
assert(core.registered_nodes["pipeworks:pipe_110000_empty"])
assert(core.registered_nodes["pipeworks:pipe_110000_loaded"])
assert(core.registered_nodes["pipeworks:tube_1"])
assert(core.registered_nodes["pipeworks:trashcan"])
if pipeworks.enable_autocrafter then
assert(core.registered_nodes["pipeworks:autocrafter"])
end
callback()
end)

mtt.register("pipe alias", function(callback)
assert(core.registered_aliases["pipeworks:pipe"] == "pipeworks:pipe_110000_empty")
callback()
end)

mtt.register("tube api", function(callback)
assert(type(pipeworks.register_tube) == "function")
assert(type(pipeworks.scan_for_tube_objects) == "function")
callback()
end)
Loading