From 05c8fa6bbe1b30589757fa70c3c28f96090515d1 Mon Sep 17 00:00:00 2001
From: Emojigit <55009343+Emojigit@users.noreply.github.com>
Date: Fri, 13 Aug 2021 07:38:48 +0800
Subject: [PATCH] init
---
README.md | 19 ++++++++++++++
init.lua | 64 +++++++++++++++++++++++++++++++++++++++++++++++
mod.conf | 4 +++
mods/default.lua | 30 ++++++++++++++++++++++
mods/ethereal.lua | 23 +++++++++++++++++
test.lua | 18 +++++++++++++
6 files changed, 158 insertions(+)
create mode 100644 init.lua
create mode 100644 mod.conf
create mode 100644 mods/default.lua
create mode 100644 mods/ethereal.lua
create mode 100644 test.lua
diff --git a/README.md b/README.md
index 57babd8..25204a8 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,21 @@
# digiline_nodes
API to add digiline nodes
+## Code License
+ Copyright (C) 2021 Cato Yiu and other contributers
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see .
+
+P.S: for a full list of contributer list, see:
+* https://gitlab.com/yw05/digistuff/-/commits/master/
+* https://github.com/C-C-Minetest-Server/digiline_nodes/commits/main
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..17e06a7
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,64 @@
+--[[
+This file is a part of digiline_nodes.
+
+Copyright (C) 2021 Cato Yiu and other contributers
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+]]
+local MN = minetest.get_current_modname()
+local MP = minetest.get_modpath(MN)
+local S = minetest.get_translator(MN)
+digiline_nodes = {}
+local _dn = digiline_nodes
+function _dn.register_digiline_node(mod,node)
+ local nodename = mod .. ":" .. node
+ local digi_nodename = MN .. ":" .. mod .. "__" .. node
+ local ndef = minetest.registered_nodes[nodename]
+ if not(ndef) then
+ minetest.log("warning","Not registering `" .. nodename ..
+ "`'s digiline node since it does not exist")
+ return
+ end
+ local digi_ndef = table.copy(ndef)
+ digi_ndef.description = S("Digiline Condused @1",ndef.description or nodename)
+ if ndef.long_description then
+ digi_ndef.long_description = S("Digiline condused version of @1",ndef.long_description)
+ end
+ digi_ndef.digiline = {
+ wire = {
+ rules = {
+ {x = 1, y = 0, z = 0},
+ {x =-1, y = 0, z = 0},
+ {x = 0, y = 1, z = 0},
+ {x = 0, y =-1, z = 0},
+ {x = 0, y = 0, z = 1},
+ {x = 0, y = 0, z =-1}
+ }
+ }
+ }
+ digi_ndef.is_ground_content = false
+ if not digi_ndef.group then digi_ndef.group = {} end
+ digi_ndef.group.digiline_node = 1
+ minetest.register_node(digi_nodename,digi_ndef)
+end
+
+local domod = function(mn)
+ dofile(MP .. "/mods/" .. mn .. ".lua")
+end
+if minetest.get_modpath("default") then
+ domod("default")
+end
+if minetest.get_modpath("ethereal") then
+ domod("ethereal")
+end
diff --git a/mod.conf b/mod.conf
new file mode 100644
index 0000000..f600378
--- /dev/null
+++ b/mod.conf
@@ -0,0 +1,4 @@
+name = digiline_nodes
+destription = API to add digiline nodes
+depends = digilines
+optional_depends = default, ethereal
diff --git a/mods/default.lua b/mods/default.lua
new file mode 100644
index 0000000..4e8c558
--- /dev/null
+++ b/mods/default.lua
@@ -0,0 +1,30 @@
+--[[
+This file is a part of digiline_nodes.
+
+Copyright (C) 2021 Cato Yiu and other contributers
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+]]
+local function reg(node)
+ digiline_nodes.register_digiline_node("default",node)
+end
+
+reg("stone")
+reg("cobbe")
+reg("stonebrick")
+reg("stone_block")
+reg("sandstone")
+reg("desert_sandstone")
+reg("silver_sandstone")
+reg("meselamp")
diff --git a/mods/ethereal.lua b/mods/ethereal.lua
new file mode 100644
index 0000000..1eb4532
--- /dev/null
+++ b/mods/ethereal.lua
@@ -0,0 +1,23 @@
+--[[
+This file is a part of digiline_nodes.
+
+Copyright (C) 2021 Cato Yiu and other contributers
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+]]
+local function reg(node)
+ digiline_nodes.register_digiline_node("ethereal",node)
+end
+
+reg("crystal_block")
diff --git a/test.lua b/test.lua
new file mode 100644
index 0000000..27fc2d2
--- /dev/null
+++ b/test.lua
@@ -0,0 +1,18 @@
+--[[
+This file is a part of digiline_nodes.
+
+Copyright (C) 2021 Cato Yiu and other contributers
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+]]