summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--factory/LICENSE17
-rw-r--r--factory/crafting.lua130
-rw-r--r--factory/craftitems.lua30
-rw-r--r--factory/ind_furnace.lua327
-rw-r--r--factory/ind_squeezer.lua327
-rw-r--r--factory/init.lua142
-rw-r--r--factory/nodes.lua384
-rw-r--r--factory/settings.txt14
-rw-r--r--factory/textures/factory_belt_bottom.pngbin0 -> 18991 bytes
-rw-r--r--factory/textures/factory_belt_side.pngbin0 -> 18872 bytes
-rw-r--r--factory/textures/factory_belt_top.pngbin0 -> 19623 bytes
-rw-r--r--factory/textures/factory_belt_top_animation.pngbin0 -> 19783 bytes
-rw-r--r--factory/textures/factory_brick.pngbin0 -> 15879 bytes
-rw-r--r--factory/textures/factory_compressed_clay.pngbin0 -> 14715 bytes
-rw-r--r--factory/textures/factory_compressor_drop_bg.pngbin0 -> 18323 bytes
-rw-r--r--factory/textures/factory_compressor_drop_fg.pngbin0 -> 18074 bytes
-rw-r--r--factory/textures/factory_compressor_front.pngbin0 -> 17135 bytes
-rw-r--r--factory/textures/factory_compressor_front_active.pngbin0 -> 20987 bytes
-rw-r--r--factory/textures/factory_ind_furnace_fire_bg.pngbin0 -> 282 bytes
-rw-r--r--factory/textures/factory_ind_furnace_fire_fg.pngbin0 -> 803 bytes
-rw-r--r--factory/textures/factory_ind_furnace_front.pngbin0 -> 17536 bytes
-rw-r--r--factory/textures/factory_ind_furnace_front_active.pngbin0 -> 21355 bytes
-rw-r--r--factory/textures/factory_lump.pngbin0 -> 15282 bytes
-rw-r--r--factory/textures/factory_machine_brick_1.pngbin0 -> 16597 bytes
-rw-r--r--factory/textures/factory_machine_brick_2.pngbin0 -> 20229 bytes
-rw-r--r--factory/textures/factory_machine_side_1.pngbin0 -> 19928 bytes
-rw-r--r--factory/textures/factory_machine_steel.pngbin0 -> 18503 bytes
-rw-r--r--factory/textures/factory_small_diamond_gear.pngbin0 -> 20593 bytes
-rw-r--r--factory/textures/factory_small_gold_gear.pngbin0 -> 23631 bytes
-rw-r--r--factory/textures/factory_small_steel_gear.pngbin0 -> 20380 bytes
-rw-r--r--factory/textures/factory_smoke.pngbin0 -> 19274 bytes
-rw-r--r--factory/textures/factory_steel_noise.pngbin0 -> 22911 bytes
-rw-r--r--factory/textures/factory_steel_noise_diamond.pngbin0 -> 24262 bytes
-rw-r--r--factory/textures/factory_steel_noise_gold.pngbin0 -> 24195 bytes
-rw-r--r--factory/textures/factory_steel_noise_red.pngbin0 -> 24372 bytes
-rw-r--r--factory/textures/factory_tree_sap.pngbin0 -> 18279 bytes
-rw-r--r--factory/textures/gui_factoryformbg.pngbin0 -> 194546 bytes
-rw-r--r--factory/textures/gui_ind_furnace_arrow_bg.pngbin0 -> 15369 bytes
-rw-r--r--factory/textures/gui_ind_furnace_arrow_fg.pngbin0 -> 15140 bytes
39 files changed, 1371 insertions, 0 deletions
diff --git a/factory/LICENSE b/factory/LICENSE
new file mode 100644
index 0000000..eb930e9
--- /dev/null
+++ b/factory/LICENSE
@@ -0,0 +1,17 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+----------
+
+This license is commonly known as "WTFPL".
diff --git a/factory/crafting.lua b/factory/crafting.lua
new file mode 100644
index 0000000..010bd6a
--- /dev/null
+++ b/factory/crafting.lua
@@ -0,0 +1,130 @@
+minetest.register_craft({
+ output = "factory:belt 12",
+ recipe = {
+ {"", "default:gold_ingot", ""},
+ {"default:obsidian", "factory:small_steel_gear", "default:obsidian"},
+ {"default:steelblock", "default:steelblock", "default:steelblock"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:arm",
+ recipe = {
+ {"default:steel_ingot", "default:steel_ingot", "farming:hoe_steel"},
+ {"default:steel_ingot", "default:gold_ingot", "factory:small_steel_gear"},
+ {"default:steelblock", "default:steelblock", "default:steelblock"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:smoke_tube",
+ recipe = {
+ {"default:steel_ingot", "", "default:steel_ingot"},
+ {"default:steel_ingot", "", "default:steel_ingot"},
+ {"default:steel_ingot", "", "default:steel_ingot"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:ind_furnace",
+ recipe = {
+ {"factory:small_steel_gear", "default:steel_ingot", "factory:small_steel_gear"},
+ {"default:steel_ingot", "default:furnace", "default:steel_ingot"},
+ {"default:stonebrick", "default:obsidian", "default:stonebrick"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:small_steel_gear 3",
+ recipe = {
+ {"default:steel_ingot", "", "default:steel_ingot"},
+ {"", "default:steel_ingot", ""},
+ {"default:steel_ingot", "", "default:steel_ingot"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:small_gold_gear 2",
+ recipe = {
+ {"default:gold_ingot", "", "default:gold_ingot"},
+ {"", "factory:small_steel_gear", ""},
+ {"default:gold_ingot", "", "default:gold_ingot"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:small_diamond_gear 2",
+ recipe = {
+ {"default:diamond", "", "default:diamond"},
+ {"", "factory:small_gold_gear", ""},
+ {"default:diamond", "", "default:diamond"}
+ }
+})
+
+minetest.register_craft({
+ output = "factory:taker",
+ recipe = {
+ {"default:shovel_steel", "default:steel_ingot", "default:gold_ingot"},
+ {"factory:small_steel_gear", "factory:small_steel_gear", "default:gold_ingot"},
+ {"default:steelblock", "default:steelblock", "default:steelblock"}
+ }
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "factory:taker_gold",
+ recipe = {"factory:taker", "default:goldblock", "factory:small_gold_gear"}
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "factory:taker_diamond",
+ recipe = {"factory:taker_gold", "default:diamondblock", "factory:small_diamond_gear"}
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "factory:queuedarm",
+ recipe = {"factory:arm", "default:chest", "factory:small_gold_gear"}
+})
+
+factory.register_craft({
+ type = "ind_squeezer",
+ output = "factory:tree_sap",
+ recipe = {{"default:tree"}}
+})
+
+factory.register_craft({
+ type = "ind_squeezer",
+ output = "factory:tree_sap",
+ recipe = {{"default:jungle_tree"}}
+})
+
+factory.register_craft({
+ type = "ind_squeezer",
+ output = "factory:compressed_clay",
+ recipe = {{"default:clay_lump"}}
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "factory:factory_lump",
+ recipe = "factory:compressed_clay"
+})
+
+minetest.register_craft({
+ output = 'factory:factory_brick 6',
+ recipe = {
+ {'factory:factory_lump', 'factory:factory_lump'},
+ {'factory:factory_lump', 'factory:factory_lump'},
+ }
+})
+
+minetest.register_craft({
+ output = "factory:ind_squeezer",
+ recipe = {
+ {"default:glass", "default:stick", "default:glass"},
+ {"default:glass", "default:steelblock", "default:glass"},
+ {"factory:small_gold_gear", "factory:ind_furnace", "factory:small_gold_gear"}
+ }
+}) \ No newline at end of file
diff --git a/factory/craftitems.lua b/factory/craftitems.lua
new file mode 100644
index 0000000..61e6f0c
--- /dev/null
+++ b/factory/craftitems.lua
@@ -0,0 +1,30 @@
+minetest.register_craftitem("factory:small_steel_gear", {
+ description = "Small Steel Gear",
+ inventory_image = "factory_small_steel_gear.png"
+})
+
+minetest.register_craftitem("factory:small_gold_gear", {
+ description = "Small Gold Gear",
+ inventory_image = "factory_small_gold_gear.png"
+})
+
+minetest.register_craftitem("factory:small_diamond_gear", {
+ description = "Small Diamond Gear",
+ inventory_image = "factory_small_diamond_gear.png"
+})
+
+minetest.register_craftitem("factory:tree_sap", {
+ description = "Tree Sap",
+ inventory_image = "factory_tree_sap.png"
+})
+
+minetest.register_craftitem("factory:compressed_clay", {
+ description = "Compressed Clay",
+ inventory_image = "factory_compressed_clay.png"
+})
+
+minetest.register_craftitem("factory:factory_lump", {
+ description = "Factory Lump",
+ inventory_image = "factory_lump.png"
+})
+
diff --git a/factory/ind_furnace.lua b/factory/ind_furnace.lua
new file mode 100644
index 0000000..4614105
--- /dev/null
+++ b/factory/ind_furnace.lua
@@ -0,0 +1,327 @@
+function factory.ind_furnace_active(pos, percent, item_percent)
+ local formspec =
+ "size[8,8.5]"..
+ factory_gui_bg..
+ factory_gui_bg_img..
+ factory_gui_slots..
+ "list[current_name;src;2.75,0.5;1,1;]"..
+ "list[current_name;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;factory_ind_furnace_fire_bg.png^[lowpart:"..
+ (100-percent)..":factory_ind_furnace_fire_fg.png]"..
+ "image[3.75,1.5;1,1;gui_ind_furnace_arrow_bg.png^[lowpart:"..
+ (item_percent*100)..":gui_ind_furnace_arrow_fg.png^[transformR270]"..
+ "list[current_name;dst;4.75,0.5;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ factory.get_hotbar_bg(0,4.25)
+ return formspec
+ end
+
+function factory.ind_furnace_active_formspec(pos, percent)
+ local meta = minetest.get_meta(pos)local inv = meta:get_inventory()
+ local srclist = inv:get_list("src")
+ local cooked = nil
+ local aftercooked = nil
+ if srclist then
+ cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
+ end
+ local item_percent = 0
+ if cooked then
+ item_percent = meta:get_float("src_time")/cooked.time
+ end
+
+ return factory.ind_furnace_active(pos, percent, item_percent)
+end
+
+factory.ind_furnace_inactive_formspec =
+ "size[8,8.5]"..
+ factory_gui_bg..
+ factory_gui_bg_img..
+ factory_gui_slots..
+ "list[current_name;src;2.75,0.5;1,1;]"..
+ "list[current_name;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;factory_ind_furnace_fire_bg.png]"..
+ "image[3.75,1.5;1,1;gui_ind_furnace_arrow_bg.png^[transformR270]"..
+ "list[current_name;dst;4.75,0.5;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ factory.get_hotbar_bg(0,4.25)
+
+minetest.register_node("factory:ind_furnace", {
+ description = "Industrial Furnace",
+ tiles = {"factory_machine_brick_1.png", "factory_machine_brick_2.png", "factory_machine_side_1.png",
+ "factory_machine_side_1.png", "factory_machine_side_1.png", "factory_ind_furnace_front.png"},
+ paramtype2 = "facedir",
+ groups = {cracky=3},
+ legacy_facedir_simple = true,
+ is_ground_content = false,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", factory.ind_furnace_inactive_formspec)
+ meta:set_string("infotext", "Industrial Furnace")
+ local inv = meta:get_inventory()
+ inv:set_size("fuel", 1)
+ inv:set_size("src", 1)
+ inv:set_size("dst", 4)
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ if not inv:is_empty("fuel") then
+ return false
+ elseif not inv:is_empty("dst") then
+ return false
+ elseif not inv:is_empty("src") then
+ return false
+ end
+ return true
+ end,
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if listname == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Furnace is empty")
+ end
+ return stack:get_count()
+ else
+ return 0
+ end
+ elseif listname == "src" then
+ return stack:get_count()
+ elseif listname == "dst" then
+ return 0
+ end
+ end,
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local stack = inv:get_stack(from_list, from_index)
+ if to_list == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Furnace is empty")
+ end
+ return count
+ else
+ return 0
+ end
+ elseif to_list == "src" then
+ return count
+ elseif to_list == "dst" then
+ return 0
+ end
+ end,
+})
+
+minetest.register_node("factory:ind_furnace_active", {
+ description = "Industrial Furnace",
+ tiles = {
+ "factory_machine_brick_1.png",
+ "factory_machine_brick_2.png",
+ "factory_machine_side_1.png",
+ "factory_machine_side_1.png",
+ "factory_machine_side_1.png",
+ {
+ image = "factory_ind_furnace_front_active.png",
+ backface_culling = false,
+ animation = {
+ type = "vertical_frames",
+ aspect_w = 32,
+ aspect_h = 32,
+ length = 1.5
+ },
+ }
+ },
+ paramtype2 = "facedir",
+ light_source = 14,
+ drop = "factory:ind_furnace",
+ groups = {cracky=3, not_in_creative_inventory=1,hot=1},
+ legacy_facedir_simple = true,
+ is_ground_content = false,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", factory.ind_furnace_inactive_formspec)
+ meta:set_string("infotext", "Industrial Furnace (burning)");
+ local inv = meta:get_inventory()
+ inv:set_size("fuel", 1)
+ inv:set_size("src", 1)
+ inv:set_size("dst", 4)
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ if not inv:is_empty("fuel") then
+ return false
+ elseif not inv:is_empty("dst") then
+ return false
+ elseif not inv:is_empty("src") then
+ return false
+ end
+ return true
+ end,
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if listname == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Furnace is empty")
+ end
+ return stack:get_count()
+ else
+ return 0
+ end
+ elseif listname == "src" then
+ return stack:get_count()
+ elseif listname == "dst" then
+ return 0
+ end
+ end,
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local stack = inv:get_stack(from_list, from_index)
+ if to_list == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Furnace is empty")
+ end
+ return count
+ else
+ return 0
+ end
+ elseif to_list == "src" then
+ return count
+ elseif to_list == "dst" then
+ return 0
+ end
+ end,
+})
+
+minetest.register_abm({
+ nodenames = {"factory:ind_furnace","factory:ind_furnace_active"},
+ interval = 1.0,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local meta = minetest.get_meta(pos)
+ for i, name in ipairs({
+ "fuel_totaltime",
+ "fuel_time",
+ "src_totaltime",
+ "src_time"
+ }) do
+ if meta:get_string(name) == "" then
+ meta:set_float(name, 0.0)
+ end
+ end
+
+ local height = 0
+
+ for i=1,7 do -- SMOKE TUBE CHECK
+ local dn = minetest.get_node({x = pos.x, y = pos.y + i, z = pos.z})
+ if dn.name == "factory:smoke_tube" then
+ height = height + 1
+ else break end
+ end
+
+ if minetest.get_node({x = pos.x, y = pos.y + height + 1, z = pos.z}).name ~= "air" then return end
+
+ if height < 2 then return else
+ if minetest.get_node(pos).name == "factory:ind_furnace_active" then
+ minetest.add_particlespawner({
+ amount = 4,
+ time = 3,
+ minpos = {x = pos.x - 0.2, y = pos.y + height + 0.3, z = pos.z - 0.2},
+ maxpos = {x = pos.x + 0.2, y = pos.y + height + 0.6, z = pos.z + 0.2},
+ minvel = {x=-0.4, y=1, z=-0.4},
+ maxvel = {x=0.4, y=2, z=0.4},
+ minacc = {x=0, y=0, z=0},
+ maxacc = {x=0, y=0, z=0},
+ minexptime = 0.8,
+ maxexptime = 2,
+ minsize = 2,
+ maxsize = 4,
+ collisiondetection = false,
+ vertical = false,
+ texture = "factory_smoke.png",
+ playername = nil,
+ })
+ end
+ end
+
+ local inv = meta:get_inventory()
+
+ local srclist = inv:get_list("src")
+ local cooked = nil
+ local aftercooked
+
+ if srclist then
+ cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
+ end
+
+ local was_active = false
+
+ if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
+ was_active = true
+ meta:set_float("fuel_time", meta:get_float("fuel_time") + 0.65)
+ meta:set_float("src_time", meta:get_float("src_time") + 1.2)
+ if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
+ -- check if there's room for output in "dst" list
+ if inv:room_for_item("dst",cooked.item) then
+ -- Put result in "dst" list
+ inv:add_item("dst", cooked.item)
+ -- take stuff from "src" list
+ inv:set_stack("src", 1, aftercooked.items[1])
+ else
+ --print("Could not insert '"..cooked.item:to_string().."'")
+ end
+ meta:set_string("src_time", 0)
+ end
+ end
+
+ if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
+ local percent = math.floor(meta:get_float("fuel_time") /
+ meta:get_float("fuel_totaltime") * 100)
+ meta:set_string("infotext","Industrial Furnace is smelting, fuel current used: "..percent.."%")
+ factory.swap_node(pos,"factory:ind_furnace_active")
+ meta:set_string("formspec",factory.ind_furnace_active_formspec(pos, percent))
+ return
+ end
+
+ local fuel = nil
+ local afterfuel
+ local cooked = nil
+ local fuellist = inv:get_list("fuel")
+ local srclist = inv:get_list("src")
+
+ if srclist then
+ cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
+ end
+ if fuellist then
+ fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
+ end
+
+ if not fuel or fuel.time <= 0 then
+ meta:set_string("infotext","Industrial Furnace has nothing to burn with")
+ factory.swap_node(pos,"factory:ind_furnace")
+ meta:set_string("formspec", factory.ind_furnace_inactive_formspec)
+ return
+ end
+
+ if cooked.item:is_empty() then
+ if was_active then
+ meta:set_string("infotext","Furnace is empty")
+ factory.swap_node(pos,"factory:ind_furnace")
+ meta:set_string("formspec", factory.ind_furnace_inactive_formspec)
+ end
+ return
+ end
+
+ meta:set_string("fuel_totaltime", fuel.time)
+ meta:set_string("fuel_time", 0)
+
+ inv:set_stack("fuel", 1, afterfuel.items[1])
+ end,
+}) \ No newline at end of file
diff --git a/factory/ind_squeezer.lua b/factory/ind_squeezer.lua
new file mode 100644
index 0000000..e580984
--- /dev/null
+++ b/factory/ind_squeezer.lua
@@ -0,0 +1,327 @@
+function factory.ind_squeezer_active(pos, percent, item_percent)
+ local formspec =
+ "size[8,8.5]"..
+ factory_gui_bg..
+ factory_gui_bg_img..
+ factory_gui_slots..
+ "list[current_name;src;2.75,0.5;1,1;]"..
+ "list[current_name;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;factory_compressor_drop_bg.png^[lowpart:"..
+ (100-percent)..":factory_compressor_drop_fg.png]"..
+ "image[3.75,1.5;1,1;gui_ind_furnace_arrow_bg.png^[lowpart:"..
+ (item_percent*100)..":gui_ind_furnace_arrow_fg.png^[transformR270]"..
+ "list[current_name;dst;4.75,0.5;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ factory.get_hotbar_bg(0,4.25)
+ return formspec
+ end
+
+function factory.ind_squeezer_active_formspec(pos, percent)
+ local meta = minetest.get_meta(pos)local inv = meta:get_inventory()
+ local srclist = inv:get_list("src")
+ local cooked = nil
+ if srclist then
+ cooked = factory.get_craft_result({method = "ind_squeezer", width = 1, items = srclist})
+ end
+ local item_percent = 0
+ if cooked then
+ item_percent = meta:get_float("src_time")/cooked.time
+ end
+
+ return factory.ind_squeezer_active(pos, percent, item_percent)
+end
+
+factory.ind_squeezer_inactive_formspec =
+ "size[8,8.5]"..
+ factory_gui_bg..
+ factory_gui_bg_img..
+ factory_gui_slots..
+ "list[current_name;src;2.75,0.5;1,1;]"..
+ "list[current_name;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;factory_compressor_drop_bg.png]"..
+ "image[3.75,1.5;1,1;gui_ind_furnace_arrow_bg.png^[transformR270]"..
+ "list[current_name;dst;4.75,0.5;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ factory.get_hotbar_bg(0,4.25)
+
+minetest.register_node("factory:ind_squeezer", {
+ description = "Industrial Squeezer",
+ tiles = {"factory_machine_brick_1.png", "factory_machine_brick_2.png", "factory_machine_side_1.png",
+ "factory_machine_side_1.png", "factory_machine_side_1.png", "factory_compressor_front.png"},
+ paramtype2 = "facedir",
+ groups = {cracky=3},
+ legacy_facedir_simple = true,
+ is_ground_content = false,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", factory.ind_squeezer_inactive_formspec)
+ meta:set_string("infotext", "Industrial Squeezer")
+ local inv = meta:get_inventory()
+ inv:set_size("fuel", 1)
+ inv:set_size("src", 1)
+ inv:set_size("dst", 4)
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ if not inv:is_empty("fuel") then
+ return false
+ elseif not inv:is_empty("dst") then
+ return false
+ elseif not inv:is_empty("src") then
+ return false
+ end
+ return true
+ end,
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if listname == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Squeezer is empty")
+ end
+ return stack:get_count()
+ else
+ return 0
+ end
+ elseif listname == "src" then
+ return stack:get_count()
+ elseif listname == "dst" then
+ return 0
+ end
+ end,
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local stack = inv:get_stack(from_list, from_index)
+ if to_list == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Squeezer is empty")
+ end
+ return count
+ else
+ return 0
+ end
+ elseif to_list == "src" then
+ return count
+ elseif to_list == "dst" then
+ return 0
+ end
+ end,
+})
+
+minetest.register_node("factory:ind_squeezer_active", {
+ description = "Industrial Squeezer",
+ tiles = {
+ "factory_machine_brick_1.png",
+ "factory_machine_brick_2.png",
+ "factory_machine_side_1.png",
+ "factory_machine_side_1.png",
+ "factory_machine_side_1.png",
+ {
+ image = "factory_compressor_front_active.png",
+ backface_culling = false,
+ animation = {
+ type = "vertical_frames",
+ aspect_w = 32,
+ aspect_h = 32,
+ length = 4
+ },
+ }
+ },
+ paramtype2 = "facedir",
+ light_source = 2,
+ drop = "factory:ind_squeezer",
+ groups = {cracky=3, not_in_creative_inventory=1,hot=1},
+ legacy_facedir_simple = true,
+ is_ground_content = false,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", factory.ind_squeezer_inactive_formspec)
+ meta:set_string("infotext", "Industrial Squeezer (working)");
+ local inv = meta:get_inventory()
+ inv:set_size("fuel", 1)
+ inv:set_size("src", 1)
+ inv:set_size("dst", 4)
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ if not inv:is_empty("fuel") then
+ return false
+ elseif not inv:is_empty("dst") then
+ return false
+ elseif not inv:is_empty("src") then
+ return false
+ end
+ return true
+ end,
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if listname == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Squeezer is empty")
+ end
+ return stack:get_count()
+ else
+ return 0
+ end
+ elseif listname == "src" then
+ return stack:get_count()
+ elseif listname == "dst" then
+ return 0
+ end
+ end,
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local stack = inv:get_stack(from_list, from_index)
+ if to_list == "fuel" then
+ if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext","Industrial Squeezer is empty")
+ end
+ return count
+ else
+ return 0
+ end
+ elseif to_list == "src" then
+ return count
+ elseif to_list == "dst" then
+ return 0
+ end
+ end,
+})
+
+minetest.register_abm({
+ nodenames = {"factory:ind_squeezer","factory:ind_squeezer_active"},
+ interval = 1.0,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local meta = minetest.get_meta(pos)
+ for i, name in ipairs({
+ "fuel_totaltime",
+ "fuel_time",
+ "src_totaltime",
+ "src_time"
+ }) do
+ if meta:get_string(name) == "" then
+ meta:set_float(name, 0.0)
+ end
+ end
+
+ local height = 0
+
+ for i=1,7 do -- SMOKE TUBE CHECK
+ local dn = minetest.get_node({x = pos.x, y = pos.y + i, z = pos.z})
+ if dn.name == "factory:smoke_tube" then
+ height = height + 1
+ else break end
+ end
+
+ if minetest.get_node({x = pos.x, y = pos.y + height + 1, z = pos.z}).name ~= "air" then return end
+
+ if height < 1 then return else
+ if minetest.get_node(pos).name == "factory:ind_squeezer_active" then
+ minetest.add_particlespawner({
+ amount = 4,
+ time = 3,
+ minpos = {x = pos.x - 0.2, y = pos.y + height + 0.3, z = pos.z - 0.2},
+ maxpos = {x = pos.x + 0.2, y = pos.y + height + 0.6, z = pos.z + 0.2},
+ minvel = {x=-0.4, y=1, z=-0.4},
+ maxvel = {x=0.4, y=2, z=0.4},
+ minacc = {x=0, y=0, z=0},
+ maxacc = {x=0, y=0, z=0},
+ minexptime = 0.8,
+ maxexptime = 2,
+ minsize = 2,
+ maxsize = 4,
+ collisiondetection = false,
+ vertical = false,
+ texture = "factory_smoke.png",
+ playername = nil,
+ })
+ end
+ end
+
+ local inv = meta:get_inventory()
+
+ local srclist = inv:get_list("src")
+ local cooked = nil
+
+ if srclist then
+ cooked = factory.get_craft_result({method = "ind_squeezer", width = 1, items = srclist})
+ end
+
+ local was_active = false
+
+ if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
+ was_active = true
+ meta:set_float("fuel_time", meta:get_float("fuel_time") + 0.9)
+ meta:set_float("src_time", meta:get_float("src_time") + 0.2)
+ if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
+ -- check if there's room for output in "dst" list
+ if inv:room_for_item("dst",cooked.item) then
+ -- Put result in "dst" list
+ inv:add_item("dst", cooked.item)
+ -- take stuff from "src" list
+ local afteritem = inv:get_stack("src", 1)
+ afteritem:take_item(1)
+ inv:set_stack("src", 1, afteritem)
+ else
+ --print("Could not insert '"..cooked.item:to_string().."'")
+ end
+ meta:set_string("src_time", 0)
+ end
+ end
+
+ if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
+ local percent = math.floor(meta:get_float("fuel_time") /
+ meta:get_float("fuel_totaltime") * 100)
+ meta:set_string("infotext","Industrial Squeezer is working, fuel current used: "..percent.."%")
+ factory.swap_node(pos,"factory:ind_squeezer_active")
+ meta:set_string("formspec",factory.ind_squeezer_active_formspec(pos, percent))
+ return
+ end
+
+ local fuel = nil
+ local afterfuel
+ local cooked = nil
+ local fuellist = inv:get_list("fuel")
+ local srclist = inv:get_list("src")
+
+ if srclist then
+ cooked = factory.get_craft_result({method = "ind_squeezer", width = 1, items = srclist})
+ end
+ if fuellist then
+ fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
+ end
+
+ if not fuel or fuel.time <= 0 then
+ meta:set_string("infotext","Industrial Squeezer has nothing to burn with")
+ factory.swap_node(pos,"factory:ind_squeezer")
+ meta:set_string("formspec", factory.ind_squeezer_inactive_formspec)
+ return
+ end
+
+ if cooked.item:is_empty() then
+ if was_active then
+ meta:set_string("infotext","Industrial Squeezer is empty")
+ factory.swap_node(pos,"factory:ind_squeezer")
+ meta:set_string("formspec", factory.ind_squeezer_inactive_formspec)
+ end
+ return
+ end
+
+ meta:set_string("fuel_totaltime", fuel.time)
+ meta:set_string("fuel_time", 0)
+
+ inv:set_stack("fuel", 1, afterfuel.items[1])
+ end,
+}) \ No newline at end of file
diff --git a/factory/init.lua b/factory/init.lua
new file mode 100644
index 0000000..4c97662
--- /dev/null
+++ b/factory/init.lua
@@ -0,0 +1,142 @@
+factory={
+ crafts={},
+ empty={item=ItemStack(nil),time=0}
+}
+
+-- Settings
+dofile(minetest.get_modpath("factory").."/settings.txt")
+
+-- This below is the Crafter mod by the legend MasterGollum
+
+function factory.register_craft(craft)
+ assert(craft.type ~= nil and craft.recipe ~= nil and craft.output ~= nil,
+ "Invalid craft definition, it must have type, recipe and output")
+ assert(type(craft.recipe)=="table" and type(craft.recipe[1])=="table","'recipe' must be a bidimensional table")
+ minetest.log("verbose","registerCraft ("..craft.type..", output="..craft.output.." recipe="..dump(craft.recipe))
+ craft._h=#craft.recipe
+ craft._w=#craft.recipe[1]
+ -- TODO check that all the arrays have the same length...
+ factory.crafts[#factory.crafts+1]=craft
+end
+
+function factory.get_craft_result(data)
+ assert(data.method ~= nil and data.items ~= nil, "Invalid call, method and items must be provided")
+ local w = 1
+ if data.width ~= nil and data.width>0 then
+ w=data.width
+ end
+ local r=nil
+ for zz,craft in ipairs(factory.crafts) do
+ r=factory._check_craft(data,w,craft)
+ if r ~= nil then
+ if factory.debug then
+ print("Craft found, returning "..dump(r.item))
+ end
+ return r
+ end
+ end
+ return factory.empty
+end
+
+function factory._check_craft(data,w,c)
+ if c.type == data.method then
+ -- Here we go..
+ for i=1,w-c._h+1 do
+ for j=1,w-c._w+1 do
+ local p=(i-1)*w+j
+ if factory.debug then
+ print("Checking data.items["..dump(i).."]["..dump(j).."]("..dump(p)..")="..dump(data.items[p]:get_name()).." vs craft.recipe[1][1]="..dump(c.recipe[1][1]))
+ end
+ if data.items[p]:get_name() == c.recipe[1][1] then
+ for m=1,c._h do
+ for n=1,c._w do
+ local q=(i+m-1-1)*w+j+n-1
+ if factory.debug then
+ print(" Checking data.items["..dump(i+m-1).."]["..dump(j+n-1).."]("..dump(q)..")="..dump(data.items[q]:get_name())..
+ " vs craft.recipe["..dump(m).."]["..dump(n).."]="..dump(c.recipe[m][n]))
+ end
+ if c.recipe[m][n] ~= data.items[q]:get_name() then
+ return nil
+ end
+ end
+ end
+ -- found! we still must check that is not any other stuff outside the limits of the recipe sizes...
+ -- Checking at right of the matching square
+ for m=i-c._h+1+1,w do
+ for n=j+c._w,w do
+ local q=(m-1)*w+n
+ if factory.debug then
+ print(" Checking right data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
+ end
+ if data.items[q]:get_name() ~= "" then
+ return nil
+ end
+ end
+ end
+ -- Checking at left of the matching square (the first row has been already scanned)
+ for m=i-c._h+1+1+1,w do
+ for n=1,j-1 do
+ local q=(m-1)*w+n
+ if factory.debug then
+ print(" Checking left data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
+ end
+ if data.items[q]:get_name() ~= "" then
+ return nil
+ end
+ end
+ end
+ -- Checking at bottom of the matching square
+ for m=i+c._h,w do
+ for n=j,j+c._w do
+ local q=(m-1)*w+n
+ if factory.debug then
+ print(" Checking bottom data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
+ end
+ if data.items[q]:get_name() ~= "" then
+ return nil
+ end
+ end
+ end
+ if factory.debug then
+ print("Craft found! "..c.output)
+ end
+ return {item=ItemStack(c.output),time=1}
+ elseif data.items[p] ~= nil and data.items[p]:get_name() ~= "" then
+ if factory.debug then
+ print("Invalid data item "..dump(data.items[p]:get_name()))
+ end
+ return nil
+ end
+ end
+ end
+ end
+end
+
+-- GUI related stuff
+factory_gui_bg = "bgcolor[#080808BB;true]"
+factory_gui_bg_img = "background[5,5;1,1;gui_factoryformbg.png;true]"
+factory_gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
+
+function factory.get_hotbar_bg(x,y)
+ local out = ""
+ for i=0,7,1 do
+ out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
+ end
+ return out
+end
+
+function factory.swap_node(pos,name)
+ local node = minetest.get_node(pos)
+ if node.name == name then
+ return
+ end
+ node.name = name
+ minetest.swap_node(pos,node)
+end
+
+dofile(minetest.get_modpath("factory").."/nodes.lua")
+dofile(minetest.get_modpath("factory").."/craftitems.lua")
+dofile(minetest.get_modpath("factory").."/crafting.lua")
+
+dofile(minetest.get_modpath("factory").."/ind_furnace.lua")
+dofile(minetest.get_modpath("factory").."/ind_squeezer.lua") \ No newline at end of file
diff --git a/factory/nodes.lua b/factory/nodes.lua
new file mode 100644
index 0000000..0c8d405
--- /dev/null
+++ b/factory/nodes.lua
@@ -0,0 +1,384 @@
+minetest.register_node("factory:belt", {
+ description = "Conveyor Belt",
+ tiles = {{name="factory_belt_top_animation.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.4}}, "factory_belt_bottom.png", "factory_belt_side.png",
+ "factory_belt_side.png", "factory_belt_side.png", "factory_belt_side.png"},
+ groups = {cracky=1},
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ is_ground_content = true,
+ legacy_facedir_simple = true,
+ node_box = {
+ type = "fixed",
+ fixed = {{-0.5,-0.5,-0.5,0.5,0.0625,0.5},}
+ },
+})
+
+minetest.register_abm({
+ nodenames = {"factory:belt"},
+ neighbors = nil,
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local all_objects = minetest.get_objects_inside_radius(pos, 1)
+ local _,obj
+ for _,obj in ipairs(all_objects) do
+ if not obj:is_player() and obj:get_luaentity() and obj:get_luaentity().name == "__builtin:item" then
+ local a = minetest.facedir_to_dir(minetest.get_node(pos).param2)
+ local b = {x = obj:getpos().x + (a.x / 3.5), y = obj:getpos().y, z = obj:getpos().z + (a.z / 3.5),}
+ obj:moveto(b, false)
+ end
+ end
+ end,
+})
+
+minetest.register_node("factory:arm",{
+ drawtype = "nodebox",
+ tiles = {"factory_steel_noise.png"},
+ paramtype = "light",
+ description = "Pneumatic Mover",
+ groups = {cracky=3},
+ paramtype2 = "facedir",
+ legacy_facedir_simple = true,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4375,0.5}, --base1
+ {-0.125,-0.5,-0.375,0.125,0.0625,0.375}, --base2
+ {-0.125,0.25,-0.5,0.125,0.3125,0.375}, --tube
+ {-0.375,-0.5,-0.0625,0.375,0.0625,0.0625}, --base3
+ {-0.125,-0.125,0.375,0.125,0.125,0.5}, --tube2
+ {-0.125,0.0625,0.3125,0.125,0.25,0.375}, --NodeBox6
+ {-0.125,0.0625,-0.5,-0.0625,0.25,0.3125}, --NodeBox7
+ {0.0625,0.0625,-0.5,0.125,0.25,0.3125}, --NodeBox8
+ {-0.0625,0.0625,-0.5,0.0625,0.125,0.3125}, --NodeBox9
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,0.5,0.5},
+ }
+ },
+})
+
+minetest.register_abm({
+ nodenames = {"factory:arm"},
+ neighbors = nil,
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local all_objects = minetest.get_objects_inside_radius(pos, 0.8)
+ local _,obj
+ for _,obj in ipairs(all_objects) do
+ if not obj:is_player() and obj:get_luaentity() and obj:get_luaentity().name == "__builtin:item" then
+ local a = minetest.facedir_to_dir(minetest.get_node(pos).param2)
+ local b = {x = pos.x + a.x, y = pos.y + a.y, z = pos.z + a.z,}
+ local target = minetest.get_node(b)
+ local stack = ItemStack(obj:get_luaentity().itemstring)
+ if target.name == "default:chest" or target.name == "default:chest_locked" then
+ local meta = minetest.env:get_meta(b)
+ local inv = meta:get_inventory()
+ if inv:room_for_item("main", stack) then
+ inv:add_item("main", stack)
+ obj:remove()
+ else
+ obj:moveto({x = pos.x + (a.x * 2), y = pos.y + 0.5, z = pos.z + (a.z * 2)}, false)
+ end
+ end
+ for i,v in ipairs(armDevicesFurnacelike) do
+ if target.name == v then
+ local a = minetest.facedir_to_dir(minetest.get_node(pos).param2)
+ local b = {x = pos.x + a.x, y = pos.y + a.y, z = pos.z + a.z,}
+ local meta = minetest.env:get_meta(b)
+ local inv = meta:get_inventory()
+
+ if minetest.dir_to_facedir({x = -a.x, y = -a.y, z = -a.z}) == minetest.get_node(b).param2 then
+ -- back, fuel
+ if inv:room_for_item("fuel", stack) then
+ inv:add_item("fuel", stack)
+ obj:remove()
+ else
+ obj:moveto({x = pos.x + (a.x * 2), y = pos.y + 0.5, z = pos.z + (a.z * 2)}, false)
+ end
+ else
+ -- everytin else, src
+ if inv:room_for_item("src", stack) then
+ inv:add_item("src", stack)
+ obj:remove()
+ else
+ obj:moveto({x = pos.x + (a.x * 2), y = pos.y + 0.5, z = pos.z + (a.z * 2)}, false)
+ end
+ end
+ end
+ end
+ end
+ end
+ end,
+})
+
+function factory.register_taker(prefix, suffix, speed, name, ctiles)
+ minetest.register_node("factory:"..prefix.."taker"..suffix,{
+ drawtype = "nodebox",
+ tiles = ctiles,
+ paramtype = "light",
+ description = name,
+ groups = {cracky=3},
+ paramtype2 = "facedir",
+ legacy_facedir_simple = true,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4375,0.5}, --base1
+ {-0.125,-0.5,-0.375,0.125,0.0625,0.375}, --base2
+ {-0.125,0.25,-0.5,0.125,0.3125,0.375}, --tube
+ {-0.375,-0.5,-0.0625,0.375,0.0625,0.0625}, --base3
+ {-0.125,-0.125,0.375,0.125,0.125,0.5}, --tube2
+ {-0.125,0.0625,0.3125,0.125,0.25,0.375}, --NodeBox6
+ {-0.125,0.0625,-0.5,-0.0625,0.25,0.3125}, --NodeBox7
+ {0.0625,0.0625,-0.5,0.125,0.25,0.3125}, --NodeBox8
+ {-0.0625,0.0625,-0.5,0.0625,0.125,0.3125}, --NodeBox9
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,0.5,0.5},
+ }
+ },
+ })
+
+ minetest.register_abm({
+ nodenames = {"factory:"..prefix.."taker"..suffix},
+ neighbors = nil,
+ interval = speed,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local a = minetest.facedir_to_dir(minetest.get_node(pos).param2)
+ local b = {x = pos.x + a.x, y = pos.y + a.y, z = pos.z + a.z,}
+ local target = minetest.get_node(b)
+ if target.name == "default:chest" or target.name == "default:chest_locked" then
+ local meta = minetest.env:get_meta(b)
+ local inv = meta:get_inventory()
+ if not inv:is_empty("main") then
+ local list = inv:get_list("main")
+ local i,item
+ for i,item in ipairs(inv:get_list("main")) do
+ if item:get_name() ~= "" then
+ local droppos = {x = pos.x - (a.x/1.5), y = pos.y + 0.5, z = pos.z - (a.z/1.5)}
+ if factory.logTaker then print(name.." at "..pos.x..", "..pos.y..", "..pos.z.." takes "..item:get_name().." from "..target.name) end
+ minetest.item_drop(item:peek_item(1), "", droppos)
+ item:take_item()
+ inv:set_stack("main", i, item)
+ return
+ end
+ end
+ end
+ end
+ for i,v in ipairs(takerDevicesFurnacelike) do
+ if target.name == v then
+ local meta = minetest.env:get_meta(b)
+ local inv = meta:get_inventory()
+ if not inv:is_empty("dst") then
+ local list = inv:get_list("dst")
+ for k,item in ipairs(inv:get_list("dst")) do
+ if item:get_name() ~= "" then
+ local droppos = {x = pos.x - (a.x/1.5), y = pos.y + 0.5, z = pos.z - (a.z/1.5)}
+ if factory.logTaker then print(name.." at "..pos.x..", "..pos.y..", "..pos.z.." takes "..item:get_name().." from "..target.name) end
+ minetest.item_drop(item:peek_item(1), "", droppos)
+ item:take_item()
+ inv:set_stack("dst", k, item)
+ return
+ end
+ end
+ end
+ end
+ end
+ end,
+ })
+end
+
+factory.register_taker("", "", 2.5, "Pneumatic Taker", {"factory_steel_noise_red.png"})
+factory.register_taker("", "_gold", 1.8, "Pneumatic Taker Mk II", {"factory_steel_noise_gold.png"})
+factory.register_taker("", "_diamond", 1.2, "Pneumatic Taker MK III", {"factory_steel_noise_diamond.png"})
+
+minetest.register_node("factory:smoke_tube", {
+ drawtype = "nodebox",
+ tiles = {"factory_machine_brick_1.png"},
+ paramtype = "light",
+ description = "Smoke Tube",
+ groups = {cracky=3},
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.125,-0.5,0.3125,0.125,0.5,0.375},
+ {-0.125,-0.5,-0.375,0.125,0.5,-0.3125},
+ {0.3125,-0.5,-0.125,0.375,0.5,0.125},
+ {-0.375,-0.5,-0.125,-0.3125,0.5,0.125},
+ {0.125,-0.5,0.25,0.25,0.5,0.3125},
+ {0.25,-0.5,0.125,0.3125,0.5,0.25},
+ {0.25,-0.5,-0.25,0.3125,0.5,-0.125},
+ {0.125,-0.5,-0.3125,0.25,0.5,-0.25},
+ {-0.25,-0.5,-0.3125,-0.125,0.5,-0.25},
+ {-0.3125,-0.5,-0.25,-0.25,0.5,-0.125},
+ {-0.3125,-0.5,0.125,-0.25,0.5,0.25},
+ {-0.25,-0.5,0.25,-0.125,0.5,0.3125},
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ {-0.375,-0.5,-0.375,0.375,0.5,0.375},
+ }
+ },
+})
+
+function qarm_handle (a, b, target, stack, minv, obj)
+ if target.name == "default:chest" or target.name == "default:chest_locked" then
+ local meta = minetest.env:get_meta(b)
+ local inv = meta:get_inventory()
+
+ if inv:room_for_item("main", stack) then
+ inv:add_item("main", stack)
+ if obj~=nil then obj:remove() end
+ elseif minv:room_for_item("main", stack) then
+ minv:add_item("main", stack)
+ if obj~=nil then obj:remove() end
+ else
+ if obj~=nil then obj:moveto({x = pos.x + (a.x * 2), y = pos.y + 0.5, z = pos.z + (a.z * 2)}, false) end
+ end
+ end
+ for i,v in ipairs(armDevicesFurnacelike) do
+ if target.name == v then
+ local meta = minetest.env:get_meta(b)
+ local inv = meta:get_inventory()
+
+ if minetest.dir_to_facedir({x = -a.x, y = -a.y, z = -a.z}) == minetest.get_node(b).param2 then
+ -- back, fuel
+ if inv:room_for_item("fuel", stack) then
+ inv:add_item("fuel", stack)
+ if obj~=nil then obj:remove() end
+ elseif minv:room_for_item("main", stack) then
+ minv:add_item("main", stack)
+ if obj~=nil then obj:remove() end
+ else
+ if obj~=nil then obj:moveto({x = pos.x + (a.x * 2), y = pos.y + 0.5, z = pos.z + (a.z * 2)}, false) end
+ end
+ else
+ -- everytin else, src
+ if inv:room_for_item("src", stack) then
+ inv:add_item("src", stack)
+ if obj~=nil then obj:remove() end
+ elseif minv:room_for_item("main", stack) then
+ minv:add_item("main", stack)
+ if obj~=nil then obj:remove() end
+ else
+ if obj~=nil then obj:moveto({x = pos.x + (a.x * 2), y = pos.y + 0.5, z = pos.z + (a.z * 2)}, false) end
+ end
+ end
+ end
+ end
+end
+
+factory.qformspec =
+ "size[8,8.5]"..
+ factory_gui_bg..
+ factory_gui_bg_img..
+ factory_gui_slots..
+ "list[current_name;main;0,0.3;8,3;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ factory.get_hotbar_bg(0,4.25)
+
+minetest.register_node("factory:queuedarm",{
+ drawtype = "nodebox",
+ tiles = {"factory_steel_noise.png"},
+ paramtype = "light",
+ description = "Queued Pneumatic Mover",
+ groups = {cracky=3},
+ paramtype2 = "facedir",
+ legacy_facedir_simple = true,
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4375,0.5}, --base1
+ {-0.125,-0.5,-0.375,0.125,0.0625,0.375}, --base2
+ {-0.125,0.25,-0.5,0.125,0.3125,0.375}, --tube
+ {-0.375,-0.5,-0.1875,0.375,0.0625,0.0625}, --base3
+ {-0.125,-0.125,0.375,0.125,0.125,0.5}, --tube2
+ {-0.125,0.0625,0.3125,0.125,0.25,0.375}, --nodebox6
+ {-0.125,0.0625,-0.5,-0.0625,0.25,0.3125}, --nodebox7
+ {0.0625,0.0625,-0.5,0.125,0.25,0.3125}, --nodebox8
+ {-0.0625,0.0625,-0.5,0.0625,0.125,0.3125}, --nodebox9
+ {-0.25,0.3125,-0.125,0.25,0.8,0.375}, --NodeBox10
+ {-0.1875,0.1875,-0.5,-0.125,0.3125,0.375}, --NodeBox11
+ {0.125,0.1875,-0.5,0.1875,0.3125,0.375}, --NodeBox12
+ {-0.125,0.3125,-0.4375,0.125,0.5,-0.125}, --NodeBox13
+ }
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,0.5,0.5},
+ }
+ },
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec",factory.qformspec)
+ meta:set_string("infotext", "Queued Pneumatic Mover")
+ local inv = meta:get_inventory()
+ inv:set_size("main", 8*3)
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("main")
+ end,
+ on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ minetest.log("action", player:get_player_name()..
+ " moves stuff in queued mover at "..minetest.pos_to_string(pos))
+ end,
+ on_metadata_inventory_put = function(pos, listname, index, stack, player)
+ minetest.log("action", player:get_player_name()..
+ " moves stuff to queued mover at "..minetest.pos_to_string(pos))
+ end,
+ on_metadata_inventory_take = function(pos, listname, index, stack, player)
+ minetest.log("action", player:get_player_name()..
+ " takes stuff from queued mover at "..minetest.pos_to_string(pos))
+ end,
+})
+
+minetest.register_abm({
+ nodenames = {"factory:queuedarm"},
+ neighbors = nil,
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local mmeta = minetest.env:get_meta(pos)
+ local minv = mmeta:get_inventory()
+ local all_objects = minetest.get_objects_inside_radius(pos, 0.8)
+ local a = minetest.facedir_to_dir(minetest.get_node(pos).param2)
+ local b = {x = pos.x + a.x, y = pos.y + a.y, z = pos.z + a.z,}
+ local target = minetest.get_node(b)
+ for _,obj in ipairs(all_objects) do
+ if not obj:is_player() and obj:get_luaentity() and obj:get_luaentity().name == "__builtin:item" then
+ local stack = ItemStack(obj:get_luaentity().itemstring)
+ qarm_handle(a, b, target, stack, minv, obj)
+ end
+ end
+ for i,stack in ipairs(minv:get_list("main")) do
+ if stack:get_name() ~= "" then
+ minv:remove_item("main", stack)
+ qarm_handle(a, b, target, stack, minv, nil)
+ return
+ end
+ end
+ end,
+})
+
+minetest.register_node("factory:factory_brick", {
+ description = "Factory Brick",
+ tiles = {"factory_brick.png"},
+ is_ground_content = true,
+ groups = {cracky=3, stone=1}
+}) \ No newline at end of file
diff --git a/factory/settings.txt b/factory/settings.txt
new file mode 100644
index 0000000..bcb7339
--- /dev/null
+++ b/factory/settings.txt
@@ -0,0 +1,14 @@
+-- LemonLake's Factories: Config
+
+-- Logging
+factory.logTaker = true
+
+-- Defines the furnace types for movers and takers.
+-- Requires fuel, src and dst inventory types.
+-- Don't change unless you know what you're doing.
+armDevicesFurnacelike = {"default:furnace", "default:furnace_active", "factory:ind_furnace", "factory:ind_furnace_active", "factory:compressor", "factory:compressor_active"}
+takerDevicesFurnacelike = {"default:furnace", "default:furnace_active", "factory:ind_furnace", "factory:ind_furnace_active", "factory:compressor", "factory:compressor_active"}
+
+-- Fuel types for the generator
+generatorFuel = {{name = "factory:tree_sap", value = 20}}
+-- TODO: Add items for other Technic blocks \ No newline at end of file
diff --git a/factory/textures/factory_belt_bottom.png b/factory/textures/factory_belt_bottom.png
new file mode 100644
index 0000000..42a7fb1
--- /dev/null
+++ b/factory/textures/factory_belt_bottom.png
Binary files differ
diff --git a/factory/textures/factory_belt_side.png b/factory/textures/factory_belt_side.png
new file mode 100644
index 0000000..6d60e06
--- /dev/null
+++ b/factory/textures/factory_belt_side.png
Binary files differ
diff --git a/factory/textures/factory_belt_top.png b/factory/textures/factory_belt_top.png
new file mode 100644
index 0000000..fe55359
--- /dev/null
+++ b/factory/textures/factory_belt_top.png
Binary files differ
diff --git a/factory/textures/factory_belt_top_animation.png b/factory/textures/factory_belt_top_animation.png
new file mode 100644
index 0000000..d703e3b
--- /dev/null
+++ b/factory/textures/factory_belt_top_animation.png
Binary files differ
diff --git a/factory/textures/factory_brick.png b/factory/textures/factory_brick.png
new file mode 100644
index 0000000..3355162
--- /dev/null
+++ b/factory/textures/factory_brick.png
Binary files differ
diff --git a/factory/textures/factory_compressed_clay.png b/factory/textures/factory_compressed_clay.png
new file mode 100644
index 0000000..646bc11
--- /dev/null
+++ b/factory/textures/factory_compressed_clay.png
Binary files differ
diff --git a/factory/textures/factory_compressor_drop_bg.png b/factory/textures/factory_compressor_drop_bg.png
new file mode 100644
index 0000000..f6e9beb
--- /dev/null
+++ b/factory/textures/factory_compressor_drop_bg.png
Binary files differ
diff --git a/factory/textures/factory_compressor_drop_fg.png b/factory/textures/factory_compressor_drop_fg.png
new file mode 100644
index 0000000..dbb9993
--- /dev/null
+++ b/factory/textures/factory_compressor_drop_fg.png
Binary files differ
diff --git a/factory/textures/factory_compressor_front.png b/factory/textures/factory_compressor_front.png
new file mode 100644
index 0000000..1e07f34
--- /dev/null
+++ b/factory/textures/factory_compressor_front.png
Binary files differ
diff --git a/factory/textures/factory_compressor_front_active.png b/factory/textures/factory_compressor_front_active.png
new file mode 100644
index 0000000..2643858
--- /dev/null
+++ b/factory/textures/factory_compressor_front_active.png
Binary files differ
diff --git a/factory/textures/factory_ind_furnace_fire_bg.png b/factory/textures/factory_ind_furnace_fire_bg.png
new file mode 100644
index 0000000..e98a4f6
--- /dev/null
+++ b/factory/textures/factory_ind_furnace_fire_bg.png
Binary files differ
diff --git a/factory/textures/factory_ind_furnace_fire_fg.png b/factory/textures/factory_ind_furnace_fire_fg.png
new file mode 100644
index 0000000..66aab65
--- /dev/null
+++ b/factory/textures/factory_ind_furnace_fire_fg.png
Binary files differ
diff --git a/factory/textures/factory_ind_furnace_front.png b/factory/textures/factory_ind_furnace_front.png
new file mode 100644
index 0000000..a91e792
--- /dev/null
+++ b/factory/textures/factory_ind_furnace_front.png
Binary files differ
diff --git a/factory/textures/factory_ind_furnace_front_active.png b/factory/textures/factory_ind_furnace_front_active.png
new file mode 100644
index 0000000..0d620f6
--- /dev/null
+++ b/factory/textures/factory_ind_furnace_front_active.png
Binary files differ
diff --git a/factory/textures/factory_lump.png b/factory/textures/factory_lump.png
new file mode 100644
index 0000000..38e2f99
--- /dev/null
+++ b/factory/textures/factory_lump.png
Binary files differ
diff --git a/factory/textures/factory_machine_brick_1.png b/factory/textures/factory_machine_brick_1.png
new file mode 100644
index 0000000..b504d60
--- /dev/null
+++ b/factory/textures/factory_machine_brick_1.png
Binary files differ
diff --git a/factory/textures/factory_machine_brick_2.png b/factory/textures/factory_machine_brick_2.png
new file mode 100644
index 0000000..abaa93d
--- /dev/null
+++ b/factory/textures/factory_machine_brick_2.png
Binary files differ
diff --git a/factory/textures/factory_machine_side_1.png b/factory/textures/factory_machine_side_1.png
new file mode 100644
index 0000000..f719d62
--- /dev/null
+++ b/factory/textures/factory_machine_side_1.png
Binary files differ
diff --git a/factory/textures/factory_machine_steel.png b/factory/textures/factory_machine_steel.png
new file mode 100644
index 0000000..ab657e1
--- /dev/null
+++ b/factory/textures/factory_machine_steel.png
Binary files differ
diff --git a/factory/textures/factory_small_diamond_gear.png b/factory/textures/factory_small_diamond_gear.png
new file mode 100644
index 0000000..6fc32cc
--- /dev/null
+++ b/factory/textures/factory_small_diamond_gear.png
Binary files differ
diff --git a/factory/textures/factory_small_gold_gear.png b/factory/textures/factory_small_gold_gear.png
new file mode 100644
index 0000000..6a33e7b
--- /dev/null
+++ b/factory/textures/factory_small_gold_gear.png
Binary files differ
diff --git a/factory/textures/factory_small_steel_gear.png b/factory/textures/factory_small_steel_gear.png
new file mode 100644
index 0000000..a512e00
--- /dev/null
+++ b/factory/textures/factory_small_steel_gear.png
Binary files differ
diff --git a/factory/textures/factory_smoke.png b/factory/textures/factory_smoke.png
new file mode 100644
index 0000000..ea622a8
--- /dev/null
+++ b/factory/textures/factory_smoke.png
Binary files differ
diff --git a/factory/textures/factory_steel_noise.png b/factory/textures/factory_steel_noise.png
new file mode 100644
index 0000000..6ccca44
--- /dev/null
+++ b/factory/textures/factory_steel_noise.png
Binary files differ
diff --git a/factory/textures/factory_steel_noise_diamond.png b/factory/textures/factory_steel_noise_diamond.png
new file mode 100644
index 0000000..0f51263
--- /dev/null
+++ b/factory/textures/factory_steel_noise_diamond.png
Binary files differ
diff --git a/factory/textures/factory_steel_noise_gold.png b/factory/textures/factory_steel_noise_gold.png
new file mode 100644
index 0000000..32295ea
--- /dev/null
+++ b/factory/textures/factory_steel_noise_gold.png
Binary files differ
diff --git a/factory/textures/factory_steel_noise_red.png b/factory/textures/factory_steel_noise_red.png
new file mode 100644
index 0000000..84a4237
--- /dev/null
+++ b/factory/textures/factory_steel_noise_red.png
Binary files differ
diff --git a/factory/textures/factory_tree_sap.png b/factory/textures/factory_tree_sap.png
new file mode 100644
index 0000000..08721b8
--- /dev/null
+++ b/factory/textures/factory_tree_sap.png
Binary files differ
diff --git a/factory/textures/gui_factoryformbg.png b/factory/textures/gui_factoryformbg.png
new file mode 100644
index 0000000..5b2f6f4
--- /dev/null
+++ b/factory/textures/gui_factoryformbg.png
Binary files differ
diff --git a/factory/textures/gui_ind_furnace_arrow_bg.png b/factory/textures/gui_ind_furnace_arrow_bg.png
new file mode 100644
index 0000000..6ffc980
--- /dev/null
+++ b/factory/textures/gui_ind_furnace_arrow_bg.png
Binary files differ
diff --git a/factory/textures/gui_ind_furnace_arrow_fg.png b/factory/textures/gui_ind_furnace_arrow_fg.png
new file mode 100644
index 0000000..3439c35
--- /dev/null
+++ b/factory/textures/gui_ind_furnace_arrow_fg.png
Binary files differ