Skip to content

Commit

Permalink
Merge branch 'master' into upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay authored Nov 24, 2023
2 parents 3264189 + 80bbcc6 commit 980fd63
Show file tree
Hide file tree
Showing 38 changed files with 1,845 additions and 668 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: luacheck
on: [push, pull_request]
jobs:
luacheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Luacheck
uses: lunarmodules/luacheck@master
22 changes: 22 additions & 0 deletions .github/workflows/mineunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

name: mineunit

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: mineunit
uses: mt-mods/mineunit-actions@master
with:
badge-label: Test coverage
# Uncomment to add coverage badge for regression tests
# - uses: RubbaBoy/[email protected]
# with:
# NAME: "${{ steps.mineunit.outputs.badge-name }}"
# LABEL: "${{ steps.mineunit.outputs.badge-label }}"
# STATUS: "${{ steps.mineunit.outputs.badge-status }}"
# COLOR: "${{ steps.mineunit.outputs.badge-color }}"
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Merge Upstream"

on:
schedule:
- cron: "30 20 * * *"
workflow_dispatch:

jobs:
pull:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: |
git config --global user.name 'Upstream Merge Action'
git config --global user.email '[email protected]'
git remote add -f upstream "https://cheapiesystems.com/git/digistuff"
git fetch upstream
git checkout -B upstream
git reset --hard upstream/master
git push origin upstream --force
(printf "GITLOG<<EOF\n";git log origin/master..upstream/master;printf "\nEOF")|sed 's/"/\&#34;/g'>>$GITHUB_ENV
shell: bash
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
source_branch: upstream
destination_branch: master
pr_title: "Pulling upstream into master"
pr_body: "${{ env.GITLOG }}"
pr_label: "upstream"
github_token: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
unused_args = false
max_line_length = 300 -- TODO: fix line lengths

globals = {
"minetest",
"digistuff",
"digilines",
}

read_globals = {
-- Builtin
table = {fields = {"copy"}},

"vector",
"ItemStack",
"DIR_DELIM",

-- Mod Deps
"default",
"mesecon",
"screwdriver",
"QoS"
}

exclude_files = {
"**/spec/**",
}
10 changes: 6 additions & 4 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
Digilines Stuff
===============
# Digilines Stuff [digistuff]

