1 local S
= minetest
.get_translator("gluncarp")
2 local F
= minetest
.formspec_escape
23 minetest
.register_node("gluncarp:machine", {
24 description
= S("Carpet Workstation"),
25 _tt_help
= S("Turns cloth to carpets"),
27 "gluncarp_machine_top.png",
28 "gluncarp_machine_bottom.png",
29 "gluncarp_machine_side2.png",
30 "gluncarp_machine_side1.png",
31 "gluncarp_machine_back.png",
32 "gluncarp_machine_front.png"
36 paramtype2
= "facedir",
37 is_ground_content
= false,
38 groups
= {oddly_breakable_by_hand
=2, choppy
=3},
42 {-0.5, -0.5, -0.125, 0.5, -0.375, 0.125},
43 {-0.5, 0.375, 0.0625, 0.5, 0.4375, 0.125},
44 {0.4375, -0.375, -0.125, 0.5, 0.375, -0.0625},
45 {-0.5, -0.375, -0.125, -0.4375, 0.375, -0.0625},
46 {0.21875, -0.375, -0.03125, 0.28125, 0.5, 0.03125},
47 {-0.28125, -0.375, -0.03125, -0.21875, 0.5, 0.03125},
48 {-0.03125, -0.4375, -0.03125, 0.03125, 0.5, 0.03125},
49 {-0.3125, -0.3125, -0.03125, 0.3125, 0.3125, 0.03125},
50 {-0.5, -0.5, -0.25, 0.5, -0.4375, 0.25},
51 {0.4375, -0.4375, 0.0625, 0.5, 0.4375, 0.125},
52 {-0.5, -0.4375, 0.0625, -0.4375, 0.4375, 0.125},
53 {-0.5, 0.375, -0.125, 0.5, 0.4375, -0.0625},
54 {-0.5, 0.375, -0.125, -0.375, 0.4375, 0.125},
55 {0.375, 0.375, -0.125, 0.5, 0.4375, 0.125},
56 {0.21875, 0.375, -0.0625, 0.28125, 0.4375, 0.0625},
57 {-0.03125, 0.375, -0.0625, 0.03125, 0.4375, 0.0625},
58 {-0.28125, 0.375, -0.0625, -0.21875, 0.4375, 0.0625},
64 {-0.5, -0.5, -0.25, 0.5, 0.5, 0.25}
67 sounds
= hades_sounds
.node_sound_wood_defaults(),
69 after_place_node
= function(pos
, placer
)
70 local meta
= minetest
.get_meta(pos
);
71 meta
:set_string("owner", (placer
:get_player_name() or ""));
72 meta
:set_string("infotext", S("Carpet workstation (owned by @1)", placer
:get_player_name() or ""));
77 can_dig
= function(pos
,player
)
78 local meta
= minetest
.get_meta(pos
);
79 local inv
= meta
:get_inventory()
80 if not inv
:is_empty("wool") then
82 elseif not inv
:is_empty("res") then
88 on_construct
= function(pos
)
89 local meta
= minetest
.get_meta(pos
)
90 meta
:set_string("formspec", "size[10,6;]"..
91 "bgcolor[#00000000;neither]"..
92 "background9[6,6;10,6;gluncarp_background.png;true;6]"..
93 "list[current_name;wool;3,0.5;1,1;]"..
94 "list[current_name;res;6,0.5;1,1;]"..
95 "label[3,0;"..F(S("Cloth:")).."]"..
96 "label[6,0;"..F(S("Output:")).."]"..
98 "label[4.5,0;"..F(S("Craft:")).."]"..
99 "image_button[4.5,0.5;1,1;gluncarp_mach1.png;carpet; ]"..
101 "list[current_player;main;0,2;10,4;]"..
102 "listring[current_player;main]"..
103 "listring[current_name;wool]"..
104 "listring[current_player;main]"..
105 "listring[current_name;res]")
106 meta
:set_string("infotext", S("Carpet workstation"))
107 local inv
= meta
:get_inventory()
108 -- Input slot (called "wool" for historic reasons only)
109 inv
:set_size("wool", 1)
110 inv
:set_size("res", 1)
113 on_receive_fields
= function(pos
, formname
, fields
, sender
)
114 local meta
= minetest
.get_meta(pos
)
115 local inv
= meta
:get_inventory()
117 if not fields
["carpet"] then
121 local count
, material
122 if fields
["carpet"] then
123 if inv
:is_empty("wool") then
128 local clothstack
= inv
:get_stack("wool", 1)
129 local clothname
= clothstack
:get_name()
130 local resstack
= inv
:get_stack("res", 1)
131 ----------------------------------------------------------------------
133 ----------------------------------------------------------------------
135 local color
= colors
[col
]
136 if clothname
== "cloth:"..color
then
139 elseif clothname
== "gluncarp:wool_"..color
then
142 elseif clothname
== "hades_stairs:slab_"..color
then
145 elseif clothname
== "hades_stairs:stair_"..color
then
148 elseif clothname
== "hades_stairs:stair_in_"..color
then
151 elseif clothname
== "hades_stairs:stair_out_"..color
then
156 ----------------------------------------------------------------------
158 local output_item
= "gluncarp:"..material
159 if not inv
:is_empty("res") then
160 if resstack
:get_name() ~= output_item
then
162 elseif resstack
:get_count() == resstack
:get_stack_max() then
166 local success
= false
167 for i
= 0, count
-1 do
168 local result
= inv
:add_item("res", output_item
)
169 if result
~= nil then
174 clothstack
:take_item()
175 inv
:set_stack("wool", 1, clothstack
)
184 minetest
.register_craft({
185 output
= 'gluncarp:machine',
187 {'group:wood', 'group:stick', 'group:wood'},
188 {'hades_farming:string', 'hades_farming:string', 'hades_farming:string'},
189 {'group:wood', "group:stick", 'group:wood'},