summaryrefslogtreecommitdiff
path: root/init.lua
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 /init.lua
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
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua42
1 files changed, 28 insertions, 14 deletions
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,