summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.luacheckrc6
-rw-r--r--LICENSE26
-rw-r--r--README23
-rw-r--r--init.lua179
-rw-r--r--locale/digitoilet.es.tr4
-rw-r--r--locale/template.txt4
-rw-r--r--mod.conf4
8 files changed, 248 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ffc8a2e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+i18n.py
+locale/*.old
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..6eeb30f
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,6 @@
+max_line_length = 160
+
+read_globals = {
+ "core",
+ "vector",
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..17be664
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,26 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+-----------------------------
+
+For information about the origins of specific files, see docs/file_sources
diff --git a/README b/README
new file mode 100644
index 0000000..cb4f646
--- /dev/null
+++ b/README
@@ -0,0 +1,23 @@
+Digilines-controlled toilet for Luanti
+======================================
+
+Why?
+----
+
+Why not?
+You can blame 2424barrier though.
+
+<2424barrier> they should really make a digiline toilet mod
+
+
+OK, so how do I use this?
+-------------------------
+
+Set a channel by right-clicking, like most other digilines devices.
+You can then send the following commands:
+
+"open": Opens the lid
+"close": Closes the lid
+"flush": Flushes the toilet
+"spray": Activates the built-in bidet. Not my problem if someone isn't sitting on it. Requires the lid to be open.
+"overflow": Flushes unsuccessfully and makes a mess of the floor. Requires the lid to be open.
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..4757087
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,179 @@
+local S = core.get_translator("digitoilet")
+
+--This part is technically copied from homedecor but probably not copyrightable,
+--with it just being the shape of the selection/collision boxes
+local toilet_sbox = {
+ type = "fixed",
+ fixed = { -6/16, -8/16, -8/16, 6/16, 9/16, 8/16 },
+}
+
+local toilet_cbox = {
+ type = "fixed",
+ fixed = {
+ {-6/16, -8/16, -8/16, 6/16, 0, 8/16 },
+ {-6/16, -8/16, 4/16, 6/16, 9/16, 8/16 }
+ }
+}
+--Copied part ends here
+
+local function handlefields(pos,_,fields,player)
+ if not (fields.channel and player:is_player()) then
+ return
+ end
+ local name = player:get_player_name()
+ if core.is_protected(pos,name) and not core.check_player_privs(name,{protection_bypass=true}) then
+ core.record_protection_violation(pos,name)
+ return
+ end
+ core.get_meta(pos):set_string("channel",fields.channel)
+end
+
+local function handledigilines(pos,node,channel,msg)
+ if channel ~= core.get_meta(pos):get_string("channel") then return end
+ if type(msg) ~= "string" then return end
+ msg = string.lower(msg)
+ if msg == "open" then
+ node.name = "digitoilet:toilet_open"
+ core.swap_node(pos,node)
+ elseif msg == "close" then
+ node.name = "digitoilet:toilet_closed"
+ core.swap_node(pos,node)
+ elseif msg == "flush" then
+ core.sound_play("homedecor_toilet_flush", {
+ pos = pos,
+ max_hear_distance = 10,
+ })
+ elseif msg == "spray" then
+ if node.name ~= "digitoilet:toilet_open" then return end
+ local dir = core.fourdir_to_dir(node.param2)
+ dir = vector.rotate_around_axis(dir,vector.new(0,1,0),math.pi)
+ core.add_particlespawner({
+ amount = 300,
+ time = 2.5,
+ size = 1,
+ glow = 10,
+ collisiondetection = true,
+ object_collision = true,
+ texture = "homedecor_water_particle.png",
+ pos = {
+ min = pos,
+ max = pos,
+ },
+ vel = {
+ min = vector.add(vector.multiply(dir,4),vector.new(0,4,0)),
+ max = vector.add(vector.multiply(dir,5),vector.new(0,5,0)),
+ },
+ acc = {
+ min = vector.new(0,-1.5,0),
+ max = vector.new(0,-1,0),
+ },
+ exptime = {
+ min = 8,
+ max = 10,
+ },
+ drag = {
+ min = vector.new(0.7,0,0.7),
+ max = vector.new(0.9,0,0.9),
+ },
+ })
+ core.sound_play("homedecor_faucet", {
+ pos = pos,
+ max_hear_distance = 10,
+ })
+ elseif msg == "overflow" then
+ if node.name ~= "digitoilet:toilet_open" then return end
+ core.add_particlespawner({
+ amount = 150,
+ time = 2.5,
+ size = 1,
+ glow = 10,
+ collisiondetection = true,
+ object_collision = true,
+ texture = "homedecor_water_particle.png",
+ pos = {
+ min = pos,
+ max = pos,
+ },
+ vel = {
+ min = vector.new(-0.5,0,-0.5),
+ max = vector.new(0.5,0,0.5),
+ },
+ acc = {
+ min = vector.new(0,-1.5,0),
+ max = vector.new(0,-1,0),
+ },
+ exptime = {
+ min = 8,
+ max = 10,
+ },
+ })
+ core.sound_play("homedecor_toilet_flush", {
+ pos = pos,
+ max_hear_distance = 10,
+ })
+ end
+end
+
+core.register_node("digitoilet:toilet_closed", {
+ description = S("Digilines-Controlled Toilet"),
+ drawtype = "mesh",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ mesh = "homedecor_toilet_closed.obj",
+ tiles = {
+ "building_blocks_marble.png",
+ "building_blocks_marble.png",
+ "building_blocks_marble.png",
+ "homedecor_generic_metal.png^[colorize:#495dc244",
+ },
+ selection_box = toilet_sbox,
+ node_box = toilet_cbox,
+ groups = {cracky=3,},
+ on_construct = function(pos)
+ local meta = core.get_meta(pos)
+ meta:set_string("formspec","field[channel;"..S("Channel")..";${channel}]")
+ end,
+ on_receive_fields = handlefields,
+ digilines = {
+ receptor = {},
+ effector = {
+ action = handledigilines,
+ },
+ },
+})
+
+core.register_node("digitoilet:toilet_open", {
+ description = S("Digilines-Controlled Toilet (open)"),
+ drawtype = "mesh",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ drop = "digitoilet:toilet_closed",
+ mesh = "homedecor_toilet_open.obj",
+ tiles = {
+ "building_blocks_marble.png",
+ "building_blocks_marble.png",
+ "building_blocks_marble.png",
+ "default_water.png",
+ "homedecor_generic_metal.png^[colorize:#495dc244",
+ },
+ selection_box = toilet_sbox,
+ node_box = toilet_cbox,
+ groups = {cracky=3,not_in_creative_inventory=1},
+ on_construct = function(pos)
+ local meta = core.get_meta(pos)
+ meta:set_string("formspec","field[channel;"..S("Channel")..";${channel}]")
+ end,
+ on_receive_fields = handlefields,
+ digilines = {
+ receptor = {},
+ effector = {
+ action = handledigilines,
+ },
+ },
+})
+
+core.register_craft({
+ type = "shapeless",
+ output = "digitoilet:toilet_closed",
+ recipe = {"homedecor:toilet","digilines:wire_std_00000000"},
+})
diff --git a/locale/digitoilet.es.tr b/locale/digitoilet.es.tr
new file mode 100644
index 0000000..a91fe8b
--- /dev/null
+++ b/locale/digitoilet.es.tr
@@ -0,0 +1,4 @@
+# textdomain: digitoilet
+Digilines-Controlled Toilet=Inodoro controlado por digilines
+Channel=Canal
+Digilines-Controlled Toilet (open)=Inodoro controlado por digilines (abierto)
diff --git a/locale/template.txt b/locale/template.txt
new file mode 100644
index 0000000..7caba05
--- /dev/null
+++ b/locale/template.txt
@@ -0,0 +1,4 @@
+# textdomain: digitoilet
+Digilines-Controlled Toilet=
+Channel=
+Digilines-Controlled Toilet (open)=
diff --git a/mod.conf b/mod.conf
new file mode 100644
index 0000000..69610cf
--- /dev/null
+++ b/mod.conf
@@ -0,0 +1,4 @@
+name = digitoilet
+description = Digilines-controlled toilet. Blame obstacle.
+depends = homedecor_bathroom,default,digilines
+min_minetest_version = 5.7