[![luacheck](https://github.com/mt-mods/digistuff/workflows/luacheck/badge.svg)](https://github.com/mt-mods/digistuff/actions)
[![mineunit](https://github.com/mt-mods/digistuff/actions/workflows/mineunit.yml/badge.svg)](https://github.com/mt-mods/digistuff/actions/workflows/mineunit.yml)

## License:

License:
Code - LGPL v3 or later (contains some code from mesecons and digilines)
Textures WITHOUT "adwaita" in the file name - CC BY-SA 3.0 Generic (contains modified versions of textures from mesecons and digilines)
Textures WITH "adwaita" in the file name - These are icons by the GNOME Project, licensed under GNU LGPL v3 or CC BY-SA 3.0.

### Depends:

Depends:
Required: digilines (base only) and mesecons (base only)
Optional: mesecons_noteblock (for digilines noteblock), mesecons_mvps (for digilines piston and movestone), mesecons_luacontroller (for I/O expander)
Only needed for craft recipes: default, basic_materials
Expand Down
173 changes: 115 additions & 58 deletions camera.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,47 @@

local formspec = "size[8,4]"..
"field[1.3,1;6,1;channel;Channel;${channel}]"..
"field[1.3,2;3,1.3;radius;Radius;${radius}]"..
"field[4.3,2;3,1.3;distance;Distance;${distance}]"..
"button_exit[4,3;3,1;submit;Save]"

local function get_formspec(enabled)
if enabled then
return formspec.."button[1,3;3,1;disable;Disable]"
else
return formspec.."button[1,3;3,1;enable;Enable]"
end
end

local function search_for_players(pos, send_empty)
local meta = minetest.get_meta(pos)
local distance = meta:get_int("distance")
local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
local spot = vector.add(pos, vector.multiply(dir, -distance))
local node = minetest.get_node(spot)
while node.name == "air" and pos.y - spot.y < 10 do
spot.y = spot.y - 1
node = minetest.get_node(spot)
end
if node.name == "air" or node.name == "ignore" then
return true
end
local radius = meta:get_int("radius")
local found = {}
for _,player in pairs(minetest.get_connected_players()) do
if vector.distance(spot, player:get_pos()) <= radius then
table.insert(found, player:get_player_name())
end
end
if #found > 0 or send_empty == true then
local channel = meta:get_string("channel")
digilines.receptor_send(pos, digilines.rules.default, channel, found)
end
return true
end

minetest.register_node("digistuff:camera", {
description = "Digilines Camera",
tiles = {
"digistuff_camera_top.png",
"digistuff_camera_bottom.png",
Expand All @@ -7,86 +50,100 @@ minetest.register_node("digistuff:camera", {
"digistuff_camera_back.png",
"digistuff_camera_front.png",
},
digiline =
{
receptor = {}
},
_digistuff_channelcopier_fieldname = "channel",
groups = {cracky=2},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.1,-0.5,-0.28,0.1,-0.3,0.3}, --Camera Body
{-0.045,-0.42,-0.34,0.045,-0.36,-0.28}, -- Lens
{-0.05,-0.9,-0.05,0.05,-0.5,0.05}, --Pole
}
{-0.1,-0.5,-0.28,0.1,-0.3,0.3}, -- Camera Body
{-0.045,-0.42,-0.34,0.045,-0.36,-0.28}, -- Lens
{-0.05,-0.9,-0.05,0.05,-0.5,0.05}, -- Pole
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.1,-0.5,-0.34,0.1,-0.3,0.3}, --Camera Body
}
{-0.1,-0.5,-0.34,0.1,-0.3,0.3},
}
},
description = "Digilines Camera",
sounds = default and default.node_sound_stone_defaults(),
groups = {cracky = 2},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec","size[8,6;]field[1,1;6,2;channel;Channel;${channel}]field[1,2;6,2;radius;Radius (max 10);${radius}]field[1,3;6,2;distance;Distance (max 20);${distance}]button_exit[2.25,4;3,1;submit;Save]")
meta:set_string("formspec", get_formspec(true))
meta:set_int("radius", 1)
meta:set_int("distance", 0)
minetest.get_node_timer(pos):start(1)
end,
on_receive_fields = function(pos, formname, fields, sender)
local name = sender:get_player_name()
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
minetest.record_protection_violation(pos,name)
on_receive_fields = function(pos, _, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local meta = minetest.get_meta(pos)
if fields.channel then meta:set_string("channel",fields.channel) end
if fields.distance and tonumber(fields.distance) then meta:set_int("distance",math.max(math.min(20,fields.distance),0)) end
if fields.radius and tonumber(fields.radius) then meta:set_int("radius",math.max(math.min(10,fields.radius),1)) end
if fields.channel then
meta:set_string("channel", fields.channel)
end
if fields.radius then
local value = math.max(1, math.min(10, tonumber(fields.radius) or 1))
meta:set_int("radius", value)
end
if fields.distance then
local value = math.max(0, math.min(20, tonumber(fields.distance) or 0))
meta:set_int("distance", value)
end
if fields.enable then
meta:set_string("formspec", get_formspec(true))
minetest.get_node_timer(pos):start(1)
elseif fields.disable then
meta:set_string("formspec", get_formspec(false))
minetest.get_node_timer(pos):stop()
end
end,
sounds = default and default.node_sound_stone_defaults()
on_timer = search_for_players,
digiline = {
receptor = {},
effector = {
action = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
if channel ~= meta:get_string("channel") then return end
if type(msg) == "table" then
if msg.radius then
local value = math.max(1, math.min(10, tonumber(msg.radius) or 1))
meta:set_int("radius", value)
end
if msg.distance then
local value = math.max(0, math.min(20, tonumber(msg.distance) or 0))
meta:set_int("distance", value)
end
if msg.command == "get" then
search_for_players(pos, true)
end
elseif msg == "GET" or msg == "get" then
search_for_players(pos, true)
end
end,
},
},
_digistuff_channelcopier_fieldname = "channel",
})

minetest.register_abm({
minetest.register_lbm({
label = "Digistuff camera update",
name = "digistuff:camera_update",
nodenames = {"digistuff:camera"},
interval = 1.0,
chance = 1,
action = function(pos,node)
local meta = minetest.get_meta(pos)
local channel = meta:get_string("channel")
local radius = meta:get_int("radius")
local distance = meta:get_int("distance")
local dir = vector.multiply(minetest.facedir_to_dir(node.param2),-1)
local spot = vector.add(pos,vector.multiply(dir,distance))
local i = 0
while i <= 10 and minetest.get_node(spot).name == "air" do
--Downward search for ground level
spot = vector.add(spot,vector.new(0,-1,0))
i = i + 1
end
if minetest.get_node(spot).name == "air" or minetest.get_node(spot).name == "ignore" then
--Ground not in range
return
end

local found_any = false
local players_found = {}
local objs = minetest.get_objects_inside_radius(spot,radius)
if objs then
local _,obj
for _,obj in ipairs(objs) do
if obj:is_player() then
table.insert(players_found,obj:get_player_name())
found_any = true
end
end
if found_any then
digiline:receptor_send({x=pos.x,y=pos.y-1,z=pos.z}, digiline.rules.default, channel, players_found)
end
end
run_at_every_load = false,
action = function(pos)
local meta = minetest.get_meta(pos)
if not meta:get("radius") then
meta:set_int("radius", 1)
end
if not meta:get("distance") then
meta:set_int("distance", 0)
end
meta:set_string("formspec", get_formspec(true))
minetest.get_node_timer(pos):start(1)
end,
})

minetest.register_craft({
Expand Down
5 changes: 2 additions & 3 deletions cardreader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ minetest.register_craftitem("digistuff:card",{
local data = meta:get_string("writedata")
meta:set_int("writepending",0)
meta:set_string("infotext","Ready to Read")
digiline:receptor_send(pos,cardreader_rules,channel,{event = "write",})
digilines.receptor_send(pos,cardreader_rules,channel,{event = "write",})
stackmeta:set_string("data",data)
stackmeta:set_string("description",string.format("Magnetic Card (%s)",meta:get_string("writedescription")))
return stack
else
local channel = meta:get_string("channel")
local data = stackmeta:get_string("data")
digiline:receptor_send(pos,cardreader_rules,channel,{event = "read",data = data,})
digilines.receptor_send(pos,cardreader_rules,channel,{event = "read",data = data,})
end
end,
})
Expand Down
4 changes: 2 additions & 2 deletions channelcopier.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
minetest.register_tool("digistuff:channelcopier",{
description = "Digilines Channel Copier (shift-click to copy, click to paste)",
description = "Digilines Channel Copier (sneak-click to copy, click to paste)",
inventory_image = "digistuff_channelcopier.png",
on_use = function(itemstack,player,pointed)
if not (pointed and pointed.under) then return itemstack end
Expand All @@ -25,7 +25,7 @@ minetest.register_tool("digistuff:channelcopier",{
if minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname then
local channel = itemstack:get_meta():get_string("channel")
if type(channel) ~= "string" or channel == "" then
minetest.chat_send_player(name,minetest.colorize("#FF5555","Error:").." No channel has been set yet. Shift-click to copy one.")
minetest.chat_send_player(name,minetest.colorize("#FF5555","Error:").." No channel has been set yet. Sneak-click to copy one.")
return itemstack
end
local oldchannel = minetest.get_meta(pos):get_string(minetest.registered_nodes[node.name]._digistuff_channelcopier_fieldname)
Expand Down
Loading

0 comments on commit 980fd63

Please sign in to comment.