Added some untracked files
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,107 @@
|
|||
-- Minetest 0.4.5 mod: framedglass
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'framedglass:wooden_framed_glass 4',
|
||||
recipe = {
|
||||
{'default:glass', 'default:glass', 'default:stick'},
|
||||
{'default:glass', 'default:glass', 'default:stick'},
|
||||
{'default:stick', 'default:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'framedglass:steel_framed_glass 4',
|
||||
recipe = {
|
||||
{'default:glass', 'default:glass', 'default:steel_ingot'},
|
||||
{'default:glass', 'default:glass', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'framedglass:wooden_framed_obsidian_glass 4',
|
||||
recipe = {
|
||||
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
|
||||
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
|
||||
{'default:stick', 'default:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'framedglass:steel_framed_obsidian_glass 4',
|
||||
recipe = {
|
||||
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
|
||||
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("framedglass:wooden_framed_glass", {
|
||||
description = "Wooden-framed Glass",
|
||||
drawtype = "glasslike_framed",
|
||||
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_streaks.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("framedglass:steel_framed_glass", {
|
||||
description = "Steel-framed Glass",
|
||||
drawtype = "glasslike_framed",
|
||||
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_streaks.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("framedglass:wooden_framed_obsidian_glass", {
|
||||
description = "Wooden-framed Obsidian Glass",
|
||||
drawtype = "glasslike_framed",
|
||||
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_clean.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("framedglass:steel_framed_obsidian_glass", {
|
||||
description = "Steel-framed Obsidian Glass",
|
||||
drawtype = "glasslike_framed",
|
||||
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_clean.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
function add_coloured_framedglass(name, desc, dye, texture)
|
||||
minetest.register_node( "framedglass:steel_framed_obsidian_glass"..name, {
|
||||
description = "Steel-framed "..desc.." Obsidian Glass",
|
||||
tiles = {"framedglass_steel_frame.png",texture},
|
||||
drawtype = "glasslike_framed",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = true,
|
||||
use_texture_alpha = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
add_coloured_framedglass ("red","Red","","framedglass_redglass.png")
|
||||
add_coloured_framedglass ("green","Green","","framedglass_greenglass.png")
|
||||
add_coloured_framedglass ("blue","Blue","","framedglass_blueglass.png")
|
||||
add_coloured_framedglass ("cyan","Cyan","","framedglass_cyanglass.png")
|
||||
add_coloured_framedglass ("darkgreen","Dark Green","","framedglass_darkgreenglass.png")
|
||||
add_coloured_framedglass ("violet","Violet","","framedglass_violetglass.png")
|
||||
add_coloured_framedglass ("pink","Pink","","framedglass_pinkglass.png")
|
||||
add_coloured_framedglass ("yellow","Yellow","","framedglass_yellowglass.png")
|
||||
add_coloured_framedglass ("orange","Orange","","framedglass_orangeglass.png")
|
||||
add_coloured_framedglass ("brown","Brown","","framedglass_brownglass.png")
|
||||
add_coloured_framedglass ("white","White","","framedglass_whiteglass.png")
|
||||
add_coloured_framedglass ("grey","Grey","","framedglass_greyglass.png")
|
||||
add_coloured_framedglass ("darkgrey","Dark Grey","","framedglass_darkgreyglass.png")
|
||||
add_coloured_framedglass ("black","Black","","framedglass_blackglass.png")
|
||||
|
After Width: | Height: | Size: 346 B |
After Width: | Height: | Size: 432 B |
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 414 B |
After Width: | Height: | Size: 436 B |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 951 B |
After Width: | Height: | Size: 445 B |
After Width: | Height: | Size: 349 B |
After Width: | Height: | Size: 410 B |
After Width: | Height: | Size: 412 B |
After Width: | Height: | Size: 444 B |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 418 B |
After Width: | Height: | Size: 348 B |
After Width: | Height: | Size: 387 B |
After Width: | Height: | Size: 400 B |
After Width: | Height: | Size: 444 B |
After Width: | Height: | Size: 313 B |
|
@ -0,0 +1,85 @@
|
|||
-- Register alloy recipes
|
||||
technic.alloy_recipes = {}
|
||||
|
||||
-- Register recipe in a table
|
||||
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
|
||||
technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft(
|
||||
{
|
||||
type = "alloy",
|
||||
output = result.." "..count3,
|
||||
items = {metal1.." "..count1,metal2.." "..count2},
|
||||
width = 2,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Retrieve a recipe given the input metals.
|
||||
-- Input parameters are a table from a StackItem
|
||||
technic.get_alloy_recipe = function(metal1, metal2)
|
||||
-- Check for both combinations of metals and for the right amount in both
|
||||
if technic.alloy_recipes[metal1.name..metal2.name]
|
||||
and metal1.count >= technic.alloy_recipes[metal1.name..metal2.name].src1_count
|
||||
and metal2.count >= technic.alloy_recipes[metal1.name..metal2.name].src2_count then
|
||||
return technic.alloy_recipes[metal1.name..metal2.name]
|
||||
elseif technic.alloy_recipes[metal2.name..metal1.name]
|
||||
and metal2.count >= technic.alloy_recipes[metal2.name..metal1.name].src1_count
|
||||
and metal1.count >= technic.alloy_recipes[metal2.name..metal1.name].src2_count then
|
||||
return technic.alloy_recipes[metal2.name..metal1.name]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
technic.register_alloy_recipe("technic:copper_dust", 3, "technic:tin_dust", 1, "technic:bronze_dust", 4)
|
||||
technic.register_alloy_recipe("moreores:copper_ingot",3, "moreores:tin_ingot", 1, "moreores:bronze_ingot", 4)
|
||||
technic.register_alloy_recipe("technic:iron_dust", 3, "technic:chromium_dust", 1, "technic:stainless_steel_dust", 4)
|
||||
technic.register_alloy_recipe("default:steel_ingot", 3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
|
||||
technic.register_alloy_recipe("technic:copper_dust", 2, "technic:zinc_dust", 1, "technic:brass_dust", 3)
|
||||
technic.register_alloy_recipe("moreores:copper_ingot",2, "technic:zinc_ingot", 1, "technic:brass_ingot", 3)
|
||||
technic.register_alloy_recipe("default:sand", 2, "technic:coal_dust", 2, "technic:silicon_wafer", 1)
|
||||
technic.register_alloy_recipe("technic:silicon_wafer",1, "technic:gold_dust", 1, "technic:doped_silicon_wafer", 1)
|
||||
|
||||
--------------------------------------
|
||||
-- LEGACY CODE - some other mods might depend on this - Register the same recipes as above...
|
||||
--------------------------------------
|
||||
alloy_recipes = {}
|
||||
registered_recipes_count = 1
|
||||
|
||||
function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
|
||||
alloy_recipes[registered_recipes_count]={}
|
||||
alloy_recipes[registered_recipes_count].src1_name=string1
|
||||
alloy_recipes[registered_recipes_count].src1_count=count1
|
||||
alloy_recipes[registered_recipes_count].src2_name=string2
|
||||
alloy_recipes[registered_recipes_count].src2_count=count2
|
||||
alloy_recipes[registered_recipes_count].dst_name=string3
|
||||
alloy_recipes[registered_recipes_count].dst_count=count3
|
||||
registered_recipes_count=registered_recipes_count+1
|
||||
alloy_recipes[registered_recipes_count]={}
|
||||
alloy_recipes[registered_recipes_count].src1_name=string2
|
||||
alloy_recipes[registered_recipes_count].src1_count=count2
|
||||
alloy_recipes[registered_recipes_count].src2_name=string1
|
||||
alloy_recipes[registered_recipes_count].src2_count=count1
|
||||
alloy_recipes[registered_recipes_count].dst_name=string3
|
||||
alloy_recipes[registered_recipes_count].dst_count=count3
|
||||
registered_recipes_count=registered_recipes_count+1
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "alloy",
|
||||
output = string3.." "..count3,
|
||||
items = {string1.." "..count1,string2.." "..count2},
|
||||
width = 2,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:bronze_dust",4)
|
||||
register_alloy_recipe ("default:copper_ingot",3, "moreores:tin_ingot",1, "default:bronze_ingot",4)
|
||||
register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
|
||||
register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
|
||||
register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
|
||||
register_alloy_recipe ("default:copper_ingot",2, "technic:zinc_ingot",1, "technic:brass_ingot",3)
|
||||
register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
|
||||
register_alloy_recipe ("technic:silicon_wafer",1, "technic:gold_dust",1, "technic:doped_silicon_wafer",1)
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
charge_tools = function(meta, charge, step)
|
||||
--charge registered power tools
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("src")==false then
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src_item=srcstack:to_table()
|
||||
local src_meta=get_item_meta(src_item["metadata"])
|
||||
|
||||
local toolname = src_item["name"]
|
||||
if technic.power_tools[toolname] ~= nil then
|
||||
-- Set meta data for the tool if it didn't do it itself :-(
|
||||
src_meta=get_item_meta(src_item["metadata"])
|
||||
if src_meta==nil then
|
||||
src_meta={}
|
||||
src_meta["technic_power_tool"]=true
|
||||
src_meta["charge"]=0
|
||||
else
|
||||
if src_meta["technic_power_tool"]==nil then
|
||||
src_meta["technic_power_tool"]=true
|
||||
src_meta["charge"]=0
|
||||
end
|
||||
end
|
||||
-- Do the charging
|
||||
local item_max_charge = technic.power_tools[toolname]
|
||||
local load = src_meta["charge"]
|
||||
local load_step = step -- how much to charge per tick
|
||||
if load<item_max_charge and charge>0 then
|
||||
if charge-load_step<0 then load_step=charge end
|
||||
if load+load_step>item_max_charge then load_step=item_max_charge-load end
|
||||
load=load+load_step
|
||||
charge=charge-load_step
|
||||
technic.set_RE_wear(src_item,load,item_max_charge)
|
||||
src_meta["charge"] = load
|
||||
src_item["metadata"] = set_item_meta(src_meta)
|
||||
inv:set_stack("src", 1, src_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
return charge -- return the remaining charge in the battery
|
||||
end
|
||||
|
||||
discharge_tools = function(meta, charge, max_charge, step)
|
||||
-- discharging registered power tools
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") == false then
|
||||
srcstack = inv:get_stack("dst", 1)
|
||||
src_item=srcstack:to_table()
|
||||
local src_meta=get_item_meta(src_item["metadata"])
|
||||
local toolname = src_item["name"]
|
||||
if technic.power_tools[toolname] ~= nil then
|
||||
-- Set meta data for the tool if it didn't do it itself :-(
|
||||
src_meta=get_item_meta(src_item["metadata"])
|
||||
if src_meta==nil then
|
||||
src_meta={}
|
||||
src_meta["technic_power_tool"]=true
|
||||
src_meta["charge"]=0
|
||||
else
|
||||
if src_meta["technic_power_tool"]==nil then
|
||||
src_meta["technic_power_tool"]=true
|
||||
src_meta["charge"]=0
|
||||
end
|
||||
end
|
||||
-- Do the discharging
|
||||
local item_max_charge = technic.power_tools[toolname]
|
||||
local load = src_meta["charge"]
|
||||
local load_step = step -- how much to discharge per tick
|
||||
if load>0 and charge<max_charge then
|
||||
if charge+load_step>max_charge then load_step=max_charge-charge end
|
||||
if load-load_step<0 then load_step=load end
|
||||
load=load-load_step
|
||||
charge=charge+load_step
|
||||
technic.set_RE_wear(src_item,load,item_max_charge)
|
||||
src_meta["charge"]=load
|
||||
src_item["metadata"]=set_item_meta(src_meta)
|
||||
inv:set_stack("dst", 1, src_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
return charge -- return the remaining charge in the battery
|
||||
end
|
|
@ -0,0 +1,55 @@
|
|||
technic.register_grinder_recipe("glooptest:alatro_lump","technic:alatro_dust 2")
|
||||
technic.register_grinder_recipe("glooptest:kalite_lump","technic:kalite_dust 2")
|
||||
technic.register_grinder_recipe("glooptest:arol_lump","technic:arol_dust 2")
|
||||
technic.register_grinder_recipe("glooptest:talinite_lump","technic:talinite_dust 2")
|
||||
technic.register_grinder_recipe("glooptest:akalin_lump","technic:akalin_dust 2")
|
||||
|
||||
minetest.register_craftitem("technic:alatro_dust", {
|
||||
description = "Alatro Dust",
|
||||
inventory_image = "technic_alatro_dust.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "glooptest:alatro_ingot",
|
||||
recipe = "technic:alatro_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:arol_dust", {
|
||||
description = "Arol Dust",
|
||||
inventory_image = "technic_arol_dust.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "glooptest:arol_ingot",
|
||||
recipe = "technic:arol_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:talinite_dust", {
|
||||
description = "Talinite Dust",
|
||||
inventory_image = "technic_talinite_dust.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "glooptest:talinite_ingot",
|
||||
recipe = "technic:talinite_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:akalin_dust", {
|
||||
description = "Akalin Dust",
|
||||
inventory_image = "technic_akalin_dust.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "glooptest:akalin_ingot",
|
||||
recipe = "technic:akalin_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:kalite_dust", {
|
||||
description = "Kalite Dust",
|
||||
inventory_image = "technic_kalite_dust.png",
|
||||
on_use = minetest.item_eat(2)
|
||||
})
|
|
@ -0,0 +1,245 @@
|
|||
-- The enriched uranium rod driven EU generator.
|
||||
-- A very large and advanced machine providing vast amounts of power.
|
||||
-- Very efficient but also expensive to run as it needs uranium. (10000EU 86400 ticks (24h))
|
||||
-- Provides HV EUs that can be down converted as needed.
|
||||
--
|
||||
-- The nuclear reactor core needs water and a protective shield to work.
|
||||
-- This is checked now and then and if the machine is tampered with... BOOM!
|
||||
|
||||
local burn_ticks = 24*60 -- [minutes]. How many minutes does the power plant burn per serving?
|
||||
local power_supply = 10000 -- [HV] EUs
|
||||
local fuel_type = "technic:enriched_uranium" -- The reactor burns this stuff
|
||||
|
||||
|
||||
-- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator?
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_nuclear_reactor_core',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:hv_nuclear_reactor_core",{
|
||||
description = "Uranium Rod Driven HV Reactor",
|
||||
stack_max = 1,
|
||||
})
|
||||
|
||||
local generator_formspec =
|
||||
"invsize[8,9;]"..
|
||||
--"image[0,0;5,5;technic_generator_menu.png]"..
|
||||
"label[0,0;Nuclear Reactor Rod Compartment]"..
|
||||
"list[current_name;src;2,1;3,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
-- "Boxy sphere"
|
||||
local nodebox = {
|
||||
{ -0.353, -0.353, -0.353, 0.353, 0.353, 0.353 }, -- Box
|
||||
{ -0.495, -0.064, -0.064, 0.495, 0.064, 0.064 }, -- Circle +-x
|
||||
{ -0.483, -0.128, -0.128, 0.483, 0.128, 0.128 },
|
||||
{ -0.462, -0.191, -0.191, 0.462, 0.191, 0.191 },
|
||||
{ -0.433, -0.249, -0.249, 0.433, 0.249, 0.249 },
|
||||
{ -0.397, -0.303, -0.303, 0.397, 0.303, 0.303 },
|
||||
{ -0.305, -0.396, -0.305, 0.305, 0.396, 0.305 }, -- Circle +-y
|
||||
{ -0.250, -0.432, -0.250, 0.250, 0.432, 0.250 },
|
||||
{ -0.191, -0.461, -0.191, 0.191, 0.461, 0.191 },
|
||||
{ -0.130, -0.482, -0.130, 0.130, 0.482, 0.130 },
|
||||
{ -0.066, -0.495, -0.066, 0.066, 0.495, 0.066 },
|
||||
{ -0.064, -0.064, -0.495, 0.064, 0.064, 0.495 }, -- Circle +-z
|
||||
{ -0.128, -0.128, -0.483, 0.128, 0.128, 0.483 },
|
||||
{ -0.191, -0.191, -0.462, 0.191, 0.191, 0.462 },
|
||||
{ -0.249, -0.249, -0.433, 0.249, 0.249, 0.433 },
|
||||
{ -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
|
||||
}
|
||||
|
||||
minetest.register_node("technic:hv_nuclear_reactor_core", {
|
||||
description = "Nuclear Reactor",
|
||||
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drawtype="nodebox",
|
||||
paramtype = "light",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("infotext", "Nuclear Reactor Core")
|
||||
meta:set_float("technic_hv_power_machine", 1)
|
||||
meta:set_int("HV_EU_supply", 0)
|
||||
meta:set_int("HV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
|
||||
meta:set_int("burn_time", 0)
|
||||
meta:set_string("formspec", generator_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 6)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
||||
description = "Uranium Rod Driven HV Reactor",
|
||||
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop="technic:hv_nuclear_reactor_core",
|
||||
drawtype="nodebox",
|
||||
light_source = 15,
|
||||
paramtype = "light",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local check_reactor_structure = function(pos)
|
||||
-- The reactor consists of an 11x11x11 cube structure
|
||||
-- A cross section through the middle:
|
||||
-- CCCCC CCCCC
|
||||
-- CCCCC CCCCC
|
||||
-- CCSSS SSSCC
|
||||
-- CCSCC CCSCC
|
||||
-- CCSCWWWCSCC
|
||||
-- CCSCW#WCSCC
|
||||
-- CCSCW|WCSCC
|
||||
-- CCSCC|CCSCC
|
||||
-- CCSSS|SSSCC
|
||||
-- CCCCC|CCCCC
|
||||
-- C = Concrete, S = Stainless Steel, W = water node (not floating), #=reactor core, |=HV cable
|
||||
-- The man-hole and the HV cable is only in the middle
|
||||
-- The man-hole is optional
|
||||
|
||||
local source_water_nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-1, y=pos.y-1, z=pos.z-1},
|
||||
{x=pos.x+1, y=pos.y+1, z=pos.z+1},
|
||||
"default:water_source")
|
||||
local flowing_water_nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-1, y=pos.y-1, z=pos.z-1},
|
||||
{x=pos.x+1, y=pos.y+1, z=pos.z+1},
|
||||
"default:water_flowing")
|
||||
if not ((#source_water_nodes + #flowing_water_nodes) >= 25) then
|
||||
return false
|
||||
end
|
||||
|
||||
local inner_shield_nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-2, y=pos.y-2, z=pos.z-2},
|
||||
{x=pos.x+2, y=pos.y+2, z=pos.z+2},
|
||||
"technic:concrete")
|
||||
if not (#inner_shield_nodes >= 96) then
|
||||
return false
|
||||
end
|
||||
|
||||
local steel_shield_nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-3, y=pos.y-3, z=pos.z-3},
|
||||
{x=pos.x+3, y=pos.y+3, z=pos.z+3},
|
||||
"default:steelblock")
|
||||
if not (#steel_shield_nodes >= 216) then
|
||||
return false
|
||||
end
|
||||
|
||||
local outer_shield_nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-5, y=pos.y-5, z=pos.z-5},
|
||||
{x=pos.x+5, y=pos.y+5, z=pos.z+5},
|
||||
"technic:concrete")
|
||||
if not (#outer_shield_nodes >= (984 + #inner_shield_nodes)) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local explode_reactor = function(pos)
|
||||
print("BOOM A reactor exploded!")
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:hv_nuclear_reactor_core", "technic:hv_nuclear_reactor_core_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local burn_time = meta:get_int("burn_time")
|
||||
|
||||
-- If more to burn and the energy produced was used: produce some more
|
||||
if burn_time > 0 then
|
||||
if not check_reactor_structure(pos) then
|
||||
explode_reactor(pos)
|
||||
end
|
||||
if meta:get_int("HV_EU_supply") == 0 then
|
||||
-- We did not use the power
|
||||
meta:set_int("HV_EU_supply", power_supply)
|
||||
else
|
||||
burn_time = burn_time - 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
local percent = math.floor(burn_time / (burn_ticks * 60) * 100)
|
||||
meta:set_string("infotext", "Nuclear Reactor Core ("..percent.."%)")
|
||||
end
|
||||
end
|
||||
|
||||
-- Burn another piece of coal
|
||||
if burn_time <= 0 then
|
||||
local inv = meta:get_inventory()
|
||||
local correct_fuel_count = 0
|
||||
if not inv:is_empty("src") then
|
||||
local srclist = inv:get_list("src")
|
||||
for _, srcstack in pairs(srclist) do
|
||||
if srcstack then
|
||||
local src_item=srcstack:to_table()
|
||||
if src_item and src_item["name"] == fuel_type then
|
||||
correct_fuel_count = correct_fuel_count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Check that the reactor is complete as well as the correct number of correct fuel
|
||||
if correct_fuel_count == 6 then
|
||||
if not check_reactor_structure(pos) then
|
||||
burn_time = burn_ticks * 60
|
||||
meta:set_int("burn_time", burn_time)
|
||||
hacky_swap_node (pos,"technic:hv_nuclear_reactor_core_active")
|
||||
meta:set_int("HV_EU_supply", power_supply)
|
||||
for idx, srcstack in pairs(srclist) do
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", idx, srcstack)
|
||||
end
|
||||
end
|
||||
else
|
||||
meta:set_int("HV_EU_supply", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Nothing left to burn
|
||||
if burn_time == 0 then
|
||||
meta:set_string("infotext", "Nuclear Reactor Core (idle)")
|
||||
hacky_swap_node(pos,"technic:hv_nuclear_reactor_core")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_HV_machine ("technic:hv_nuclear_reactor_core","PR")
|
||||
technic.register_HV_machine ("technic:hv_nuclear_reactor_core_active","PR")
|
|
@ -0,0 +1,398 @@
|
|||
--HV cable node boxes
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_cable 3',
|
||||
recipe ={
|
||||
{'technic:rubber','technic:rubber','technic:rubber'},
|
||||
{'technic:mv_cable','technic:mv_cable','technic:mv_cable'},
|
||||
{'technic:rubber','technic:rubber','technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("technic:hv_cable", {
|
||||
description = "Gigh Voltage Copper Cable",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:hv_cable", {
|
||||
description = "High Voltage Copper Cable",
|
||||
tiles = {"technic_hv_cable.png"},
|
||||
inventory_image = "technic_hv_cable_wield.png",
|
||||
wield_image = "technic_hv_cable_wield.png",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:hv_cable",
|
||||
hv_cablelike=1,
|
||||
rules_x1=0,
|
||||
rules_x2=0,
|
||||
rules_y1=0,
|
||||
rules_y2=0,
|
||||
rules_z1=0,
|
||||
rules_z2=0,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.125 , -0.125 , -0.125 , 0.125 , 0.125 , 0.125 },
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
meta:set_float("hv_cablelike",1)
|
||||
meta:set_float("x1",0)
|
||||
meta:set_float("x2",0)
|
||||
meta:set_float("y1",0)
|
||||
meta:set_float("y2",0)
|
||||
meta:set_float("z1",0)
|
||||
meta:set_float("z2",0)
|
||||
HV_check_connections (pos)
|
||||
end,
|
||||
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
HV_check_connections_on_destroy (pos)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
|
||||
str_y1= { -0.125 , -0.125 , -0.125 , 0.125 , 0.5, 0.125 } --0 y+
|
||||
str_x1= { -0.125 , -0.125 , -0.125 , 0.5, 0.125 , 0.125 } --0 x+
|
||||
str_z1= { -0.125 , -0.125 , 0.125 , 0.125 , 0.125 , 0.5 } --0 z+
|
||||
str_z2= { -0.125 , -0.125, -0.5 , 0.125 , 0.125 , 0.125 } --0 z-
|
||||
str_y2= { -0.125 , -0.5, -0.125 , 0.125 , 0.125 , 0.125 } --0 y-
|
||||
str_x2= { -0.5 , -0.125, -0.125 , 0.125 , 0.125 , 0.125 } --0 x-
|
||||
|
||||
|
||||
|
||||
local x1,x2,y1,y2,z1,z2
|
||||
local count=0
|
||||
|
||||
for x1 = 0, 1, 1 do --x-
|
||||
for x2 = 0, 1, 1 do --x+
|
||||
for y1 = 0, 1, 1 do --y-
|
||||
for y2 = 0, 1, 1 do --y-
|
||||
for z1 = 0, 1, 1 do --z-
|
||||
for z2 = 0, 1, 1 do --z+
|
||||
|
||||
temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
|
||||
|
||||
if x1==1 then temp_x1=str_x1 end
|
||||
if x2==1 then temp_x2=str_x2 end
|
||||
if y1==1 then temp_y1=str_y1 end
|
||||
if y2==1 then temp_y2=str_y2 end
|
||||
if z1==1 then temp_z1=str_z1 end
|
||||
if z2==1 then temp_z2=str_z2 end
|
||||
|
||||
|
||||
minetest.register_node("technic:hv_cable"..count, {
|
||||
description = "High Voltage Copper Cable",
|
||||
tiles = {"technic_hv_cable.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:hv_cable",
|
||||
rules_x1=0,
|
||||
rules_x2=0,
|
||||
rules_y1=0,
|
||||
rules_y2=0,
|
||||
rules_z1=0,
|
||||
rules_z2=0,
|
||||
cablelike=1,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
|
||||
}},
|
||||
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
|
||||
}},
|
||||
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
HV_check_connections_on_destroy (pos)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
count=count+1 end end end end end end
|
||||
|
||||
HV_check_connections = function(pos)
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
x2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x2",x2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
x1=1
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("x1",x1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x-2
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
x1=1
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x1",x1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
x2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("x2",x2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
y2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y2",y2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("y1",y1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
end
|
||||
|
||||
if minetest.env:get_meta(pos1):get_float("technic_hv_power_machine")==1 then
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
meta:set_float("y1",y1)
|
||||
end
|
||||
|
||||
|
||||
pos1.y=pos1.y-2
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y1",y1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
y2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("y2",y2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
z2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z2",z2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
z1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("z1",z1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
end
|
||||
pos1.z=pos1.z-2
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
z1=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:hv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z1",z1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
z2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
meta:set_float("z2",z2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:hv_cable"..rule)
|
||||
end
|
||||
pos1.z=pos1.z+1
|
||||
end
|
||||
|
||||
|
||||
HV_check_connections_on_destroy = function(pos)
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
x2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x2",x2)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x-2
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
x1=0
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x1",x1)
|
||||
end
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
y2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y2",y2)
|
||||
end
|
||||
|
||||
pos1.y=pos1.y-2
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
y1=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y1",y1)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
z2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z2",z2)
|
||||
end
|
||||
|
||||
pos1.z=pos1.z-2
|
||||
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
|
||||
z1=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z1",z1)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
local path = technic.modpath.."/machines/lv"
|
||||
|
||||
dofile(path.."/wires.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/solar_panel.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/geothermal.lua")
|
||||
dofile(path.."/water_mill.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
dofile(path.."/music_player.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/cnc.lua")
|
||||
dofile(path.."/cnc_api.lua")
|
||||
dofile(path.."/cnc_nodes.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
|
@ -0,0 +1,122 @@
|
|||
-- LV Tool workshop
|
||||
-- This machine repairs tools.
|
||||
minetest.register_alias("tool_workshop", "technic:tool_workshop")
|
||||
minetest.register_craft({
|
||||
output = 'technic:tool_workshop',
|
||||
recipe = {
|
||||
{'default:wood', 'default:wood', 'default:wood'},
|
||||
{'default:wood', 'default:diamond', 'default:wood'},
|
||||
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:tool_workshop", {
|
||||
description = "Tool Workshop",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
local workshop_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"label[0,0;Tool Workshop]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
minetest.register_node(
|
||||
"technic:tool_workshop",
|
||||
{
|
||||
description = "Tool Workshop",
|
||||
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
|
||||
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("infotext", "Tool Workshop")
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", workshop_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{ nodenames = {"technic:tool_workshop"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
local state = meta:get_int("state")
|
||||
local next_state = state
|
||||
|
||||
-- Machine information
|
||||
local machine_name = "Tool Workshop"
|
||||
local machine_node = "technic:tool_workshop"
|
||||
local machine_state_demand = { 50, 150 }
|
||||
|
||||
-- Setup meta data if it does not exist. state is used as an indicator of this
|
||||
if state == 0 then
|
||||
meta:set_int("state", 1)
|
||||
meta:set_int("LV_EU_demand", machine_state_demand[1])
|
||||
meta:set_int("LV_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "LV")
|
||||
|
||||
-- State machine
|
||||
if eu_input == 0 then
|
||||
-- Unpowered - go idle
|
||||
--hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", machine_name.." Unpowered")
|
||||
next_state = 1
|
||||
elseif eu_input == machine_state_demand[state] then
|
||||
-- Powered - do the state specific actions
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if state == 1 then
|
||||
--hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", machine_name.." Idle")
|
||||
if not inv:is_empty("src") then
|
||||
next_state = 2
|
||||
end
|
||||
elseif state == 2 then
|
||||
--hacky_swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", machine_name.." Active")
|
||||
|
||||
if inv:is_empty("src") then
|
||||
next_state = 1
|
||||
else
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
src_item=srcstack:to_table()
|
||||
-- Cannot charge cans
|
||||
if (src_item["name"]=="technic:water_can" or src_item["name"]=="technic:lava_can") then
|
||||
return
|
||||
end
|
||||
local wear=tonumber(src_item["wear"])
|
||||
wear = math.max(1, wear-2000) -- Improve the tool this much every tick
|
||||
src_item["wear"]=tostring(wear)
|
||||
inv:set_stack("src", 1, src_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Change state?
|
||||
if next_state ~= state then
|
||||
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
|
||||
meta:set_int("state", next_state)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_LV_machine ("technic:tool_workshop","RE")
|
||||
|
|
@ -0,0 +1,401 @@
|
|||
--LV cable node boxes
|
||||
|
||||
|
||||
minetest.register_alias("lv_cable", "technic:lv_cable")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:lv_cable 6',
|
||||
recipe = {
|
||||
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:lv_cable", {
|
||||
description = "Low Voltage Copper Cable",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:lv_cable", {
|
||||
description = "Low Voltage Copper Cable",
|
||||
tiles = {"technic_lv_cable.png"},
|
||||
inventory_image = "technic_lv_cable_wield.png",
|
||||
wield_image = "technic_lv_cable_wield.png",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:lv_cable",
|
||||
cablelike=1,
|
||||
rules_x1=0,
|
||||
rules_x2=0,
|
||||
rules_y1=0,
|
||||
rules_y2=0,
|
||||
rules_z1=0,
|
||||
rules_z2=0,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
meta:set_float("cablelike",1)
|
||||
meta:set_float("x1",0)
|
||||
meta:set_float("x2",0)
|
||||
meta:set_float("y1",0)
|
||||
meta:set_float("y2",0)
|
||||
meta:set_float("z1",0)
|
||||
meta:set_float("z2",0)
|
||||
check_connections (pos)
|
||||
end,
|
||||
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
check_connections_on_destroy (pos)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
|
||||
str_y1= { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1 } --0 y+
|
||||
str_x1= { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1 } --0 x+
|
||||
str_z1= { -0.1 , -0.1 , 0.1 , 0.1 , 0.1 , 0.5 } --0 z+
|
||||
str_z2= { -0.1 , -0.1, -0.5 , 0.1 , 0.1 , 0.1 } --0 z-
|
||||
str_y2= { -0.1 , -0.5, -0.1 , 0.1 , 0.1 , 0.1 } --0 y-
|
||||
str_x2= { -0.5 , -0.1, -0.1 , 0.1 , 0.1 , 0.1 } --0 x-
|
||||
|
||||
|
||||
|
||||
local x1,x2,y1,y2,z1,z2
|
||||
local count=0
|
||||
|
||||
for x1 = 0, 1, 1 do --x-
|
||||
for x2 = 0, 1, 1 do --x+
|
||||
for y1 = 0, 1, 1 do --y-
|
||||
for y2 = 0, 1, 1 do --y-
|
||||
for z1 = 0, 1, 1 do --z-
|
||||
for z2 = 0, 1, 1 do --z+
|
||||
|
||||
temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
|
||||
|
||||
if x1==1 then temp_x1=str_x1 end
|
||||
if x2==1 then temp_x2=str_x2 end
|
||||
if y1==1 then temp_y1=str_y1 end
|
||||
if y2==1 then temp_y2=str_y2 end
|
||||
if z1==1 then temp_z1=str_z1 end
|
||||
if z2==1 then temp_z2=str_z2 end
|
||||
|
||||
|
||||
minetest.register_node("technic:lv_cable"..count, {
|
||||
description = "Low Voltage Copper Cable",
|
||||
tiles = {"technic_lv_cable.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:lv_cable",
|
||||
rules_x1=0,
|
||||
rules_x2=0,
|
||||
rules_y1=0,
|
||||
rules_y2=0,
|
||||
rules_z1=0,
|
||||
rules_z2=0,
|
||||
cablelike=1,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
|
||||
}},
|
||||
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
|
||||
}},
|
||||
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
check_connections_on_destroy (pos)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
count=count+1 end end end end end end
|
||||
|
||||
check_connections = function(pos)
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
x2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x2",x2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
x1=1
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("x1",x1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x-2
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
x1=1
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x1",x1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
x2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("x2",x2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
y2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y2",y2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("y1",y1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
end
|
||||
|
||||
if minetest.env:get_meta(pos1):get_float("technic_power_machine")==1 then
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
meta:set_float("y1",y1)
|
||||
end
|
||||
|
||||
|
||||
pos1.y=pos1.y-2
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y1",y1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
y2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("y2",y2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
z2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z2",z2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
z1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("z1",z1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
end
|
||||
pos1.z=pos1.z-2
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
z1=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:lv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z1",z1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
z2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
meta:set_float("z2",z2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:lv_cable"..rule)
|
||||
end
|
||||
pos1.z=pos1.z+1
|
||||
end
|
||||
|
||||
function make_rule_number (x1,x2,y1,y2,z1,z2)
|
||||
local temp= z2+z1*2+y2*4+y1*8+x2*16+x1*32
|
||||
return temp
|
||||
end
|
||||
|
||||
check_connections_on_destroy = function(pos)
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
x2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x2",x2)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x-2
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
x1=0
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x1",x1)
|
||||
end
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
y2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y2",y2)
|
||||
end
|
||||
|
||||
pos1.y=pos1.y-2
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
y1=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y1",y1)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
z2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z2",z2)
|
||||
end
|
||||
|
||||
pos1.z=pos1.z-2
|
||||
if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
|
||||
z1=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z1",z1)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
local path = technic.modpath.."/machines/mv"
|
||||
|
||||
dofile(path.."/wires.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
|
||||
-- The power radiator supplies appliances with inductive coupled power:
|
||||
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||
dofile(path.."/power_radiator.lua")
|
||||
dofile(path.."/lighting.lua")
|
||||
|
|
@ -0,0 +1,590 @@
|
|||
-- NOTE: The code is takes directly from VanessaE's homedecor mod.
|
||||
-- I just made it the lights into indictive appliances for this mod.
|
||||
|
||||
-- This file supplies electric powered glowlights
|
||||
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
local S
|
||||
if (minetest.get_modpath("intllib")) then
|
||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
||||
S = intllib.Getter(minetest.get_current_modname())
|
||||
else
|
||||
S = function ( s ) return s end
|
||||
end
|
||||
|
||||
function technic_homedecor_node_is_owned(pos, placer)
|
||||
local ownername = false
|
||||
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
||||
if HasOwner(pos, placer) then -- returns true if the node is owned
|
||||
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
|
||||
if type(getLastOwner) == "function" then -- ...is an old version
|
||||
ownername = getLastOwner(pos)
|
||||
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
||||
ownername = GetNodeOwnerName(pos)
|
||||
else
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif type(isprotect)=="function" then -- glomie's protection mod
|
||||
if not isprotect(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
|
||||
if not protector.can_dig(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
|
||||
if ownername ~= false then
|
||||
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local dirs1 = { 20, 23, 22, 21 }
|
||||
local dirs2 = { 9, 18, 7, 12 }
|
||||
|
||||
local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_thing)
|
||||
if not technic_homedecor_node_is_owned(pointed_thing.under, placer)
|
||||
and not technic_homedecor_node_is_owned(pointed_thing.above, placer) then
|
||||
local node = minetest.env:get_node(pointed_thing.under)
|
||||
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
|
||||
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
local pitch = placer:get_look_pitch()
|
||||
local pname = minetest.env:get_node(under).name
|
||||
local node = minetest.env:get_node(above)
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local wield_name = itemstack:get_name()
|
||||
|
||||
if not minetest.registered_nodes[pname]
|
||||
or not minetest.registered_nodes[pname].on_rightclick then
|
||||
|
||||
local iswall = (above.x ~= under.x) or (above.z ~= under.z)
|
||||
local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||
local pos1 = above
|
||||
|
||||
if minetest.registered_nodes[pname]["buildable_to"] then
|
||||
pos1 = under
|
||||
iswall = false
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
|
||||
|
||||
if iswall then
|
||||
minetest.env:add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
|
||||
elseif isceiling then
|
||||
minetest.env:add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
|
||||
else
|
||||
minetest.env:add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
|
||||
end
|
||||
|
||||
if not homedecor_expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
else
|
||||
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Yellow -- Half node
|
||||
minetest.register_node('technic:homedecor_glowlight_half_yellow', {
|
||||
description = S("Yellow Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_yellow_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_half_yellow_active', {
|
||||
description = S("Yellow Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = LIGHT_MAX,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_half_yellow",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_yellow")
|
||||
end
|
||||
})
|
||||
|
||||
-- Yellow -- Quarter node
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_yellow', {
|
||||
description = S("Yellow Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_yellow_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_yellow_active', {
|
||||
description = S("Yellow Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_quarter_yellow",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_yellow")
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- White -- half node
|
||||
minetest.register_node('technic:homedecor_glowlight_half_white', {
|
||||
description = S("White Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_white_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_half_white_active', {
|
||||
description = S("White Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = LIGHT_MAX,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_half_white",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_white")
|
||||
end
|
||||
})
|
||||
|
||||
-- White -- Quarter node
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_white', {
|
||||
description = S("White Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_white_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_white_active', {
|
||||
description = S("White Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_quarter_white",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_white")
|
||||
end
|
||||
})
|
||||
|
||||
-- Glowlight "cubes" - yellow
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_yellow', {
|
||||
description = S("Yellow Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_yellow_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_yellow_active', {
|
||||
description = S("Yellow Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_small_cube_yellow",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_yellow")
|
||||
end
|
||||
})
|
||||
|
||||
-- Glowlight "cubes" - white
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_white', {
|
||||
description = S("White Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_white_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_white_active', {
|
||||
description = S("White Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_small_cube_white",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_white")
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_half_yellow")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_half_white")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_quarter_yellow")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_quarter_white")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_yellow")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_white")
|
|
@ -0,0 +1,400 @@
|
|||
--MV cable node boxes
|
||||
|
||||
|
||||
minetest.register_alias("mv_cable", "technic:mv_cable")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_cable 3',
|
||||
recipe ={
|
||||
{'technic:rubber','technic:rubber','technic:rubber'},
|
||||
{'technic:lv_cable','technic:lv_cable','technic:lv_cable'},
|
||||
{'technic:rubber','technic:rubber','technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("technic:mv_cable", {
|
||||
description = "Medium Voltage Copper Cable",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:mv_cable", {
|
||||
description = "Medium Voltage Copper Cable",
|
||||
tiles = {"technic_mv_cable.png"},
|
||||
inventory_image = "technic_mv_cable_wield.png",
|
||||
wield_image = "technic_mv_cable_wield.png",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:mv_cable",
|
||||
mv_cablelike=1,
|
||||
rules_x1=0,
|
||||
rules_x2=0,
|
||||
rules_y1=0,
|
||||
rules_y2=0,
|
||||
rules_z1=0,
|
||||
rules_z2=0,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
meta:set_float("mv_cablelike",1)
|
||||
meta:set_float("x1",0)
|
||||
meta:set_float("x2",0)
|
||||
meta:set_float("y1",0)
|
||||
meta:set_float("y2",0)
|
||||
meta:set_float("z1",0)
|
||||
meta:set_float("z2",0)
|
||||
MV_check_connections (pos)
|
||||
end,
|
||||
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
MV_check_connections_on_destroy (pos)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
|
||||
str_y1= { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1 } --0 y+
|
||||
str_x1= { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1 } --0 x+
|
||||
str_z1= { -0.1 , -0.1 , 0.1 , 0.1 , 0.1 , 0.5 } --0 z+
|
||||
str_z2= { -0.1 , -0.1, -0.5 , 0.1 , 0.1 , 0.1 } --0 z-
|
||||
str_y2= { -0.1 , -0.5, -0.1 , 0.1 , 0.1 , 0.1 } --0 y-
|
||||
str_x2= { -0.5 , -0.1, -0.1 , 0.1 , 0.1 , 0.1 } --0 x-
|
||||
|
||||
|
||||
|
||||
local x1,x2,y1,y2,z1,z2
|
||||
local count=0
|
||||
|
||||
for x1 = 0, 1, 1 do --x-
|
||||
for x2 = 0, 1, 1 do --x+
|
||||
for y1 = 0, 1, 1 do --y-
|
||||
for y2 = 0, 1, 1 do --y-
|
||||
for z1 = 0, 1, 1 do --z-
|
||||
for z2 = 0, 1, 1 do --z+
|
||||
|
||||
temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
|
||||
|
||||
if x1==1 then temp_x1=str_x1 end
|
||||
if x2==1 then temp_x2=str_x2 end
|
||||
if y1==1 then temp_y1=str_y1 end
|
||||
if y2==1 then temp_y2=str_y2 end
|
||||
if z1==1 then temp_z1=str_z1 end
|
||||
if z2==1 then temp_z2=str_z2 end
|
||||
|
||||
|
||||
minetest.register_node("technic:mv_cable"..count, {
|
||||
description = "Medium Voltage Copper Cable",
|
||||
tiles = {"technic_mv_cable.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:mv_cable",
|
||||
rules_x1=0,
|
||||
rules_x2=0,
|
||||
rules_y1=0,
|
||||
rules_y2=0,
|
||||
rules_z1=0,
|
||||
rules_z2=0,
|
||||
cablelike=1,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
|
||||
}},
|
||||
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
|
||||
}},
|
||||
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
MV_check_connections_on_destroy (pos)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
count=count+1 end end end end end end
|
||||
|
||||
MV_check_connections = function(pos)
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
x2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x2",x2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
x1=1
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("x1",x1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x-2
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
x1=1
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x1",x1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
x2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("x2",x2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
y2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y2",y2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("y1",y1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
end
|
||||
|
||||
if minetest.env:get_meta(pos1):get_float("technic_mv_power_machine")==1 then
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
meta:set_float("y1",y1)
|
||||
end
|
||||
|
||||
|
||||
pos1.y=pos1.y-2
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
y1=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y1",y1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
y2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("y2",y2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
z2=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z2",z2)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
z1=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos):get_float("z2")
|
||||
meta:set_float("z1",z1)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
end
|
||||
pos1.z=pos1.z-2
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
z1=1
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos1,"technic:mv_cable"..rule)
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z1",z1)
|
||||
meta=minetest.env:get_meta(pos)
|
||||
z2=1
|
||||
x1=minetest.env:get_meta(pos):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos):get_float("z1")
|
||||
meta:set_float("z2",z2)
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
hacky_swap_node(pos,"technic:mv_cable"..rule)
|
||||
end
|
||||
pos1.z=pos1.z+1
|
||||
end
|
||||
|
||||
|
||||
MV_check_connections_on_destroy = function(pos)
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
x2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x2",x2)
|
||||
end
|
||||
|
||||
pos1.x=pos1.x-2
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
x1=0
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("x1",x1)
|
||||
end
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
y2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y2",y2)
|
||||
end
|
||||
|
||||
pos1.y=pos1.y-2
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
y1=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("y1",y1)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
z2=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z1=minetest.env:get_meta(pos1):get_float("z1")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z2",z2)
|
||||
end
|
||||
|
||||
pos1.z=pos1.z-2
|
||||
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
|
||||
z1=0
|
||||
x1=minetest.env:get_meta(pos1):get_float("x1")
|
||||
x2=minetest.env:get_meta(pos1):get_float("x2")
|
||||
y1=minetest.env:get_meta(pos1):get_float("y1")
|
||||
y2=minetest.env:get_meta(pos1):get_float("y2")
|
||||
z2=minetest.env:get_meta(pos1):get_float("z2")
|
||||
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
|
||||
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
|
||||
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
|
||||
meta=minetest.env:get_meta(pos1)
|
||||
meta:set_float("z1",z1)
|
||||
end
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
-- This file includes the functions and data structures for registering machines and tools for LV, MV, HV types.
|
||||
-- We use the technic namespace for these functions and data to avoid eventual conflict.
|
||||
|
||||
-- register power tools here
|
||||
technic.power_tools = {}
|
||||
technic.register_power_tool = function(craftitem,max_charge)
|
||||
technic.power_tools[craftitem] = max_charge
|
||||
end
|
||||
|
||||
-- register LV machines here
|
||||
technic.LV_machines = {}
|
||||
|
||||
technic.register_LV_machine = function(nodename,type)
|
||||
technic.LV_machines[nodename] = type
|
||||
end
|
||||
|
||||
technic.unregister_LV_machine = function(nodename,type)
|
||||
technic.LV_machines[nodename] = nil
|
||||
end
|
||||
|
||||
-- register MV machines here
|
||||
technic.MV_machines = {}
|
||||
technic.MV_power_tools = {}
|
||||
technic.register_MV_machine = function(nodename,type)
|
||||
technic.MV_machines[nodename] = type
|
||||
end
|
||||
|
||||
technic.unregister_MV_machine = function(nodename)
|
||||
technic.MV_machines[nodename] = nil
|
||||
end
|
||||
|
||||
-- register HV machines here
|
||||
technic.HV_machines = {}
|
||||
technic.HV_power_tools = {}
|
||||
technic.register_HV_machine = function(nodename,type)
|
||||
technic.HV_machines[nodename] = type
|
||||
end
|
||||
|
||||
technic.unregister_HV_machine = function(nodename)
|
||||
technic.HV_machines[nodename] = nil
|
||||
end
|
||||
|
||||
-- Utility functions. Not sure exactly what they do.. water.lua uses the two first.
|
||||
function technic.get_RE_item_load (load1,max_load)
|
||||
if load1==0 then load1=65535 end
|
||||
local temp = 65536-load1
|
||||
temp= temp/65535*max_load
|
||||
return math.floor(temp + 0.5)
|
||||
end
|
||||
|
||||
function technic.set_RE_item_load (load1,max_load)
|
||||
if load1 == 0 then return 65535 end
|
||||
local temp=load1/max_load*65535
|
||||
temp=65536-temp
|
||||
return math.floor(temp)
|
||||
end
|
||||
|
||||
-- Wear down a tool depending on the remaining charge.
|
||||
function technic.set_RE_wear (item_stack,load,max_load)
|
||||
local temp=65536-math.floor(load/max_load*65535)
|
||||
item_stack["wear"]=tostring(temp)
|
||||
return item_stack
|
||||
end
|
|
@ -0,0 +1,123 @@
|
|||
-- Code of rubber tree by PilzAdam
|
||||
|
||||
minetest.register_node("technic:rubber_sapling", {
|
||||
description = "Rubber Tree Sapling",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"technic_rubber_sapling.png"},
|
||||
inventory_image = "technic_rubber_sapling.png",
|
||||
wield_image = "technic_rubber_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("technic:rubber_tree_full", {
|
||||
description = "Rubber Tree",
|
||||
tiles = {"default_tree_top.png", "default_tree_top.png", "technic_rubber_tree_full.png"},
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
drop = "default:tree",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
on_dig = function(pos, node, digger)
|
||||
minetest.node_dig(pos, node, digger)
|
||||
minetest.env:remove_node(pos)
|
||||
end,
|
||||
|
||||
after_destruct = function(pos, oldnode)
|
||||
oldnode.name = "technic:rubber_tree_empty"
|
||||
minetest.env:set_node(pos, oldnode)
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("technic:rubber_tree_empty", {
|
||||
tiles = {"default_tree_top.png", "default_tree_top.png", "technic_rubber_tree_empty.png"},
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2, not_in_creative_inventory=1},
|
||||
drop = "default:tree",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:rubber_tree_empty"},
|
||||
interval = 60,
|
||||
chance = 15,
|
||||
action = function(pos, node)
|
||||
node.name = "technic:rubber_tree_full"
|
||||
minetest.env:set_node(pos, node)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("technic:rubber_leaves", {
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = {"technic_rubber_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'technic:rubber_sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:rubber_sapling"},
|
||||
interval = 60,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
rubber_tree={
|
||||
axiom="FFFFA",
|
||||
rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]",
|
||||
rules_b="[&FFA]////[&FFA]////[&FFA]",
|
||||
trunk="technic:rubber_tree_full",
|
||||
leaves="technic:rubber_leaves",
|
||||
angle=35,
|
||||
iterations=3,
|
||||
random_level=1,
|
||||
thin_trunks=false;
|
||||
fruit_tree=false,
|
||||
fruit=""
|
||||
}
|
||||
minetest.env:spawn_tree(pos,rubber_tree)
|
||||
end
|
||||
})
|
||||
|
||||
if technic.config:getBool("enable_rubber_tree_generation") then
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
if math.random(1, 100) > 5 then
|
||||
return
|
||||
end
|
||||
local rubber_tree={
|
||||
axiom="FFFFA",
|
||||
rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]",
|
||||
rules_b="[&FFA]////[&FFA]////[&FFA]",
|
||||
trunk="technic:rubber_tree_full",
|
||||
leaves="technic:rubber_leaves",
|
||||
angle=35,
|
||||
iterations=3,
|
||||
random_level=1,
|
||||
thin_trunks=false;
|
||||
fruit_tree=false,
|
||||
fruit=""
|
||||
}
|
||||
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
|
||||
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
|
||||
if pos ~= nil then
|
||||
minetest.env:spawn_tree({x=pos.x, y=pos.y+1, z=pos.z}, rubber_tree)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
-- ========= FUEL =========
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "technic:rubber_sapling",
|
||||
burntime = 10
|
||||
})
|
After Width: | Height: | Size: 508 B |
After Width: | Height: | Size: 543 B |
After Width: | Height: | Size: 313 B |
After Width: | Height: | Size: 397 B |
After Width: | Height: | Size: 738 B |
After Width: | Height: | Size: 594 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 423 B |
After Width: | Height: | Size: 443 B |
After Width: | Height: | Size: 448 B |
After Width: | Height: | Size: 399 B |
After Width: | Height: | Size: 393 B |
After Width: | Height: | Size: 777 B |
After Width: | Height: | Size: 587 B |
|
@ -0,0 +1,664 @@
|
|||
--data tables definitions
|
||||
unified_inventory = {}
|
||||
unified_inventory.players = {}
|
||||
unified_inventory.current_page = {}
|
||||
unified_inventory.current_index = {}
|
||||
unified_inventory.items_list_size = 0
|
||||
unified_inventory.items_list = {}
|
||||
unified_inventory.filtered_items_list_size = {}
|
||||
unified_inventory.filtered_items_list = {}
|
||||
unified_inventory.activefilter = {}
|
||||
unified_inventory.alternate = {}
|
||||
unified_inventory.current_item = {}
|
||||
unified_inventory.crafts_table ={}
|
||||
unified_inventory.crafts_table_count=0
|
||||
|
||||
-- default inventory page
|
||||
unified_inventory.default = "craft"
|
||||
|
||||
-- homepos stuff
|
||||
local home_gui = {}
|
||||
local homepos = {}
|
||||
unified_inventory.home_filename = minetest.get_worldpath()..'/unified_inventory_home'
|
||||
|
||||
-- Create detached creative inventory after loading all mods
|
||||
-- Also 2nd attempt to disable default creative mod
|
||||
minetest.after(0.01, function()
|
||||
|
||||
if creative_inventory then
|
||||
creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
unified_inventory.items_list = {}
|
||||
for name,def in pairs(minetest.registered_items) do
|
||||
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
|
||||
and def.description and def.description ~= "" then
|
||||
table.insert(unified_inventory.items_list, name)
|
||||
local recipes=minetest.get_all_craft_recipes(name)
|
||||
if unified_inventory.crafts_table[name]==nil then
|
||||
unified_inventory.crafts_table[name] = {}
|
||||
end
|
||||
if recipes then
|
||||
for i=1,#recipes,1 do
|
||||
table.insert(unified_inventory.crafts_table[name],recipes[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--print(dump(unified_inventory.crafts_table))
|
||||
table.sort(unified_inventory.items_list)
|
||||
unified_inventory.items_list_size = #unified_inventory.items_list
|
||||
print ("Unified Inventory. inventory size: "..unified_inventory.items_list_size)
|
||||
end)
|
||||
|
||||
-- register_on_joinplayer
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
unified_inventory.players[player_name]={}
|
||||
unified_inventory.current_index[player_name] = 1
|
||||
unified_inventory.filtered_items_list[player_name] = {}
|
||||
unified_inventory.filtered_items_list[player_name] = unified_inventory.items_list
|
||||
unified_inventory.filtered_items_list_size[player_name]=unified_inventory.items_list_size
|
||||
unified_inventory.activefilter[player_name]=""
|
||||
unified_inventory.apply_filter(player, "")
|
||||
unified_inventory.alternate[player_name] = 1
|
||||
unified_inventory.current_item[player_name] =nil
|
||||
unified_inventory.set_inventory_formspec(player,unified_inventory.get_formspec(player, unified_inventory.default))
|
||||
|
||||
--crafting guide inventories
|
||||
local inv = minetest.create_detached_inventory(player:get_player_name().."craftrecipe",{
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
return 0
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
inv:set_size("output", 1)
|
||||
inv:set_size("build", 3*3)
|
||||
|
||||
-- refill slot
|
||||
unified_inventory.refill = minetest.create_detached_inventory(player_name.."refill", {
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
inv:set_stack(listname, index, ItemStack(stack:get_name().." "..stack:get_stack_max()))
|
||||
minetest.sound_play("electricity", {to_player=player_name, gain = 1.0})
|
||||
end,
|
||||
})
|
||||
unified_inventory.refill:set_size("main", 1)
|
||||
|
||||
-- trash slot
|
||||
unified_inventory.trash = minetest.create_detached_inventory("trash", {
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
inv:set_stack(listname, index, nil)
|
||||
local player_name=player:get_player_name()
|
||||
minetest.sound_play("trash", {to_player=player_name, gain = 1.0})
|
||||
end,
|
||||
})
|
||||
unified_inventory.trash:set_size("main", 1)
|
||||
end)
|
||||
|
||||
-- set_inventory_formspec
|
||||
unified_inventory.set_inventory_formspec = function(player,formspec)
|
||||
if player then
|
||||
player:set_inventory_formspec(formspec)
|
||||
end
|
||||
end
|
||||
|
||||
-- get_formspec
|
||||
unified_inventory.get_formspec = function(player,page)
|
||||
if player==nil then return "" end
|
||||
local player_name = player:get_player_name()
|
||||
unified_inventory.current_page[player_name]=page
|
||||
|
||||
local formspec = "size[14,10]"
|
||||
|
||||
-- player inventory
|
||||
formspec = formspec .. "list[current_player;main;0,4.5;8,4;]"
|
||||
|
||||
-- backgrounds
|
||||
formspec = formspec .. "background[-0.19,-0.2;14.38,10.55;ui_form_bg.png]"
|
||||
if page=="craft" then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_crafting_form.png]"
|
||||
end
|
||||
if page=="craftguide" then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_craftguide_form.png]"
|
||||
end
|
||||
if page=="misc" then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_misc_form.png]"
|
||||
end
|
||||
if page=="bags" then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_bags_main_form.png]"
|
||||
end
|
||||
|
||||
for i=1,4 do
|
||||
if page=="bag"..i then
|
||||
local slots = player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots
|
||||
if slots == 8 then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]"
|
||||
elseif slots == 16 then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]"
|
||||
elseif slots == 24 then
|
||||
formspec = formspec .. "background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- main buttons
|
||||
local start_x=0
|
||||
formspec = formspec .. "image_button["..(start_x+.65*0)..",9;.8,.8;ui_craft_icon.png;craft;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.65*1)..",9;.8,.8;ui_craftguide_icon.png;craftguide;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.65*2)..",9;.8,.8;ui_bags_icon.png;bags;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.65*3)..",9;.8,.8;ui_sethome_icon.png;home_gui_set;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.65*4)..",9;.8,.8;ui_gohome_icon.png;home_gui_go;]"
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
formspec = formspec .. "image_button["..(start_x+.65*5)..",9;.8,.8;ui_sun_icon.png;misc_set_day;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.65*6)..",9;.8,.8;ui_moon_icon.png;misc_set_night;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.65*7)..",9;.8,.8;ui_trash_icon.png;clear_inv;]"
|
||||
end
|
||||
|
||||
--controls to flip items pages
|
||||
start_x=9.2
|
||||
formspec = formspec .. "image_button["..(start_x+.6*0)..",9;.8,.8;ui_skip_backward_icon.png;start_list;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.6*1)..",9;.8,.8;ui_doubleleft_icon.png;rewind3;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.6*2)..",9;.8,.8;ui_left_icon.png;rewind1;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.6*3)..",9;.8,.8;ui_right_icon.png;forward1;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.6*4)..",9;.8,.8;ui_doubleright_icon.png;forward3;]"
|
||||
formspec = formspec .. "image_button["..(start_x+.6*5)..",9;.8,.8;ui_skip_forward_icon.png;end_list;]"
|
||||
|
||||
-- search box
|
||||
formspec = formspec .. "field[9.5,8.325;3,1;searchbox;;]"
|
||||
formspec = formspec .. "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]"
|
||||
|
||||
-- craft page
|
||||
if page=="craft" then
|
||||
formspec = formspec.."label[0,0;Crafting]"
|
||||
formspec = formspec.."list[current_player;craftpreview;6,1;1,1;]"
|
||||
formspec = formspec.."list[current_player;craft;2,1;3,3;]"
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
formspec = formspec.."label[0,2.5;Refill:]"
|
||||
formspec = formspec.."list[detached:"..player_name.."refill;main;0,3;1,1;]"
|
||||
formspec = formspec.."label[7,2.5;Trash:]"
|
||||
formspec = formspec.."list[detached:trash;main;7,3;1,1;]"
|
||||
end
|
||||
end
|
||||
|
||||
-- craft guide page
|
||||
if page=="craftguide" then
|
||||
formspec = formspec.."label[0,0;Crafting Guide]"
|
||||
formspec = formspec.."list[detached:"..player_name.."craftrecipe;build;2,1;3,3;]"
|
||||
formspec = formspec.."list[detached:"..player_name.."craftrecipe;output;6,1;1,1;]"
|
||||
formspec = formspec.."label[2,0.5;Input:]"
|
||||
formspec = formspec.."label[6,0.5;Output:]"
|
||||
formspec = formspec.."label[6,2.6;Method:]"
|
||||
local item_name=unified_inventory.current_item[player_name]
|
||||
if item_name then
|
||||
formspec = formspec.."label[2,0;"..item_name.."]"
|
||||
local alternates = 0
|
||||
local alternate = unified_inventory.alternate[player_name]
|
||||
local crafts = unified_inventory.crafts_table[item_name]
|
||||
|
||||
if crafts ~= nil and #crafts>0 then
|
||||
alternates = #crafts
|
||||
local craft = crafts[alternate]
|
||||
local method = "Crafting"
|
||||
if craft.type == "shapeless" then
|
||||
method="Crafting"
|
||||
end
|
||||
if craft.type == "cooking" then
|
||||
method="Cooking"
|
||||
end
|
||||
if craft.type == "fuel" then
|
||||
method="Fuel"
|
||||
end
|
||||
if craft.type == "grinding" then
|
||||
method="Grinding"
|
||||
end
|
||||
if craft.type == "alloy" then
|
||||
method="Alloy cooking"
|
||||
end
|
||||
if craft.type == "extracting" then
|
||||
method="Extracting"
|
||||
end
|
||||
if craft.type == "compressing" then
|
||||
method="Compressing"
|
||||
end
|
||||
formspec = formspec.."label[6,3;"..method.."]"
|
||||
end
|
||||
|
||||
if alternates > 1 then
|
||||
formspec = formspec.."label[0,2.6;Recipe "..tostring(alternate).." of "..tostring(alternates).."]"
|
||||
formspec = formspec.."button[0,3.15;2,1;alternate;Alternate]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- bags
|
||||
if page=="bags" then
|
||||
formspec = formspec.."label[0,0;Bags]"
|
||||
formspec=formspec.."button[0,2;2,0.5;bag1;Bag 1]"
|
||||
formspec=formspec.."button[2,2;2,0.5;bag2;Bag 2]"
|
||||
formspec=formspec.."button[4,2;2,0.5;bag3;Bag 3]"
|
||||
formspec=formspec.."button[6,2;2,0.5;bag4;Bag 4]"
|
||||
formspec=formspec.."list[detached:"..player_name.."_bags;bag1;0.5,1;1,1;]"
|
||||
formspec=formspec.."list[detached:"..player_name.."_bags;bag2;2.5,1;1,1;]"
|
||||
formspec=formspec.."list[detached:"..player_name.."_bags;bag3;4.5,1;1,1;]"
|
||||
formspec=formspec.."list[detached:"..player_name.."_bags;bag4;6.5,1;1,1;]"
|
||||
end
|
||||
|
||||
for i=1,4 do
|
||||
if page=="bag"..i then
|
||||
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
|
||||
formspec=formspec.."image[7,0;1,1;"..image.."]"
|
||||
formspec=formspec.."list[current_player;bag"..i.."contents;0,1;8,3;]"
|
||||
end
|
||||
end
|
||||
|
||||
--Items list
|
||||
local list_index=unified_inventory.current_index[player_name]
|
||||
local page=math.floor(list_index / (80) + 1)
|
||||
local pagemax = math.floor((unified_inventory.filtered_items_list_size[player_name]-1) / (80) + 1)
|
||||
local image
|
||||
local item={}
|
||||
for y=0,9,1 do
|
||||
for x=0,7,1 do
|
||||
name=unified_inventory.filtered_items_list[player_name][list_index]
|
||||
if minetest.registered_items[name] then
|
||||
formspec=formspec.."item_image_button["..(8.2+x*.7)..","..(1+y*.7)..";.81,.81;"..name..";item_button"..list_index..";]"
|
||||
list_index=list_index+1
|
||||
end
|
||||
end
|
||||
end
|
||||
formspec=formspec.."label[8.2,0;Page:]"
|
||||
formspec=formspec.."label[9,0;"..page.." of "..pagemax.."]"
|
||||
formspec=formspec.."label[8.2,0.4;Filter:]"
|
||||
formspec=formspec.."label[9,0.4;"..unified_inventory.activefilter[player_name].."]"
|
||||
return formspec
|
||||
end
|
||||
|
||||
-- register_on_player_receive_fields
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
-- main buttons
|
||||
if fields.craft then
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"craft"))
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
return
|
||||
end
|
||||
|
||||
if fields.craftguide then
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"craftguide"))
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
return
|
||||
end
|
||||
|
||||
if fields.bags then
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"bags"))
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
return
|
||||
end
|
||||
|
||||
-- bags
|
||||
for i=1,4 do
|
||||
local page = "bag"..i
|
||||
if fields[page] then
|
||||
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
|
||||
page = "bags"
|
||||
end
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,page))
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Miscellaneous
|
||||
if fields.home_gui_set then
|
||||
unified_inventory.set_home(player, player:getpos())
|
||||
local home = homepos[player_name]
|
||||
if home ~= nil then
|
||||
minetest.sound_play("dingdong", {to_player=player_name, gain = 1.0})
|
||||
minetest.chat_send_player(player_name, "Home position set to: "..math.floor(home.x)..","..math.floor(home.y)..","..math.floor(home.z))
|
||||
end
|
||||
end
|
||||
if fields.home_gui_go then
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"craft"))
|
||||
minetest.sound_play("teleport", {to_player=player_name, gain = 1.0})
|
||||
unified_inventory.go_home(player)
|
||||
end
|
||||
if fields.misc_set_day then
|
||||
if minetest.get_player_privs(player_name).settime==true then
|
||||
minetest.sound_play("birds", {to_player=player_name, gain = 1.0})
|
||||
minetest.env:set_timeofday((6000 % 24000) / 24000)
|
||||
minetest.chat_send_player(player_name, "Time of day set to 6am")
|
||||
else
|
||||
minetest.chat_send_player(player_name, "You don't have settime priviledge!")
|
||||
end
|
||||
end
|
||||
if fields.misc_set_night then
|
||||
if minetest.get_player_privs(player_name).settime==true then
|
||||
minetest.sound_play("owl", {to_player=player_name, gain = 1.0})
|
||||
minetest.env:set_timeofday((21000 % 24000) / 24000)
|
||||
minetest.chat_send_player(player_name, "Time of day set to 9pm")
|
||||
else
|
||||
minetest.chat_send_player(player_name, "You don't have settime priviledge!")
|
||||
end
|
||||
end
|
||||
|
||||
if fields.clear_inv then
|
||||
local inventory = {}
|
||||
player:get_inventory():set_list("main", inventory)
|
||||
minetest.chat_send_player(player_name, 'Inventory Cleared!')
|
||||
minetest.sound_play("trash_all", {to_player=player_name, gain = 1.0})
|
||||
end
|
||||
|
||||
-- Inventory page controls
|
||||
local start=math.floor(unified_inventory.current_index[player_name]/80 +1 )
|
||||
local start_i=start
|
||||
local pagemax = math.floor((unified_inventory.filtered_items_list_size[player_name]-1) / (80) + 1)
|
||||
|
||||
if fields.start_list then
|
||||
minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0})
|
||||
start_i = 1
|
||||
end
|
||||
if fields.rewind1 then
|
||||
minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0})
|
||||
start_i = start_i - 1
|
||||
end
|
||||
if fields.forward1 then
|
||||
minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0})
|
||||
start_i = start_i + 1
|
||||
end
|
||||
if fields.rewind3 then
|
||||
minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0})
|
||||
start_i = start_i - 3
|
||||
end
|
||||
if fields.forward3 then
|
||||
minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0})
|
||||
start_i = start_i + 3
|
||||
end
|
||||
if fields.end_list then
|
||||
minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0})
|
||||
start_i = pagemax
|
||||
end
|
||||
if start_i < 1 then
|
||||
start_i = 1
|
||||
end
|
||||
if start_i > pagemax then
|
||||
start_i = pagemax
|
||||
end
|
||||
if not (start_i ==start) then
|
||||
unified_inventory.current_index[player_name] = (start_i-1)*80+1
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,unified_inventory.current_page[player_name]))
|
||||
end
|
||||
|
||||
-- Item list buttons
|
||||
local list_index=unified_inventory.current_index[player_name]
|
||||
local page=unified_inventory.current_page[player_name]
|
||||
for i=0,80,1 do
|
||||
local button="item_button"..list_index
|
||||
if fields[button] then
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
if minetest.setting_getbool("creative_mode")==false then
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,"craftguide"))
|
||||
page="craftguide"
|
||||
end
|
||||
if page=="craftguide" then
|
||||
unified_inventory.current_item[player_name] = unified_inventory.filtered_items_list[player_name][list_index]
|
||||
unified_inventory.alternate[player_name] = 1
|
||||
unified_inventory.update_recipe (player, unified_inventory.filtered_items_list[player_name][list_index], 1)
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,unified_inventory.current_page[player_name]))
|
||||
else
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
local inv = player:get_inventory()
|
||||
dst_stack={}
|
||||
dst_stack["name"] = unified_inventory.filtered_items_list[player_name][list_index]
|
||||
dst_stack["count"]=99
|
||||
if inv:room_for_item("main",dst_stack) then
|
||||
inv:add_item("main",dst_stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
list_index=list_index+1
|
||||
end
|
||||
|
||||
if fields.searchbutton then
|
||||
unified_inventory.apply_filter(player, fields.searchbox)
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,unified_inventory.current_page[player_name]))
|
||||
minetest.sound_play("paperflip2", {to_player=player_name, gain = 1.0})
|
||||
end
|
||||
|
||||
-- alternate button
|
||||
if fields.alternate then
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
local item_name=unified_inventory.current_item[player_name]
|
||||
if item_name then
|
||||
local alternates = 0
|
||||
local alternate=unified_inventory.alternate[player_name]
|
||||
local crafts = unified_inventory.crafts_table[item_name]
|
||||
if crafts ~= nil then
|
||||
alternates = #crafts
|
||||
end
|
||||
if alternates > 1 then
|
||||
alternate=alternate+1
|
||||
if alternate>alternates then
|
||||
alternate=1
|
||||
end
|
||||
unified_inventory.alternate[player_name]=alternate
|
||||
unified_inventory.update_recipe (player, unified_inventory.current_item[player_name], alternate)
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,unified_inventory.current_page[player_name]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- load_home
|
||||
local load_home = function()
|
||||
local input = io.open(unified_inventory.home_filename..".home", "r")
|
||||
if input then
|
||||
while true do
|
||||
local x = input:read("*n")
|
||||
if x == nil then
|
||||
break
|
||||
end
|
||||
local y = input:read("*n")
|
||||
local z = input:read("*n")
|
||||
local name = input:read("*l")
|
||||
homepos[name:sub(2)] = {x = x, y = y, z = z}
|
||||
end
|
||||
io.close(input)
|
||||
else
|
||||
homepos = {}
|
||||
end
|
||||
end
|
||||
load_home() -- run it now
|
||||
|
||||
-- set_home
|
||||
unified_inventory.set_home = function(player, pos)
|
||||
local player_name=player:get_player_name()
|
||||
homepos[player_name] = pos
|
||||
-- save the home data from the table to the file
|
||||
local output = io.open(unified_inventory.home_filename..".home", "w")
|
||||
for k, v in pairs(homepos) do
|
||||
if v ~= nil then
|
||||
output:write(math.floor(v.x).." "..math.floor(v.y).." "..math.floor(v.z).." "..k.."\n")
|
||||
end
|
||||
end
|
||||
io.close(output)
|
||||
end
|
||||
|
||||
-- go_home
|
||||
unified_inventory.go_home = function(player)
|
||||
local pos = homepos[player:get_player_name()]
|
||||
if pos~=nil then
|
||||
player:setpos(pos)
|
||||
end
|
||||
end
|
||||
|
||||
--apply filter to the inventory list (create filtered copy of full one)
|
||||
unified_inventory.apply_filter = function(player,filter)
|
||||
local player_name = player:get_player_name()
|
||||
local size=0
|
||||
local str_temp1=string.lower(filter)
|
||||
if str_temp1 ~= "" then
|
||||
for i=1,str_temp1:len(),1 do
|
||||
if string.byte(str_temp1,i) == 91 then
|
||||
str_temp1=""
|
||||
end
|
||||
end
|
||||
end
|
||||
local str_temp2
|
||||
local str_temp3
|
||||
unified_inventory.filtered_items_list[player_name]={}
|
||||
for name,def in pairs(minetest.registered_items) do
|
||||
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
|
||||
and def.description and def.description ~= "" then
|
||||
str_temp2=string.lower(def.name)
|
||||
str_temp3=string.lower(def.description)
|
||||
if string.find(str_temp2, str_temp1) or string.find(str_temp3, str_temp1) then
|
||||
table.insert(unified_inventory.filtered_items_list[player_name], name)
|
||||
size=size+1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
table.sort(unified_inventory.filtered_items_list[player_name])
|
||||
unified_inventory.filtered_items_list_size[player_name]=size
|
||||
unified_inventory.current_index[player_name]=1
|
||||
unified_inventory.activefilter[player_name]=filter
|
||||
unified_inventory.set_inventory_formspec(player, unified_inventory.get_formspec(player,unified_inventory.current_page[player_name]))
|
||||
end
|
||||
|
||||
|
||||
-- update_recipe
|
||||
unified_inventory.update_recipe = function(player, stack_name, alternate)
|
||||
local inv = minetest.get_inventory({type="detached", name=player:get_player_name().."craftrecipe"})
|
||||
for i=0,inv:get_size("build"),1 do
|
||||
inv:set_stack("build", i, nil)
|
||||
end
|
||||
inv:set_stack("output", 1, nil)
|
||||
alternate = tonumber(alternate) or 1
|
||||
local crafts = unified_inventory.crafts_table[stack_name]
|
||||
print(dump(crafts))
|
||||
local next=next
|
||||
if next(crafts) == nil then return end -- no craft recipes
|
||||
if alternate < 1 or alternate > #crafts then
|
||||
alternate = 1
|
||||
end
|
||||
local craft = crafts[alternate]
|
||||
inv:set_stack("output", 1, craft.output)
|
||||
local items=craft.items
|
||||
|
||||
-- cooking, fuel, grinding, and extracting recipes
|
||||
if craft.type == "cooking" or
|
||||
craft.type == "fuel" or
|
||||
craft.type == "grinding" or
|
||||
craft.type == "extracting" or
|
||||
craft.type == "compressing" then
|
||||
def=unified_inventory.find_item_def(craft["items"][1])
|
||||
if def then
|
||||
inv:set_stack("build", 1, def)
|
||||
end
|
||||
return
|
||||
end
|
||||
if craft.width==0 then
|
||||
local build_table={1,2,3}
|
||||
for i=1,3,1 do
|
||||
if craft.items[i] then
|
||||
def=unified_inventory.find_item_def(craft.items[i])
|
||||
if def then inv:set_stack("build", build_table[i], def) end
|
||||
end
|
||||
end
|
||||
end
|
||||
if craft.width==1 then
|
||||
local build_table={1,4,7}
|
||||
for i=1,3,1 do
|
||||
if craft.items[i] then
|
||||
def=unified_inventory.find_item_def(craft.items[i])
|
||||
if def then inv:set_stack("build", build_table[i], def) end
|
||||
end
|
||||
end
|
||||
end
|
||||
if craft.width==2 then
|
||||
local build_table={1,2,4,5,7,8}
|
||||
for i=1,6,1 do
|
||||
if craft.items[i] then
|
||||
def=unified_inventory.find_item_def(craft.items[i])
|
||||
if def then inv:set_stack("build", build_table[i], def) end
|
||||
end
|
||||
end
|
||||
end
|
||||
if craft.width==3 then
|
||||
for i=1,9,1 do
|
||||
if craft.items[i] then
|
||||
def=unified_inventory.find_item_def(craft.items[i])
|
||||
if def then inv:set_stack("build", i, def) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unified_inventory.find_item_def = function(def1)
|
||||
if type(def1)=="string" then
|
||||
if string.find(def1, "group:") then
|
||||
def1=string.gsub(def1, "group:", "")
|
||||
def1=string.gsub(def1, '\"', "")
|
||||
local items=unified_inventory.items_in_group(def1)
|
||||
return items[1]
|
||||
else
|
||||
return def1
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
unified_inventory.items_in_group = function(group)
|
||||
local items = {}
|
||||
for name, item in pairs(minetest.registered_items) do
|
||||
for _, g in ipairs(group:split(',')) do
|
||||
if item.groups[g] then
|
||||
table.insert(items,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
-- register_craft
|
||||
unified_inventory.register_craft = function(options)
|
||||
if options.output == nil then
|
||||
return
|
||||
end
|
||||
local itemstack = ItemStack(options.output)
|
||||
if itemstack:is_empty() then
|
||||
return
|
||||
end
|
||||
if unified_inventory.crafts_table[itemstack:get_name()]==nil then
|
||||
unified_inventory.crafts_table[itemstack:get_name()] = {}
|
||||
end
|
||||
table.insert(unified_inventory.crafts_table[itemstack:get_name()],options)
|
||||
--crafts_table_count=crafts_table_count+1
|
||||
end
|
|
@ -0,0 +1,89 @@
|
|||
--[[
|
||||
|
||||
Bags for Minetest
|
||||
|
||||
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
Source Code: https://github.com/cornernote/minetest-particles
|
||||
License: GPLv3
|
||||
|
||||
]]--
|
||||
|
||||
-- register_on_joinplayer
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local player_inv = player:get_inventory()
|
||||
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, stack)
|
||||
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, nil)
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if stack:get_definition().groups.bagslots then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
if player:get_inventory():is_empty(listname.."contents")==true then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
for i=1,4 do
|
||||
local bag = "bag"..i
|
||||
player_inv:set_size(bag, 1)
|
||||
bags_inv:set_size(bag, 1)
|
||||
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
|
||||
end
|
||||
end)
|
||||
|
||||
-- register bag tools
|
||||
minetest.register_tool("unified_inventory:bag_small", {
|
||||
description = "Small Bag",
|
||||
inventory_image = "bags_small.png",
|
||||
groups = {bagslots=8},
|
||||
})
|
||||
minetest.register_tool("unified_inventory:bag_medium", {
|
||||
description = "Medium Bag",
|
||||
inventory_image = "bags_medium.png",
|
||||
groups = {bagslots=16},
|
||||
})
|
||||
minetest.register_tool("unified_inventory:bag_large", {
|
||||
description = "Large Bag",
|
||||
inventory_image = "bags_large.png",
|
||||
groups = {bagslots=24},
|
||||
})
|
||||
|
||||
-- register bag crafts
|
||||
minetest.register_craft({
|
||||
output = "unified_inventory:bag_small",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "unified_inventory:bag_medium",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"unified_inventory:bag_small", "unified_inventory:bag_small", "unified_inventory:bag_small"},
|
||||
{"unified_inventory:bag_small", "unified_inventory:bag_small", "unified_inventory:bag_small"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "unified_inventory:bag_large",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"unified_inventory:bag_medium", "unified_inventory:bag_medium", "unified_inventory:bag_medium"},
|
||||
{"unified_inventory:bag_medium", "unified_inventory:bag_medium", "unified_inventory:bag_medium"},
|
||||
},
|
||||
})
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
-- Unified Inventory mod 0.4.6
|
||||
|
||||
-- disable default creative inventory
|
||||
if creative_inventory then
|
||||
creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("unified_inventory").."/api.lua")
|
||||
dofile(minetest.get_modpath("unified_inventory").."/bags.lua")
|
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 797 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 16 KiB |