summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-09-14 18:24:37 -0500
committercheapie <no-email-for-you@example.com>2024-09-14 18:24:37 -0500
commitc05caf502e954b0618ce717305d5112ab9d8cc9d (patch)
tree4e24a692dd28d01a75d67ad858c7a9260bb294cc
parent889b83ac24dac0b4b608cd03e09334b79053712c (diff)
downloadprinter-c05caf502e954b0618ce717305d5112ab9d8cc9d.tar
printer-c05caf502e954b0618ce717305d5112ab9d8cc9d.tar.gz
printer-c05caf502e954b0618ce717305d5112ab9d8cc9d.tar.bz2
printer-c05caf502e954b0618ce717305d5112ab9d8cc9d.tar.xz
printer-c05caf502e954b0618ce717305d5112ab9d8cc9d.zip
Add luacheck configuration and some minor cleanupsHEADmaster
-rw-r--r--.luacheckrc8
-rw-r--r--depends.txt2
-rw-r--r--init.lua42
-rw-r--r--mod.conf3
4 files changed, 39 insertions, 16 deletions
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..e66ba22
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,8 @@
+max_line_length = 160
+
+read_globals = {
+ "minetest",
+ "vector",
+ "ItemStack",
+ "digilines",
+}
diff --git a/depends.txt b/depends.txt
deleted file mode 100644
index 6346be3..0000000
--- a/depends.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-digilines
-default
diff --git a/init.lua b/init.lua
index 5cd17e6..b9bff75 100644
--- a/init.lua
+++ b/init.lua
@@ -2,8 +2,8 @@ local function eject_item(pos,dir,item,speed)
if not speed then speed = 3 end
local spawnpos = vector.add(pos,vector.multiply(dir,-0.6))
local velocity = vector.multiply(dir,speed*-1)
- local item = minetest.add_item(spawnpos,item)
- item:set_velocity(velocity)
+ local eref = minetest.add_item(spawnpos,item)
+ eref:set_velocity(velocity)
end
minetest.register_craftitem("printer:document",{
@@ -50,7 +50,14 @@ minetest.register_node("printer:printer",{
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:get_inventory():set_size("paper",1)
- meta:set_string("formspec","size[8,6]label[1,0;Paper Tray]list[context;paper;1,0.5;1,1]list[current_player;main;0,2;8,4]listring[]field[3,0.75;2,1;channel;Channel;${channel}]button_exit[5,0.5;2,1;set;Set]")
+ meta:set_string("formspec","size[8,6]"..
+ "label[1,0;Paper Tray]"..
+ "list[context;paper;1,0.5;1,1]"..
+ "list[current_player;main;0,2;8,4]"..
+ "listring[]"..
+ "field[3,0.75;2,1;channel;Channel;${channel}]"..
+ "button_exit[5,0.5;2,1;set;Set]"
+ )
end,
can_dig = function(pos,player)
local name = player:get_player_name()
@@ -110,18 +117,18 @@ minetest.register_node("printer:printer",{
local facedir = minetest.facedir_to_dir(node.param2)
if msg.command == "get_status" then
if paperstack:get_count() > 0 then
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "OK",paper_left = paperstack:get_count(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "OK",paper_left = paperstack:get_count(),})
else
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "no_paper",paper_left = paperstack:get_count(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "no_paper",paper_left = paperstack:get_count(),})
end
elseif msg.command == "formfeed" then
if paperstack:get_count() > 0 then
eject_item(pos,facedir,ItemStack("default:paper"))
paperstack:take_item(1)
minetest.sound_play("printer_feed",{pos=pos})
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "OK",paper_left = paperstack:get_count(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "OK",paper_left = paperstack:get_count(),})
else
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "no_paper",paper_left = paperstack:get_count(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "no_paper",paper_left = paperstack:get_count(),})
end
elseif msg.command == "print" then
if paperstack:get_count() > 0 then
@@ -134,9 +141,9 @@ minetest.register_node("printer:printer",{
eject_item(pos,facedir,document)
paperstack:take_item(1)
minetest.sound_play("printer_print",{pos=pos})
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "OK",paper_left = paperstack:get_count(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "OK",paper_left = paperstack:get_count(),})
else
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "no_paper",paper_left = paperstack:get_count(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "no_paper",paper_left = paperstack:get_count(),})
end
end
meta:get_inventory():set_stack("paper",1,paperstack)
@@ -198,7 +205,14 @@ minetest.register_node("printer:receipt_printer",{
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:get_inventory():set_size("paper",1)
- meta:set_string("formspec","size[8,6]label[1,0;Paper Compartment]list[context;paper;1,0.5;1,1]list[current_player;main;0,2;8,4]listring[]field[3,0.75;2,1;channel;Channel;${channel}]button_exit[5,0.5;2,1;set;Set]")
+ meta:set_string("formspec","size[8,6]"..
+ "label[1,0;Paper Compartment]"..
+ "list[context;paper;1,0.5;1,1]"..
+ "list[current_player;main;0,2;8,4]"..
+ "listring[]"..
+ "field[3,0.75;2,1;channel;Channel;${channel}]"..
+ "button_exit[5,0.5;2,1;set;Set]"
+ )
end,
can_dig = function(pos,player)
local name = player:get_player_name()
@@ -258,9 +272,9 @@ minetest.register_node("printer:receipt_printer",{
local facedir = minetest.facedir_to_dir(node.param2)
if msg.command == "get_status" then
if paperstack:get_count() > 0 and paperstack:get_name() == "printer:receiptpaper_roll" then
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "OK",paper_left = 65535-paperstack:get_wear(),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "OK",paper_left = 65535-paperstack:get_wear(),})
else
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "no_paper",paper_left = 0,})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "no_paper",paper_left = 0,})
end
elseif msg.command == "print" then
if paperstack:get_count() > 0 and paperstack:get_name() == "printer:receiptpaper_roll" then
@@ -279,9 +293,9 @@ minetest.register_node("printer:receipt_printer",{
paperstack:set_wear(newwear)
end
meta:get_inventory():set_stack("paper",1,paperstack)
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "OK",paper_left = math.max(0,65535-newwear),})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "OK",paper_left = math.max(0,65535-newwear),})
else
- digiline:receptor_send(pos,digiline.rules.default,channel,{status = "no_paper",paper_left = 0,})
+ digilines.receptor_send(pos,digilines.rules.default,channel,{status = "no_paper",paper_left = 0,})
end
end
end,
diff --git a/mod.conf b/mod.conf
new file mode 100644
index 0000000..54fb774
--- /dev/null
+++ b/mod.conf
@@ -0,0 +1,3 @@
+name = printer
+description = Printer
+depends = digilines,default