mirror of
https://github.com/D00Med/scifi_nodes.git
synced 2025-06-29 22:50:48 +02:00
Compare commits
2 Commits
protected-
...
integratio
Author | SHA1 | Date | |
---|---|---|---|
286e80edfd | |||
fcce42837f |
15
.github/workflows/integration-test.yml
vendored
Normal file
15
.github/workflows/integration-test.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: integration-test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: integration-test
|
||||
run: ./test/integration-test.sh
|
@ -3,6 +3,7 @@
|
||||
# scifi_nodes
|
||||
|
||||

|
||||

|
||||
|
||||
Minetest mod that adds scifi themed blocks, doors, materials, plants and other assets.
|
||||
|
||||
|
3
init.lua
3
init.lua
@ -14,8 +14,7 @@ dofile(MP.."/chest.lua")
|
||||
dofile(MP.."/plants.lua")
|
||||
dofile(MP.."/nodes.lua")
|
||||
dofile(MP.."/doors.lua")
|
||||
dofile(MP.."/switch.lua")
|
||||
dofile(MP.."/protected_switch.lua")
|
||||
dofile(MP.."/switches.lua")
|
||||
dofile(MP.."/nodeboxes.lua")
|
||||
dofile(MP.."/palm_scanner.lua")
|
||||
dofile(MP.."/digicode.lua")
|
||||
|
@ -1,89 +0,0 @@
|
||||
|
||||
--------------
|
||||
-- Switches --
|
||||
--------------
|
||||
|
||||
local has_mesecons = minetest.get_modpath("mesecons")
|
||||
|
||||
local function toggle_switch(pos, _, player)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
if name == "scifi_nodes:protected_switch_on" then
|
||||
-- toggle off
|
||||
minetest.sound_play("scifi_nodes_switch", {max_hear_distance = 8, pos = pos})
|
||||
minetest.set_node(pos, {name = "scifi_nodes:protected_switch_off", param2 = node.param2})
|
||||
mesecon.receptor_off(pos, scifi_nodes.get_switch_rules(node.param2))
|
||||
elseif name == "scifi_nodes:protected_switch_off" then
|
||||
-- toggle on, check protection first
|
||||
if player and minetest.is_protected(pos, player:get_player_name()) then
|
||||
-- position is protected, abort
|
||||
minetest.sound_play("scifi_nodes_scanner_refused", {max_hear_distance = 8, pos = pos})
|
||||
return
|
||||
end
|
||||
minetest.sound_play("scifi_nodes_switch", {max_hear_distance = 8, pos = pos})
|
||||
minetest.set_node(pos, {name = "scifi_nodes:protected_switch_on", param2 = node.param2})
|
||||
mesecon.receptor_on(pos, scifi_nodes.get_switch_rules(node.param2))
|
||||
minetest.get_node_timer(pos):start(2)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("scifi_nodes:protected_switch_on", {
|
||||
description = "Protected wall switch",
|
||||
sunlight_propagates = true,
|
||||
buildable_to = false,
|
||||
tiles = {"scifi_nodes_switch_on.png",},
|
||||
inventory_image = "scifi_nodes_switch_on.png",
|
||||
wield_image = "scifi_nodes_switch_on.png",
|
||||
drawtype = "signlike",
|
||||
node_box = {type = "wallmounted",},
|
||||
selection_box = {type = "wallmounted",},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
light_source = 5,
|
||||
groups = {
|
||||
cracky=1,
|
||||
oddly_breakable_by_hand = 1,
|
||||
not_in_creative_inventory = 1,
|
||||
mesecon_needs_receiver = 1
|
||||
},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = (has_mesecons and mesecon.state.on)
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
on_rightclick = (has_mesecons and toggle_switch),
|
||||
on_timer = (has_mesecons and toggle_switch)
|
||||
})
|
||||
|
||||
minetest.register_node("scifi_nodes:protected_switch_off", {
|
||||
description = "Protected wall switch",
|
||||
tiles = {"scifi_nodes_switch_off.png",},
|
||||
inventory_image = "scifi_nodes_switch_on.png",
|
||||
wield_image = "scifi_nodes_switch_on.png",
|
||||
drawtype = "signlike",
|
||||
sunlight_propagates = true,
|
||||
buildable_to = false,
|
||||
node_box = {type = "wallmounted",},
|
||||
selection_box = {type = "wallmounted",},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {
|
||||
cracky = 1,
|
||||
oddly_breakable_by_hand = 1,
|
||||
mesecon_needs_receiver = 1
|
||||
},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = (has_mesecons and mesecon.state.off)
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
on_rightclick = (has_mesecons and toggle_switch)
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "scifi_nodes:protected_switch_off 2",
|
||||
type = "shapeless",
|
||||
recipe = {"scifi_nodes:switch_off", "default:steel_ingot"}
|
||||
})
|
@ -33,12 +33,7 @@ minetest.register_node("scifi_nodes:switch_on", {
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
light_source = 5,
|
||||
groups = {
|
||||
cracky=1,
|
||||
oddly_breakable_by_hand = 1,
|
||||
not_in_creative_inventory = 1,
|
||||
mesecon_needs_receiver = 1
|
||||
},
|
||||
groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = (has_mesecons and mesecon.state.on)
|
||||
@ -61,11 +56,7 @@ minetest.register_node("scifi_nodes:switch_off", {
|
||||
selection_box = {type = "wallmounted",},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {
|
||||
cracky = 1,
|
||||
oddly_breakable_by_hand = 1,
|
||||
mesecon_needs_receiver = 1
|
||||
},
|
||||
groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = (has_mesecons and mesecon.state.off)
|
25
test/integration-test.sh
Executable file
25
test/integration-test.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# Spins up a test world to ensure proper working recipes and registrations
|
||||
|
||||
CWD=$(dirname $0)
|
||||
cd ${CWD}/../
|
||||
|
||||
CFG=/tmp/minetest.conf
|
||||
MTDIR=/tmp/mt
|
||||
WORLDDIR=${MTDIR}/worlds/world
|
||||
|
||||
cat <<EOF > ${CFG}
|
||||
# empty
|
||||
EOF
|
||||
|
||||
mkdir -p ${WORLDDIR}
|
||||
chmod 777 ${MTDIR} -R
|
||||
docker run --rm -i \
|
||||
-v ${CFG}:/etc/minetest/minetest.conf:ro \
|
||||
-v ${MTDIR}:/var/lib/minetest/.minetest \
|
||||
-v $(pwd)/:/var/lib/minetest/.minetest/worlds/world/worldmods/scifi_nodes \
|
||||
-v $(pwd)/test/test_mod/:/var/lib/minetest/.minetest/worlds/world/worldmods/scifi_nodes_test \
|
||||
--network host \
|
||||
registry.gitlab.com/minetest/minetest/server:5.2.0
|
||||
|
||||
test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1
|
40
test/test_mod/init.lua
Normal file
40
test/test_mod/init.lua
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
minetest.log("warning", "[TEST] integration-test enabled!")
|
||||
|
||||
-- those mods have to be present
|
||||
local assert_mods = {
|
||||
"scifi_nodes"
|
||||
}
|
||||
|
||||
-- those nodes have to be present
|
||||
local assert_nodes = {
|
||||
"scifi_nodes:crate",
|
||||
"scifi_nodes:door1a"
|
||||
}
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
minetest.after(0, function()
|
||||
-- check mods
|
||||
for _, modname in ipairs(assert_mods) do
|
||||
if not minetest.get_modpath(modname) then
|
||||
error("Mod not present: " .. modname)
|
||||
end
|
||||
end
|
||||
|
||||
-- check nodes
|
||||
for _, nodename in ipairs(assert_nodes) do
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
error("Node not present: " .. nodename)
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
minetest.request_shutdown("success")
|
||||
|
||||
end)
|
||||
end)
|
2
test/test_mod/mod.conf
Normal file
2
test/test_mod/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = scifi_nodes_test
|
||||
depends = scifi_nodes
|
Reference in New Issue
Block a user