commit 167434085cf62f133aaeaeadd7f9eb80d946189f Author: RealBadAngel Date: Tue Aug 21 07:18:33 2012 +0200 upload diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..412eeda --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ebd21a --- /dev/null +++ b/.gitignore @@ -0,0 +1,163 @@ +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.vspscc +.builds +*.dotCover + +## TODO: If you have NuGet Package Restore enabled, uncomment this +#packages/ + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp + +# ReSharper is a .NET coding add-in +_ReSharper* + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Others +[Bb]in +[Oo]bj +sql +TestResults +*.Cache +ClientBin +stylecop.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + + + +############ +## Windows +############ + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg + +# Mac crap +.DS_Store diff --git a/concrete.lua b/concrete.lua new file mode 100644 index 0000000..0a480a0 --- /dev/null +++ b/concrete.lua @@ -0,0 +1,74 @@ + +minetest.register_craft({ + output = 'technic:rebar 6', + recipe = { + {'','', 'default:steel_ingot'}, + {'','default:steel_ingot',''}, + {'default:steel_ingot', '', ''}, + } +}) + +minetest.register_craft({ + output = 'technic:concrete 5', + recipe = { + {'default:stone','technic:rebar','default:stone'}, + {'technic:rebar','default:stone','technic:rebar'}, + {'default:stone','technic:rebar','default:stone'}, + } +}) + +minetest.register_craft({ + output = 'technic:concrete_post 4', + recipe = { + {'default:stone','technic:rebar','default:stone'}, + {'default:stone','technic:rebar','default:stone'}, + {'default:stone','technic:rebar','default:stone'}, +} +}) + +minetest.register_craftitem("technic:rebar", { + description = "Rebar", + inventory_image = "technic_rebar.png", + stack_max = 99, +}) + +minetest.register_craftitem("technic:concrete", { + description = "Concrete Block", + inventory_image = "technic_concrete_block.png", + stack_max = 99, +}) + +minetest.register_craftitem("technic:concrete_post", { + description = "Concrete Post", + inventory_image = "technic_concrete_post.png", + stack_max = 99, +}) + + + +-- NODES: + +minetest.register_node("technic:concrete", { + description = "Concrete Block", + tile_images = {"technic_concrete_block.png",}, + is_ground_content = true, + groups = {cracky=1}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("technic:concrete_post", { + description = "Concrete Post", + drawtype = "fencelike", + tiles = {"technic_concrete_block.png"}, + inventory_image = "default_fence.png", + wield_image = "default_fence.png", + paramtype = "light", + is_ground_content = true, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + + groups = {cracky=1}, + sounds = default.node_sound_stone_defaults(), +}) \ No newline at end of file diff --git a/copper_chest.lua b/copper_chest.lua new file mode 100644 index 0000000..cf1ae06 --- /dev/null +++ b/copper_chest.lua @@ -0,0 +1,162 @@ +minetest.register_craft({ + output = 'technic:copper_chest 1', + recipe = { + {'moreores:copper_ingot','moreores:copper_ingot','moreores:copper_ingot'}, + {'moreores:copper_ingot','technic:iron_chest','moreores:copper_ingot'}, + {'moreores:copper_ingot','moreores:copper_ingot','moreores:copper_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:copper_locked_chest 1', + recipe = { + {'moreores:copper_ingot','moreores:copper_ingot','moreores:copper_ingot'}, + {'moreores:copper_ingot','technic:iron_locked_chest','moreores:copper_ingot'}, + {'moreores:copper_ingot','moreores:copper_ingot','moreores:copper_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:copper_locked_chest 1', + recipe = { + {'default:steel_ingot'}, + {'technic:copper_chest'}, + } +}) + +minetest.register_craftitem("technic:copper_chest", { + description = "Copper Chest", + stack_max = 99, +}) +minetest.register_craftitem("technic:copper_locked_chest", { + description = "Copper Locked Chest", + stack_max = 99, +}) + +minetest.register_node("technic:copper_chest", { + description = "Copper Chest", + tiles = {"technic_copper_chest_top.png", "technic_copper_chest_top.png", "technic_copper_chest_side.png", + "technic_copper_chest_side.png", "technic_copper_chest_side.png", "technic_copper_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[10,9;]".. + "list[current_name;main;0,0;10,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Copper Chest") + local inv = meta:get_inventory() + inv:set_size("main", 10*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, +}) + + +local function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +minetest.register_node("technic:copper_locked_chest", { + description = "Copper Locked Chest", + tiles = {"technic_copper_chest_top.png", "technic_copper_chest_top.png", "technic_copper_chest_side.png", + "technic_copper_chest_side.png", "technic_copper_chest_side.png", "technic_copper_chest_locked.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Copper Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, +on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[10,9;]".. + "list[current_name;main;0,0;10,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Copper Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 10*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..d2e492a --- /dev/null +++ b/depends.txt @@ -0,0 +1,7 @@ +default +moreores +stairs +flowers +dye + + diff --git a/dyes.lua b/dyes.lua new file mode 100644 index 0000000..a81988e --- /dev/null +++ b/dyes.lua @@ -0,0 +1,40 @@ +minetest.register_craft({ + type = "cooking", + output = "dye:black 2", + recipe = "default:coal_lump", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:green 2", + recipe = "default:cactus", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:red 2", + recipe = "flowers:flower_rose", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:blue 2", + recipe = "flowers:flower_viola", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:white 2", + recipe = "flowers:flower_dandelion_white", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:yellow 2", + recipe = "flowers:flower_dandelion_yellow", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:orange 2", + recipe = "flowers:flower_tulip", +}) +minetest.register_craft({ + type = "cooking", + output = "dye:brown 2", + recipe = "default:dry_shrub", +}) \ No newline at end of file diff --git a/electric.lua b/electric.lua new file mode 100644 index 0000000..6ddaa46 --- /dev/null +++ b/electric.lua @@ -0,0 +1,588 @@ +minetest.register_alias("battery", "technic:battery") +minetest.register_alias("battery_box", "technic:battery_box") +minetest.register_alias("electric_furnace", "technic:electric_furnace") + + +minetest.register_craft({ + output = 'technic:battery 1', + recipe = { + {'default:wood', 'moreores:copper_ingot', 'default:wood'}, + {'default:wood', 'moreores:tin_ingot', 'default:wood'}, + {'default:wood', 'moreores:copper_ingot', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'technic:battery_box 1', + recipe = { + {'technic:battery', 'default:wood', 'technic:battery'}, + {'technic:battery', 'moreores:copper_ingot', 'technic:battery'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:electric_furnace', + recipe = { + {'default:brick', 'default:brick', 'default:brick'}, + {'default:brick', '', 'default:brick'}, + {'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'}, + } +}) + + +--minetest.register_craftitem("technic:battery", { +-- description = "Recharcheable battery", +-- inventory_image = "technic_battery.png", +-- stack_max = 1, +--}) + +minetest.register_tool("technic:battery", +{description = "RE Battery", +inventory_image = "technic_battery.png", +energy_charge = 0, +tool_capabilities = {max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}}) + +minetest.register_craftitem("technic:battery_box", { + description = "Battery box", + stack_max = 99, +}) + + + +battery_box_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "list[current_name;src;3,1;1,1;]".. + "image[4,1;1,1;technic_battery_reload.png]".. + "list[current_name;dst;5,1;1,1;]".. + "label[0,0;Battery box]".. + "label[3,0;Charge]".. + "label[5,0;Discharge]".. + "label[1,3;Power level]".. + "list[current_player;main;0,5;8,4;]" + +minetest.register_node("technic:battery_box", { + description = "Battery box", + tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png", "technic_battery_box_side.png", + "technic_battery_box_side.png", "technic_battery_box_side.png", "technic_battery_box_side.png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + technic_power_machine=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("infotext", "Battery box") + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", battery_box_formspec) + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 1) + battery_charge = 0 + max_charge = 60000 + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +electric_furnace_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "list[current_name;src;3,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "label[0,0;Electric Furnace]".. + "label[1,3;Power level]" + +minetest.register_node("technic:electric_furnace", { + description = "Electric furnace", + tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png", + "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"}, + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + technic_power_machine=1, + internal_EU_buffer=0; + interal_EU_buffer_size=2000; + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("infotext", "Electric furnace") + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + local EU_used = 0 + local furnace_is_cookin = 0 + local cooked = nil + meta:set_float("internal_EU_buffer",0) + meta:set_float("internal_EU_buffer_size",2000) + + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +minetest.register_node("technic:electric_furnace_active", { + description = "Electric Furnace", + tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png", + "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"}, + paramtype2 = "facedir", + light_source = 8, + drop = "technic:electric_furnace", + groups = {cracky=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + internal_EU_buffer=0; + interal_EU_buffer_size=2000; + technic_power_machine=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("infotext", "Electric furnace"); + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + local EU_used = 0 + local furnace_is_cookin = 0 + local cooked = nil + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +minetest.register_abm({ + nodenames = {"technic:electric_furnace","technic:electric_furnace_active"}, + interval = 1, + chance = 1, + + action = function(pos, node, active_object_count, active_object_count_wider) + + local meta = minetest.env:get_meta(pos) + internal_EU_buffer=meta:get_float("internal_EU_buffer") + internal_EU_buffer_size=meta:get_float("internal_EU_buffer") + local load = math.floor(internal_EU_buffer/2000 * 100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "list[current_name;src;3,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "label[0,0;Electric Furnace]".. + "label[1,3;Power level]") + + local inv = meta:get_inventory() + + local furnace_is_cookin = meta:get_float("furnace_is_cookin") + + + local srclist = inv:get_list("src") + local cooked=nil + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + end + + + if (furnace_is_cookin == 1) then + if internal_EU_buffer>=150 then + internal_EU_buffer=internal_EU_buffer-150; + meta:set_float("internal_EU_buffer",internal_EU_buffer) + meta:set_float("src_time", meta:get_float("src_time") + 3) + if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then + -- check if there's room for output in "dst" list + if inv:room_for_item("dst",cooked.item) then + -- Put result in "dst" list + inv:add_item("dst", cooked.item) + -- take stuff from "src" list + srcstack = inv:get_stack("src", 1) + srcstack:take_item() + inv:set_stack("src", 1, srcstack) + else + print("Furnace inventory full!") + end + meta:set_string("src_time", 0) + end + end + end + + + + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + if cooked.time>0 then + hacky_swap_node(pos,"technic:electric_furnace_active") + meta:set_string("infotext","Furnace active") + meta:set_string("furnace_is_cookin",1) + -- meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("src_time", 0) + return + end + + end + + hacky_swap_node(pos,"technic:electric_furnace") + meta:set_string("infotext","Furnace inactive") + meta:set_string("furnace_is_cookin",0) + -- meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("src_time", 0) + + +end, +}) + + + + +function take_EU_from_net(pos, EU_to_take) + local meta = minetest.env:get_meta(pos) + local pos1=pos + pos1.z=pos1.z +1 + local meta1 = minetest.env:get_meta(pos1) + charge=meta1:get_float("battery_charge") + charge=charge - EU_to_take + meta1:set_float("battery_charge",charge) +end + + LV_nodes_visited = {} + +function 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 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 + +minetest.register_abm({ + nodenames = {"technic:battery_box"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.env:get_meta(pos) + charge= meta:get_float("battery_charge") + max_charge= 60000 + + local inv = meta:get_inventory() + if inv:is_empty("src")==false then + srcstack = inv:get_stack("src", 1) + src_item=srcstack:to_table() + if src_item["name"]== "technic:battery" then + local load1=tonumber((src_item["wear"])) + load1=get_RE_item_load(load1,10000) + load_step=1000 + if load1<10000 and charge>0 then + if charge-load_step<0 then load_step=charge end + if load1+load_step>10000 then load_step=10000-load1 end + load1=load1+load_step + charge=charge-load_step + + load1=set_RE_item_load(load1,10000) + src_item["wear"]=tostring(load1) + inv:set_stack("src", 1, src_item) + end + end + end + meta:set_float("battery_charge",charge) + + + if inv:is_empty("src")==false then + srcstack = inv:get_stack("src", 1) + src_item=srcstack:to_table() + if src_item["name"]== "technic:laser_mk1" then + local load1=tonumber((src_item["wear"])) + load1=get_RE_item_load(load1,40000) + load_step=1000 + if load1<40000 and charge>0 then + if charge-load_step<0 then load_step=charge end + if load1+load_step>40000 then load_step=40000-load1 end + load1=load1+load_step + charge=charge-load_step + load1=set_RE_item_load(load1,40000) + src_item["wear"]=tostring(load1) + inv:set_stack("src", 1, src_item) + end + end + end + meta:set_float("battery_charge",charge) + + + if inv:is_empty("dst") == false then + srcstack = inv:get_stack("dst", 1) + src_item=srcstack:to_table() + if src_item["name"]== "technic:battery" then + local load1=tonumber((src_item["wear"])) + load1=get_RE_item_load(load1,10000) + load_step=1000 + if load1>0 and chargemax_charge then load_step=max_charge-charge end + if load1-load_step<0 then load_step=load1 end + load1=load1-load_step + charge=charge+load_step + + load1=set_RE_item_load(load1,10000) + src_item["wear"]=tostring(load1) + inv:set_stack("dst", 1, src_item) + end + end + end + + + meta:set_float("battery_charge",charge) + meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge); + + local load = math.floor(charge/60000 * 100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "list[current_name;src;3,1;1,1;]".. + "image[4,1;1,1;technic_battery_reload.png]".. + "list[current_name;dst;5,1;1,1;]".. + "label[0,0;Battery box]".. + "label[3,0;Charge]".. + "label[5,0;Discharge]".. + "label[1,3;Power level]".. + "list[current_player;main;0,5;8,4;]") + + local pos1={} + + pos1.y=pos.y-1 + pos1.x=pos.x + pos1.z=pos.z + + + meta1 = minetest.env:get_meta(pos1) + if meta1:get_float("cablelike")~=1 then return end + + local LV_nodes = {} + local PR_nodes = {} + local RE_nodes = {} + + LV_nodes[1]={} + LV_nodes[1].x=pos1.x + LV_nodes[1].y=pos1.y + LV_nodes[1].z=pos1.z + LV_nodes[1].visited=false + + +table_index=1 + repeat + check_LV_node (PR_nodes,RE_nodes,LV_nodes,table_index) + table_index=table_index+1 + if LV_nodes[table_index]==nil then break end + until false + + +local pos1={} +i=1 + repeat + if PR_nodes[i]==nil then break end + pos1.x=PR_nodes[i].x + pos1.y=PR_nodes[i].y + pos1.z=PR_nodes[i].z + local meta1 = minetest.env:get_meta(pos1) + local active=meta1:get_float("active") + if active==1 then charge=charge+80 end + i=i+1 + until false + +if charge>max_charge then charge=max_charge end + +i=1 + repeat + if RE_nodes[i]==nil then break end + pos1.x=RE_nodes[i].x -- loading all conected machines buffers + pos1.y=RE_nodes[i].y + pos1.z=RE_nodes[i].z + local meta1 = minetest.env:get_meta(pos1) + local internal_EU_buffer=meta1:get_float("internal_EU_buffer") + local internal_EU_buffer_size=meta1:get_float("internal_EU_buffer_size") + + local charge_to_give=200 + if internal_EU_buffer+charge_to_give>internal_EU_buffer_size then + charge_to_give=internal_EU_buffer_size-internal_EU_buffer + end + if charge-charge_to_give<0 then charge_to_give=charge end + + internal_EU_buffer=internal_EU_buffer+charge_to_give + meta1:set_float("internal_EU_buffer",internal_EU_buffer) + charge=charge-charge_to_give; + + i=i+1 + until false + + meta:set_float("battery_charge",charge) + meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge); + + +end +}) + +function add_new_cable_node (LV_nodes,pos1) +local i=1 + repeat + if LV_nodes[i]==nil then break end + if pos1.x==LV_nodes[i].x and pos1.y==LV_nodes[i].y and pos1.z==LV_nodes[i].z then return false end + i=i+1 + until false +LV_nodes[i]={} +LV_nodes[i].x=pos1.x +LV_nodes[i].y=pos1.y +LV_nodes[i].z=pos1.z +LV_nodes[i].visited=false +return true +end + +function check_LV_node (PR_nodes,RE_nodes,LV_nodes,i) + local pos1={} + pos1.x=LV_nodes[i].x + pos1.y=LV_nodes[i].y + pos1.z=LV_nodes[i].z + LV_nodes[i].visited=true + new_node_added=false + + pos1.x=pos1.x+1 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.x=pos1.x-2 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.x=pos1.x+1 + + pos1.y=pos1.y+1 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.y=pos1.y-2 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.y=pos1.y+1 + + pos1.z=pos1.z+1 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.z=pos1.z-2 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.z=pos1.z+1 +return new_node_added +end + +function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) +meta = minetest.env:get_meta(pos1) +if meta:get_float("cablelike")==1 then new_node_added=add_new_cable_node(LV_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:solar_panel" then new_node_added=add_new_cable_node(PR_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:electric_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:electric_furnace_active" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:tool_workshop" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:music_player" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:grinder" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +end + + +function get_connected_charge (charge,pos1) + local charge1=0 + local meta={} + if minetest.env:get_node(pos1).name == "technic:battery_box" then + print ("found batbox") + meta = minetest.env:get_meta(pos1) + return meta:get_float("cable_OUT") + end + + if minetest.env:get_node(pos1).name == "technic:lv_cable" then + meta = minetest.env:get_meta(pos1) + charge1=meta:get_float("cable_OUT") + if charge1>charge then + charge=charge1 + end + end +return charge +end + +minetest.register_node("technic:solar_panel", { + tiles = {"technic_solar_panel_top.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png", + "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + description="Solar Panel", + active = false, + technic_power_machine=1, + drawtype = "nodebox", + paramtype = "light", + is_ground_content = true, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_float("technic_power_machine", 1) + meta:set_string("infotext", "Solar Panel") + meta:set_float("active", false) + end, +}) + +minetest.register_craft({ + output = 'technic:solar_panel 1', + recipe = { + {'default:sand', 'default:sand','default:sand'}, + {'default:sand', 'moreores:copper_ingot','default:sand'}, + {'default:sand', 'default:sand','default:sand'}, + + } +}) + +minetest.register_abm( + {nodenames = {"technic:solar_panel"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + + local pos1={} + pos1.y=pos.y+1 + pos1.x=pos.x + pos1.z=pos.z + + local light = minetest.env:get_node_light(pos1, nil) + local meta = minetest.env:get_meta(pos) + if light == nil then light = 0 end + if light >= 12 then + meta:set_string("infotext", "Solar Panel is active ") + meta:set_float("active",1) + else + meta:set_string("infotext", "Solar Panel is inactive"); + meta:set_float("active",0) + end + end, +}) \ No newline at end of file diff --git a/gold_chest.lua b/gold_chest.lua new file mode 100644 index 0000000..44fb313 --- /dev/null +++ b/gold_chest.lua @@ -0,0 +1,452 @@ +local chest_mark_colors = { + '', -- regular chest, without color bar + '_black', + '_blue', + '_brown', + '_cyan', + '_dark_green', + '_dark_grey', + '_green', + '_grey', + '_magenta', + '_orange', + '_pink', + '_red', + '_violet', + '_white', + '_yellow', +} + +minetest.register_craft({ + output = 'technic:gold_chest 1', + recipe = { + {'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, + {'moreores:gold_ingot','technic:silver_chest','moreores:gold_ingot'}, + {'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:gold_locked_chest 1', + recipe = { + {'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, + {'moreores:gold_ingot','technic:silver_locked_chest','moreores:gold_ingot'}, + {'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:gold_locked_chest 1', + recipe = { + {'default:steel_ingot'}, + {'technic:gold_chest'}, + } +}) + +minetest.register_craftitem("technic:gold_chest", { + description = "Gold Chest", + stack_max = 99, +}) +minetest.register_craftitem("technic:gold_locked_chest", { + description = "Gold Locked Chest", + stack_max = 99, +}) + +for i, state in ipairs(chest_mark_colors) do +minetest.register_node("technic:gold_chest".. state, { + description = "Gold Chest", + tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", + "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front"..state..".png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Gold Chest") + local inv = meta:get_inventory() + inv:set_size("main", 12*4) + end, + + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_punch = function (pos, node, puncher) + chest_punched (pos,node,puncher); + end, + + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos); + fields.text = fields.text or "" + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + end, + + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, +}) +end + + +local function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +for i, state in ipairs(chest_mark_colors) do +minetest.register_node("technic:gold_locked_chest".. state, { + description = "Gold Locked Chest", + tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", + "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked"..state..".png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Gold Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Gold Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 12*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_punch = function (pos, node, puncher) + local meta = minetest.env:get_meta(pos); + if (has_locked_chest_privilege(meta, puncher)) then + locked_chest_punched (pos,node,puncher); + end + end, + + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos); + fields.text = fields.text or "" + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + + meta:set_string("formspec", + "invsize[12,9;]".. + "list[current_name;main;0,0;12,4;]".. + "list[current_player;main;0,5;8,4;]") + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) +end + +function chest_punched (pos,node,puncher) + + local player_tool = puncher:get_wielded_item(); + local item=player_tool:get_name(); + if item == "dye:black" then + if (hacky_swap_node(pos,"technic:gold_chest_black")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:blue" then + if (hacky_swap_node(pos,"technic:gold_chest_blue")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:brown" then + if (hacky_swap_node(pos,"technic:gold_chest_brown")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:cyan" then + if (hacky_swap_node(pos,"technic:gold_chest_cyan")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:dark_green" then + if (hacky_swap_node(pos,"technic:gold_chest_dark_green")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:dark_grey" then + if (hacky_swap_node(pos,"technic:gold_chest_dark_grey")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:green" then + if (hacky_swap_node(pos,"technic:gold_chest_green")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:grey" then + if (hacky_swap_node(pos,"technic:gold_chest_grey")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:magenta" then + if (hacky_swap_node(pos,"technic:gold_chest_magenta")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:orange" then + if (hacky_swap_node(pos,"technic:gold_chest_orange")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:pink" then + if (hacky_swap_node(pos,"technic:gold_chest_pink")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:red" then + if (hacky_swap_node(pos,"technic:gold_chest_red")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:violet" then + if (hacky_swap_node(pos,"technic:gold_chest_violet")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:white" then + if (hacky_swap_node(pos,"technic:gold_chest_white")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:yellow" then + if (hacky_swap_node(pos,"technic:gold_chest_yellow")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + + local meta = minetest.env:get_meta(pos); + meta:set_string("formspec", "hack:sign_text_input") + end + + +function locked_chest_punched (pos,node,puncher) + + local player_tool = puncher:get_wielded_item(); + local item=player_tool:get_name(); + if item == "dye:black" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_black")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:blue" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_blue")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:brown" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_brown")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:cyan" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_cyan")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:dark_green" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_green")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:dark_grey" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_grey")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:green" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_green")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:grey" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_grey")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:magenta" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_magenta")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:orange" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_orange")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:pink" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_pink")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:red" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_red")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:violet" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_violet")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:white" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_white")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + if item == "dye:yellow" then + if (hacky_swap_node(pos,"technic:gold_locked_chest_yellow")) then + player_tool:take_item(1); + puncher:set_wielded_item(player_tool); + return + end + end + + local meta = minetest.env:get_meta(pos); + meta:set_string("formspec", "hack:sign_text_input") + end + \ No newline at end of file diff --git a/grinder.lua b/grinder.lua new file mode 100644 index 0000000..b0c6722 --- /dev/null +++ b/grinder.lua @@ -0,0 +1,236 @@ +minetest.register_craftitem( "technic:coal_dust", { + description = "Coal Dust", + inventory_image = "technic_coal_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) + +minetest.register_craftitem( "technic:iron_dust", { + description = "Iron Dust", + inventory_image = "technic_iron_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) + +minetest.register_craft({ + type = "cooking", + output = "default:steel_ingot", + recipe = "technic:iron_dust", +}) + +minetest.register_craftitem( "technic:copper_dust", { + description = "Copper Dust", + inventory_image = "technic_copper_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) +minetest.register_craft({ + type = "cooking", + output = "moreores:copper_ingot", + recipe = "technic:copper_dust", +}) + +minetest.register_craftitem( "technic:tin_dust", { + description = "Tin Dust", + inventory_image = "technic_tin_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) +minetest.register_craft({ + type = "cooking", + output = "moreores:tin_ingot", + recipe = "technic:tin_dust", +}) + +minetest.register_craftitem( "technic:silver_dust", { + description = "Silver Dust", + inventory_image = "technic_silver_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) +minetest.register_craft({ + type = "cooking", + output = "moreores:silver_ingot", + recipe = "technic:silver_dust", +}) + +minetest.register_craftitem( "technic:gold_dust", { + description = "Gold Dust", + inventory_image = "technic_gold_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) +minetest.register_craft({ + type = "cooking", + output = "moreores:gold_ingot", + recipe = "technic:gold_dust", +}) + +minetest.register_craftitem( "technic:mithril_dust", { + description = "Mithril Dust", + inventory_image = "technic_mithril_dust.png", + on_place_on_ground = minetest.craftitem_place_item, + }) +minetest.register_craft({ + type = "cooking", + output = "moreores:mithril_ingot", + recipe = "technic:mithril_dust", +}) + +minetest.register_alias("grinder", "technic:grinder") +minetest.register_craft({ + output = 'technic:grinder', + recipe = { + {'default:desert_stone', 'default:desert_stone', 'default:desert_stone'}, + {'default:desert_stone', 'technic:diamond', 'default:desert_stone'}, + {'default:stone', 'moreores:copper_ingot', 'default:stone'}, + } +}) + +minetest.register_craftitem("technic:grinder", { + description = "Grinder", + stack_max = 99, +}) + +grinder_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "label[0,0;Grinder]".. + "label[1,3;Power level]".. + "list[current_name;src;3,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]" + + +minetest.register_node("technic:grinder", { + description = "Grinder", + tiles = {"technic_grinder_top.png", "technic_machine_bottom.png", "technic_grinder_side.png", + "technic_grinder_side.png", "technic_grinder_side.png", "technic_grinder_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + technic_power_machine=1, + internal_EU_buffer=0; + internal_EU_buffer_size=5000; + grind_time=0; + grinded = nil; + src_time = 0; + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("infotext", "Grinder") + meta:set_float("technic_power_machine", 1) + meta:set_float("internal_EU_buffer", 0) + meta:set_float("internal_EU_buffer_size", 5000) + meta:set_string("formspec", grinder_formspec) + meta:set_float("grind_time", 0) + + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + + 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 + return false + end + if not inv:is_empty("dst") then + return false + end + + return true + end, + +}) + +minetest.register_abm({ + nodenames = {"technic:grinder"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + + local meta = minetest.env:get_meta(pos) + local charge= meta:get_float("internal_EU_buffer") + local max_charge= meta:get_float("internal_EU_buffer_size") + local grind_cost=200 + + local load = math.floor((charge/max_charge)*100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "label[0,0;Grinder]".. + "label[1,3;Power level]".. + "list[current_name;src;3,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]" + ) + + + + local inv = meta:get_inventory() + +-- local grinder_on = meta:get_float("grinder_on") + + + local srclist = inv:get_list("src") + if inv:is_empty("src") then meta:set_float("grinder_on",0) end + + + if (meta:get_float("grinder_on") == 1) then + if charge>=grind_cost then + charge=charge-grind_cost; + meta:set_float("internal_EU_buffer",charge) + meta:set_float("src_time", meta:get_float("src_time") + 1) + if meta:get_float("src_time") >= meta:get_float("grind_time") then + -- check if there's room for output in "dst" list + grinded = get_grinded_item (inv:get_stack("src", 1)) + if inv:room_for_item("dst",grinded) then + -- Put result in "dst" list + inv:add_item("dst", grinded) + -- take stuff from "src" list + srcstack = inv:get_stack("src", 1) + srcstack:take_item() + inv:set_stack("src", 1, srcstack) + if inv:is_empty("src") then meta:set_float("grinder_on",0) end + + + + else + print("Grinder inventory full!") + end + meta:set_float("src_time", 0) + end + end + end + + if (meta:get_float("grinder_on")==0) then + local grinded=nil + if not inv:is_empty("src") then + grinded = get_grinded_item (inv:get_stack("src", 1)) + if grinded then meta:set_float("grinder_on",1) end + grind_time=4 + meta:set_float("grind_time",grind_time) + meta:set_float("src_time", 0) + end + end + + + end +}) + +function get_grinded_item (items) +new_item =nil +src_item=items:to_table() +item_name=src_item["name"] + +if item_name=="default:stone" then new_item=ItemStack("default:sand") return new_item end +if item_name=="default:cobble" then new_item=ItemStack("default:gravel") return new_item end +if item_name=="default:gravel" then new_item=ItemStack("default:dirt") return new_item end +if item_name=="default:desert_stone" then new_item=ItemStack("default:desert_sand") return new_item end +if item_name=="default:iron_lump" then new_item=ItemStack("technic:iron_dust 2") return new_item end +if item_name=="default:coal_lump" then new_item=ItemStack("technic:coal_dust 2") return new_item end +if item_name=="moreores:copper_lump" then new_item=ItemStack("technic:copper_dust 2") return new_item end +if item_name=="moreores:tin_lump" then new_item=ItemStack("technic:tin_dust 2") return new_item end +if item_name=="moreores:silver_lump" then new_item=ItemStack("technic:silver_dust 2") return new_item end +if item_name=="moreores:gold_lump" then new_item=ItemStack("technic:gold_dust 2") return new_item end +if item_name=="moreores:mithril_lump" then new_item=ItemStack("technic:mithril_dust 2") return new_item end + +return nil +end \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..52e1716 --- /dev/null +++ b/init.lua @@ -0,0 +1,55 @@ +-- Minetest 0.4.1 mod: technic + +minetest.register_alias("rebar", "technic:rebar") +minetest.register_alias("concrete", "technic:concrete") +minetest.register_alias("concrete_post", "technic:concrete_post") +minetest.register_alias("iron_chest", "technic:iron_chest") +minetest.register_alias("iron_locked_chest", "technic:iron_locked_chest") +minetest.register_alias("copper_chest", "technic:copper_chest") +minetest.register_alias("copper_locked_chest", "technic:copper_locked_chest") +minetest.register_alias("silver_chest", "technic:silver_chest") +minetest.register_alias("silver_locked_chest", "technic:silver_locked_chest") +minetest.register_alias("gold_chest", "technic:gold_chest") +minetest.register_alias("gold_locked_chest", "technic:gold_locked_chest") +minetest.register_alias("mithril_chest", "technic:mithril_chest") +minetest.register_alias("mithril_locked_chest", "technic:mithril_locked_chest") + +dofile(minetest.get_modpath("technic").."/concrete.lua") +dofile(minetest.get_modpath("technic").."/iron_chest.lua") +dofile(minetest.get_modpath("technic").."/copper_chest.lua") +dofile(minetest.get_modpath("technic").."/silver_chest.lua") +dofile(minetest.get_modpath("technic").."/gold_chest.lua") +dofile(minetest.get_modpath("technic").."/mithril_chest.lua") +dofile(minetest.get_modpath("technic").."/electric.lua") +dofile(minetest.get_modpath("technic").."/wires.lua") +dofile(minetest.get_modpath("technic").."/dyes.lua") +dofile(minetest.get_modpath("technic").."/ores.lua") + +dofile(minetest.get_modpath("technic").."/tool_workshop.lua") +dofile(minetest.get_modpath("technic").."/music_player.lua") +dofile(minetest.get_modpath("technic").."/grinder.lua") +dofile(minetest.get_modpath("technic").."/mining_laser_mk1.lua") + + +function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + + +function hacky_swap_node(pos,name) + local node = minetest.env:get_node(pos) + local meta = minetest.env:get_meta(pos) + local meta0 = meta:to_table() + if node.name == name then + return nil + end + node.name = name + local meta0 = meta:to_table() + minetest.env:set_node(pos,node) + meta = minetest.env:get_meta(pos) + meta:from_table(meta0) + return 1 +end \ No newline at end of file diff --git a/iron_chest.lua b/iron_chest.lua new file mode 100644 index 0000000..d6a4cc2 --- /dev/null +++ b/iron_chest.lua @@ -0,0 +1,151 @@ +minetest.register_craft({ + output = 'technic:iron_chest 1', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot'}, + {'default:steel_ingot','default:chest','default:steel_ingot'}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot'}, + } +}) +minetest.register_craft({ + output = 'technic:iron_locked_chest 1', + recipe = { + {'default:steel_ingot'}, + {'technic:iron_chest'}, + } +}) + + +minetest.register_craftitem("technic:iron_chest", { + description = "Iron Chest", + stack_max = 99, +}) +minetest.register_craftitem("technic:iron_locked_chest", { + description = "Iron Locked Chest", + stack_max = 99, +}) + +minetest.register_node("technic:iron_chest", { + description = "Iron Chest", + tiles = {"technic_iron_chest_top.png", "technic_iron_chest_top.png", "technic_iron_chest_side.png", + "technic_iron_chest_side.png", "technic_iron_chest_side.png", "technic_iron_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[9,9;]".. + "list[current_name;main;0,0;9,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Iron Chest") + local inv = meta:get_inventory() + inv:set_size("main", 9*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, +}) + +local function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +minetest.register_node("technic:iron_locked_chest", { + description = "Iron Locked Chest", + tiles = {"technic_iron_chest_top.png", "technic_iron_chest_top.png", "technic_iron_chest_side.png", + "technic_iron_chest_side.png", "technic_iron_chest_side.png", "technic_iron_chest_locked.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Locked Iron Chest (owned by ".. + meta:get_string("owner")..")") + end, +on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[9,9;]".. + "list[current_name;main;0,0;9,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Iron Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 9*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) diff --git a/mining_laser_mk1.lua b/mining_laser_mk1.lua new file mode 100644 index 0000000..a2569e3 --- /dev/null +++ b/mining_laser_mk1.lua @@ -0,0 +1,153 @@ +laser_mk1_max_charge=40000 + +local laser_shoot = function(itemstack, player, pointed_thing) + local playerpos=player:getpos() + local dir=player:get_look_dir() + direction_y=math.abs(math.floor(dir.y*100)) + print (direction_y) + if direction_y>50 then entity_name="technic:laser_beam_entityV" + else entity_name="technic:laser_beam_entity" end + local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.6,z=playerpos.z},entity_name) + if obj:get_luaentity().player == nil then + obj:get_luaentity().player = player + end + obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19}) + obj:setacceleration({x=dir.x*-2, y=0, z=dir.z*-2}) + obj:setyaw(player:get_look_yaw()+math.pi) + if obj:get_luaentity().player == nil then + obj:get_luaentity().player = player + end + obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name() + minetest.sound_play("technic_laser", {pos = playerpos, gain = 1.0, max_hear_distance = 10,}) + return true +end + + +minetest.register_tool("technic:laser_mk1", { + description = "Mining Laser MK1", + inventory_image = "technic_mining_laser_mk1.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + item=itemstack:to_table() + local charge=tonumber((item["wear"])) + if charge ==0 then charge =65535 end + charge=get_RE_item_load(charge,laser_mk1_max_charge) + if charge-400>0 then + laser_shoot(item, user, pointed_thing) + charge =charge-400; + charge=set_RE_item_load(charge,laser_mk1_max_charge) + item["wear"]=tostring(charge) + itemstack:replace(item) + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'technic:laser_mk1', + recipe = { + {'technic:diamond', 'default:steel_ingot', 'technic:battery'}, + {'', 'default:steel_ingot', 'technic:battery'}, + {'', '', 'moreores:copper_ingot'}, + } +}) + + + +minetest.register_node("technic:laser_beam_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + { -0.5 , -0.1, -0.1 , 0.1 , 0.1 , 0.1 }, + { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1 }, + } + }, + tiles = {"technic_laser_beam.png"}, + groups = {not_in_creative_inventory=1}, +}) + +minetest.register_node("technic:laser_beam_boxV", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1 }, + { -0.1 , -0.5, -0.1 , 0.1 , 0.1 , 0.1 }, + + } + }, + tiles = {"technic_laser_beam.png"}, + groups = {not_in_creative_inventory=1}, +}) + +LASER_BEAM_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.2, y=0.2}, + textures = {"technic:laser_beam_box"}, + lastpos={}, + max_range=15, + count=0, +-- digger=nil, + collisionbox = {0,0,0,0,0,0}, +} + +LASER_BEAM_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + if self.lastpos.x~=nil then lazer_it (pos, node, self.player) end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.count=self.count+1 + if self.count>=self.max_range then self.object:remove() end +end + +LASER_BEAM_ENTITYV={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.2, y=0.2}, + textures = {"technic:laser_beam_boxV"}, + lastpos={}, + max_range=15, + count=0, + collisionbox = {0,0,0,0,0,0}, +} + +LASER_BEAM_ENTITYV.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + if self.lastpos.x~=nil then lazer_it (pos, node, self.player,self.count) end + + self.lastpos={x=pos.x, y=pos.y, z=pos.z} + self.count=self.count+1 + if self.count==self.max_range then self.object:remove() end +end + + +minetest.register_entity("technic:laser_beam_entity", LASER_BEAM_ENTITY) +minetest.register_entity("technic:laser_beam_entityV", LASER_BEAM_ENTITYV) + +function lazer_it (pos, node, player,count) + if node.name == "air" then return end + if node.name == "default:lava_source" then return end + if node.name == "default:lava_flowing" then return end + if node.name == "default:water_source" then minetest.env:remove_node(pos) return end + if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end + if node.name == "ignore" then minetest.env:remove_node(pos) return end + + if player then + local drops = minetest.get_node_drops(node.name, "default:pick_mese") + if player:get_inventory() then + local _, dropped_item + for _, dropped_item in ipairs(drops) do + player:get_inventory():add_item("main", dropped_item) + end + end + minetest.env:remove_node(pos) + end + +end \ No newline at end of file diff --git a/mithril_chest.lua b/mithril_chest.lua new file mode 100644 index 0000000..89683f8 --- /dev/null +++ b/mithril_chest.lua @@ -0,0 +1,145 @@ +minetest.register_craft({ + output = 'technic:mithril_chest 1', + recipe = { + {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, + {'moreores:mithril_ingot','technic:gold_chest','moreores:mithril_ingot'}, + {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:mithril_locked_chest 1', + recipe = { + {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, + {'moreores:mithril_ingot','technic:gold_locked_chest','moreores:mithril_ingot'}, + {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:mithril_locked_chest 1', + recipe = { + {'default:steel_ingot'}, + {'technic:mithril_chest'}, + } +}) + +minetest.register_node("technic:mithril_chest", { + description = "Mithril Chest", + tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png", + "technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[13,9;]".. + "list[current_name;main;0,0;13,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Mithril Chest") + local inv = meta:get_inventory() + inv:set_size("main", 13*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, +}) + +minetest.register_node("technic:mithril_locked_chest", { + description = "Mithril Locked Chest", + tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png", + "technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_chest_locked.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Mithril Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, +on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[13,9;]".. + "list[current_name;main;0,0;13,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Mithril Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 13*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) diff --git a/music_player.lua b/music_player.lua new file mode 100644 index 0000000..72adee1 --- /dev/null +++ b/music_player.lua @@ -0,0 +1,124 @@ + +minetest.register_alias("music_player", "technic:music_player") +minetest.register_craft({ + output = 'technic:music_player', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'technic:diamond', 'technic:diamond', 'technic:diamond'}, + {'default:stone', 'moreores:copper_ingot', 'default:stone'}, + } +}) + +minetest.register_craftitem("technic:music_player", { + description = "Music Player", + stack_max = 99, +}) + +music_player_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "label[0,0;Music Player]".. + "label[1,3;Power level]".. + "button[5,2;1,1;track1;1]".. + "button[6,2;1,1;track2;2]" + + +minetest.register_node("technic:music_player", { + description = "Music Player", + tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png", + "technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + technic_power_machine=1, + internal_EU_buffer=0, + internal_EU_buffer_size=5000, + music_player_on=0, + music_handle = 0, + music_player_current_track =1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("infotext", "Music Player") + meta:set_float("technic_power_machine", 1) + meta:set_float("internal_EU_buffer", 1) + meta:set_float("internal_EU_buffer_size", 5000) + meta:set_string("formspec", music_player_formspec) + meta:set_float("music_player_on", 0) + meta:set_float("music_player_current_track", 1) + end, + + on_receive_fields = function(pos, formanme, fields, sender) + + local meta = minetest.env:get_meta(pos) + player_on=meta:get_float("music_player_on") + music_handle=meta:get_float("music_handle") + music_player_current_track=meta:get_float("music_player_current_track") + if fields.track1 then music_player_current_track=1 end + if fields.track2 then music_player_current_track=2 end + if fields.track3 then music_player_current_track=3 end + if fields.track4 then music_player_current_track=4 end + if fields.track5 then music_player_current_track=5 end + if fields.track6 then music_player_current_track=6 end + if fields.track7 then music_player_current_track=7 end + if fields.track8 then music_player_current_track=8 end + if fields.track9 then music_player_current_track=9 end + meta:set_float("music_player_current_track",music_player_current_track) + if fields.play and player_on==1 then + minetest.sound_stop(music_handle) + music_handle=minetest.sound_play("technic_track"..music_player_current_track, {pos = pos, gain = 1.0,loop = true, max_hear_distance = 72,}) + end + if fields.stop then + minetest.sound_stop(music_handle) + end + meta:set_float("music_handle",music_handle) + end, +}) + +minetest.register_abm({ + nodenames = {"technic:music_player"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.env:get_meta(pos) + local charge= meta:get_float("internal_EU_buffer") + local max_charge= meta:get_float("internal_EU_buffer_size") + player_on=meta:get_float("music_player_on") + music_player_current_track=meta:get_float("music_player_current_track") + local play_cost=80 + + if charge>play_cost then + charge=charge-play_cost; + meta:set_float("internal_EU_buffer",charge) + meta:set_float("music_player_on",1) + else + player_on=0 + meta:set_float("music_player_on",0) + minetest.sound_stop(music_handle) + end + local load = math.floor((charge/max_charge)*100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "label[0,0;Music Player]".. + "label[1,3;Power level]".. + "button[4,1;1,1;track1;1]".. + "button[5,1;1,1;track2;2]".. + "button[6,1;1,1;track3;3]".. + "button[4,2;1,1;track4;4]".. + "button[5,2;1,1;track5;5]".. + "button[6,2;1,1;track6;6]".. + "button[4,3;1,1;track7;7]".. + "button[5,3;1,1;track8;8]".. + "button[6,3;1,1;track9;9]".. + "button[4,4;1,2;play;Play]".. + "button[6,4;1,2;stop;Stop]".. + "label[4,0;Current track "..tostring(music_player_current_track).."]" + + ) + + + + + end +}) + diff --git a/ores.lua b/ores.lua new file mode 100644 index 0000000..f1304b2 --- /dev/null +++ b/ores.lua @@ -0,0 +1,60 @@ +minetest.register_node( "technic:mineral_diamond", { + description = "Diamond Ore", + tile_images = { "default_stone.png^technic_mineral_diamond.png" }, + is_ground_content = true, + groups = {cracky=3}, + sounds = default.node_sound_stone_defaults(), + drop = 'craft "technic:diamond" 1', +}) + +minetest.register_craftitem( "technic:diamond", { + description = "Diamond", + inventory_image = "technic_diamond.png", + on_place_on_ground = minetest.craftitem_place_item, +}) + +local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max) + if maxp.y < height_min or minp.y > height_max then + return + end + local y_min = math.max(minp.y, height_min) + local y_max = math.min(maxp.y, height_max) + local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1) + local pr = PseudoRandom(seed) + local num_chunks = math.floor(chunks_per_volume * volume) + local chunk_size = 3 + if ore_per_chunk <= 4 then + chunk_size = 2 + end + local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk) + --print("generate_ore num_chunks: "..dump(num_chunks)) + for i=1,num_chunks do + if (y_max-chunk_size+1 <= y_min) then return end + local y0 = pr:next(y_min, y_max-chunk_size+1) + if y0 >= height_min and y0 <= height_max then + local x0 = pr:next(minp.x, maxp.x-chunk_size+1) + local z0 = pr:next(minp.z, maxp.z-chunk_size+1) + local p0 = {x=x0, y=y0, z=z0} + for x1=0,chunk_size-1 do + for y1=0,chunk_size-1 do + for z1=0,chunk_size-1 do + if pr:next(1,inverse_chance) == 1 then + local x2 = x0+x1 + local y2 = y0+y1 + local z2 = z0+z1 + local p2 = {x=x2, y=y2, z=z2} + if minetest.env:get_node(p2).name == wherein then + minetest.env:set_node(p2, {name=name}) + end + end + end + end + end + end + end + --print("generate_ore done") +end + +minetest.register_on_generated(function(minp, maxp, seed) +generate_ore("technic:mineral_diamond", "default:stone", minp, maxp, seed+20, 1/11/11/11, 1, -31000, -450) +end) \ No newline at end of file diff --git a/silver_chest.lua b/silver_chest.lua new file mode 100644 index 0000000..66a915a --- /dev/null +++ b/silver_chest.lua @@ -0,0 +1,197 @@ +minetest.register_craft({ + output = 'technic:silver_chest 1', + recipe = { + {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'}, + {'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'}, + {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:silver_locked_chest 1', + recipe = { + {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'}, + {'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'}, + {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:silver_locked_chest 1', + recipe = { + {'default:steel_ingot'}, + {'technic:silver_chest'}, + } +}) + +minetest.register_craftitem("technic:silver_chest", { + description = "Silver Chest", + stack_max = 99, +}) +minetest.register_craftitem("technic:silver_locked_chest", { + description = "Silver Locked Chest", + stack_max = 99, +}) + +minetest.register_node("technic:silver_chest", { + description = "Silver Chest", + tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png", + "technic_silver_chest_side.png", "technic_silver_chest_side.png", "technic_silver_chest_front.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[11,9;]".. + "list[current_name;main;0,0;11,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Silver Chest") + local inv = meta:get_inventory() + inv:set_size("main", 11*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_punch = function (pos, node, puncher) + local meta = minetest.env:get_meta(pos); + meta:set_string("formspec", "hack:sign_text_input") + end, + + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos); + fields.text = fields.text or "" + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + + meta:set_string("formspec", + "invsize[11,9;]".. + "list[current_name;main;0,0;11,4;]".. + "list[current_player;main;0,5;8,4;]") + end, + + on_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_move_allow_all( + pos, from_list, from_index, to_list, to_index, count, player) + end, + on_metadata_inventory_offer = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + return minetest.node_metadata_inventory_offer_allow_all( + pos, listname, index, stack, player) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + +}) + +local function has_locked_chest_privilege(meta, player) + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + return true +end + +minetest.register_node("technic:silver_locked_chest", { + description = "Silver Locked Chest", + tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png", + "technic_silver_chest_side.png", "technic_silver_chest_side.png", "technic_silver_chest_locked.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, placer) + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Silver Locked Chest (owned by ".. + meta:get_string("owner")..")") + end, +on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", + "invsize[11,9;]".. + "list[current_name;main;0,0;11,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", "Silver Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("main", 11*4) + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + + on_punch = function (pos, node, puncher) + local meta = minetest.env:get_meta(pos); + meta:set_string("formspec", "hack:sign_text_input") + end, + + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos); + fields.text = fields.text or "" + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') + + meta:set_string("formspec", + "invsize[11,9;]".. + "list[current_name;main;0,0;11,4;]".. + "list[current_player;main;0,5;8,4;]") + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return count + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if not has_locked_chest_privilege(meta, player) then + minetest.log("action", player:get_player_name().. + " tried to access a locked chest belonging to ".. + meta:get_string("owner").." at ".. + minetest.pos_to_string(pos)) + return 0 + end + return stack:get_count() + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to locked chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from locked chest at "..minetest.pos_to_string(pos)) + end, +}) diff --git a/solar.lua b/solar.lua new file mode 100644 index 0000000..2d397f9 --- /dev/null +++ b/solar.lua @@ -0,0 +1,23 @@ +minetest.register_abm( + {nodenames = {"technic:solar_panel"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + + local pos1={} + pos1.y=pos.y+1 + pos1.x=pos.x + pos1.z=pos.z + + local light = minetest.env:get_node_light(pos1, nil) + local meta = minetest.env:get_meta(pos) + if light == nil then light = 0 end + if light >= 12 then + meta:set_string("infotext", "Solar Panel is active ") + meta:set_float("active",1) + else + meta:set_string("infotext", "Solar Panel is inactive"); + meta:set_float("active",0) + end + end, +}) \ No newline at end of file diff --git a/sounds/technic_laser.ogg b/sounds/technic_laser.ogg new file mode 100644 index 0000000..19be080 Binary files /dev/null and b/sounds/technic_laser.ogg differ diff --git a/textures/technic_battery.png b/textures/technic_battery.png new file mode 100644 index 0000000..ee83b74 Binary files /dev/null and b/textures/technic_battery.png differ diff --git a/textures/technic_battery_box_bottom.png b/textures/technic_battery_box_bottom.png new file mode 100644 index 0000000..1b3cf48 Binary files /dev/null and b/textures/technic_battery_box_bottom.png differ diff --git a/textures/technic_battery_box_side.png b/textures/technic_battery_box_side.png new file mode 100644 index 0000000..5a8a976 Binary files /dev/null and b/textures/technic_battery_box_side.png differ diff --git a/textures/technic_battery_box_top.png b/textures/technic_battery_box_top.png new file mode 100644 index 0000000..f10be04 Binary files /dev/null and b/textures/technic_battery_box_top.png differ diff --git a/textures/technic_battery_reload.png b/textures/technic_battery_reload.png new file mode 100644 index 0000000..164b4ac Binary files /dev/null and b/textures/technic_battery_reload.png differ diff --git a/textures/technic_coal_dust.png b/textures/technic_coal_dust.png new file mode 100644 index 0000000..4a1da0c Binary files /dev/null and b/textures/technic_coal_dust.png differ diff --git a/textures/technic_concrete_block.png b/textures/technic_concrete_block.png new file mode 100644 index 0000000..91364f3 Binary files /dev/null and b/textures/technic_concrete_block.png differ diff --git a/textures/technic_copper_chest_front.png b/textures/technic_copper_chest_front.png new file mode 100644 index 0000000..1769435 Binary files /dev/null and b/textures/technic_copper_chest_front.png differ diff --git a/textures/technic_copper_chest_locked.png b/textures/technic_copper_chest_locked.png new file mode 100644 index 0000000..6d059e9 Binary files /dev/null and b/textures/technic_copper_chest_locked.png differ diff --git a/textures/technic_copper_chest_side.png b/textures/technic_copper_chest_side.png new file mode 100644 index 0000000..2c7943f Binary files /dev/null and b/textures/technic_copper_chest_side.png differ diff --git a/textures/technic_copper_chest_top.png b/textures/technic_copper_chest_top.png new file mode 100644 index 0000000..2ab8104 Binary files /dev/null and b/textures/technic_copper_chest_top.png differ diff --git a/textures/technic_copper_dust.png b/textures/technic_copper_dust.png new file mode 100644 index 0000000..9597a2e Binary files /dev/null and b/textures/technic_copper_dust.png differ diff --git a/textures/technic_diamond.png b/textures/technic_diamond.png new file mode 100644 index 0000000..23e6126 Binary files /dev/null and b/textures/technic_diamond.png differ diff --git a/textures/technic_electric_furnace_bottom.png b/textures/technic_electric_furnace_bottom.png new file mode 100644 index 0000000..15fa6de Binary files /dev/null and b/textures/technic_electric_furnace_bottom.png differ diff --git a/textures/technic_electric_furnace_front.png b/textures/technic_electric_furnace_front.png new file mode 100644 index 0000000..755aadf Binary files /dev/null and b/textures/technic_electric_furnace_front.png differ diff --git a/textures/technic_electric_furnace_front_active.png b/textures/technic_electric_furnace_front_active.png new file mode 100644 index 0000000..de7f1f9 Binary files /dev/null and b/textures/technic_electric_furnace_front_active.png differ diff --git a/textures/technic_electric_furnace_side.png b/textures/technic_electric_furnace_side.png new file mode 100644 index 0000000..80cf742 Binary files /dev/null and b/textures/technic_electric_furnace_side.png differ diff --git a/textures/technic_electric_furnace_top.png b/textures/technic_electric_furnace_top.png new file mode 100644 index 0000000..fbadd9a Binary files /dev/null and b/textures/technic_electric_furnace_top.png differ diff --git a/textures/technic_gold_chest_front.png b/textures/technic_gold_chest_front.png new file mode 100644 index 0000000..9bc9615 Binary files /dev/null and b/textures/technic_gold_chest_front.png differ diff --git a/textures/technic_gold_chest_front_black.png b/textures/technic_gold_chest_front_black.png new file mode 100644 index 0000000..6d0fe5e Binary files /dev/null and b/textures/technic_gold_chest_front_black.png differ diff --git a/textures/technic_gold_chest_front_blue.png b/textures/technic_gold_chest_front_blue.png new file mode 100644 index 0000000..7efe651 Binary files /dev/null and b/textures/technic_gold_chest_front_blue.png differ diff --git a/textures/technic_gold_chest_front_brown.png b/textures/technic_gold_chest_front_brown.png new file mode 100644 index 0000000..4f4f34e Binary files /dev/null and b/textures/technic_gold_chest_front_brown.png differ diff --git a/textures/technic_gold_chest_front_cyan.png b/textures/technic_gold_chest_front_cyan.png new file mode 100644 index 0000000..e33d76d Binary files /dev/null and b/textures/technic_gold_chest_front_cyan.png differ diff --git a/textures/technic_gold_chest_front_dark_green.png b/textures/technic_gold_chest_front_dark_green.png new file mode 100644 index 0000000..3088bbf Binary files /dev/null and b/textures/technic_gold_chest_front_dark_green.png differ diff --git a/textures/technic_gold_chest_front_dark_grey.png b/textures/technic_gold_chest_front_dark_grey.png new file mode 100644 index 0000000..0aa03b4 Binary files /dev/null and b/textures/technic_gold_chest_front_dark_grey.png differ diff --git a/textures/technic_gold_chest_front_green.png b/textures/technic_gold_chest_front_green.png new file mode 100644 index 0000000..30da993 Binary files /dev/null and b/textures/technic_gold_chest_front_green.png differ diff --git a/textures/technic_gold_chest_front_grey.png b/textures/technic_gold_chest_front_grey.png new file mode 100644 index 0000000..eae7e69 Binary files /dev/null and b/textures/technic_gold_chest_front_grey.png differ diff --git a/textures/technic_gold_chest_front_magenta.png b/textures/technic_gold_chest_front_magenta.png new file mode 100644 index 0000000..6daed3b Binary files /dev/null and b/textures/technic_gold_chest_front_magenta.png differ diff --git a/textures/technic_gold_chest_front_orange.png b/textures/technic_gold_chest_front_orange.png new file mode 100644 index 0000000..085c102 Binary files /dev/null and b/textures/technic_gold_chest_front_orange.png differ diff --git a/textures/technic_gold_chest_front_pink.png b/textures/technic_gold_chest_front_pink.png new file mode 100644 index 0000000..eada4da Binary files /dev/null and b/textures/technic_gold_chest_front_pink.png differ diff --git a/textures/technic_gold_chest_front_red.png b/textures/technic_gold_chest_front_red.png new file mode 100644 index 0000000..b67da7b Binary files /dev/null and b/textures/technic_gold_chest_front_red.png differ diff --git a/textures/technic_gold_chest_front_violet.png b/textures/technic_gold_chest_front_violet.png new file mode 100644 index 0000000..b62011c Binary files /dev/null and b/textures/technic_gold_chest_front_violet.png differ diff --git a/textures/technic_gold_chest_front_white.png b/textures/technic_gold_chest_front_white.png new file mode 100644 index 0000000..76b5ebf Binary files /dev/null and b/textures/technic_gold_chest_front_white.png differ diff --git a/textures/technic_gold_chest_front_yellow.png b/textures/technic_gold_chest_front_yellow.png new file mode 100644 index 0000000..b0ab9f4 Binary files /dev/null and b/textures/technic_gold_chest_front_yellow.png differ diff --git a/textures/technic_gold_chest_locked.png b/textures/technic_gold_chest_locked.png new file mode 100644 index 0000000..91a8b73 Binary files /dev/null and b/textures/technic_gold_chest_locked.png differ diff --git a/textures/technic_gold_chest_locked_black.png b/textures/technic_gold_chest_locked_black.png new file mode 100644 index 0000000..5a5a568 Binary files /dev/null and b/textures/technic_gold_chest_locked_black.png differ diff --git a/textures/technic_gold_chest_locked_blue.png b/textures/technic_gold_chest_locked_blue.png new file mode 100644 index 0000000..f369ebd Binary files /dev/null and b/textures/technic_gold_chest_locked_blue.png differ diff --git a/textures/technic_gold_chest_locked_brown.png b/textures/technic_gold_chest_locked_brown.png new file mode 100644 index 0000000..a44a273 Binary files /dev/null and b/textures/technic_gold_chest_locked_brown.png differ diff --git a/textures/technic_gold_chest_locked_cyan.png b/textures/technic_gold_chest_locked_cyan.png new file mode 100644 index 0000000..f3ce7b6 Binary files /dev/null and b/textures/technic_gold_chest_locked_cyan.png differ diff --git a/textures/technic_gold_chest_locked_dark_green.png b/textures/technic_gold_chest_locked_dark_green.png new file mode 100644 index 0000000..084dae5 Binary files /dev/null and b/textures/technic_gold_chest_locked_dark_green.png differ diff --git a/textures/technic_gold_chest_locked_dark_grey.png b/textures/technic_gold_chest_locked_dark_grey.png new file mode 100644 index 0000000..629e33c Binary files /dev/null and b/textures/technic_gold_chest_locked_dark_grey.png differ diff --git a/textures/technic_gold_chest_locked_green.png b/textures/technic_gold_chest_locked_green.png new file mode 100644 index 0000000..9ea1818 Binary files /dev/null and b/textures/technic_gold_chest_locked_green.png differ diff --git a/textures/technic_gold_chest_locked_grey.png b/textures/technic_gold_chest_locked_grey.png new file mode 100644 index 0000000..c936d7c Binary files /dev/null and b/textures/technic_gold_chest_locked_grey.png differ diff --git a/textures/technic_gold_chest_locked_magenta.png b/textures/technic_gold_chest_locked_magenta.png new file mode 100644 index 0000000..4c97fa8 Binary files /dev/null and b/textures/technic_gold_chest_locked_magenta.png differ diff --git a/textures/technic_gold_chest_locked_orange.png b/textures/technic_gold_chest_locked_orange.png new file mode 100644 index 0000000..f6d5e90 Binary files /dev/null and b/textures/technic_gold_chest_locked_orange.png differ diff --git a/textures/technic_gold_chest_locked_pink.png b/textures/technic_gold_chest_locked_pink.png new file mode 100644 index 0000000..4248c21 Binary files /dev/null and b/textures/technic_gold_chest_locked_pink.png differ diff --git a/textures/technic_gold_chest_locked_red.png b/textures/technic_gold_chest_locked_red.png new file mode 100644 index 0000000..4bfe5d4 Binary files /dev/null and b/textures/technic_gold_chest_locked_red.png differ diff --git a/textures/technic_gold_chest_locked_violet.png b/textures/technic_gold_chest_locked_violet.png new file mode 100644 index 0000000..c9abe73 Binary files /dev/null and b/textures/technic_gold_chest_locked_violet.png differ diff --git a/textures/technic_gold_chest_locked_white.png b/textures/technic_gold_chest_locked_white.png new file mode 100644 index 0000000..810abb9 Binary files /dev/null and b/textures/technic_gold_chest_locked_white.png differ diff --git a/textures/technic_gold_chest_locked_yellow.png b/textures/technic_gold_chest_locked_yellow.png new file mode 100644 index 0000000..2856165 Binary files /dev/null and b/textures/technic_gold_chest_locked_yellow.png differ diff --git a/textures/technic_gold_chest_side.png b/textures/technic_gold_chest_side.png new file mode 100644 index 0000000..5d5ad0f Binary files /dev/null and b/textures/technic_gold_chest_side.png differ diff --git a/textures/technic_gold_chest_top.png b/textures/technic_gold_chest_top.png new file mode 100644 index 0000000..f9c8fec Binary files /dev/null and b/textures/technic_gold_chest_top.png differ diff --git a/textures/technic_gold_dust.png b/textures/technic_gold_dust.png new file mode 100644 index 0000000..00c1a2f Binary files /dev/null and b/textures/technic_gold_dust.png differ diff --git a/textures/technic_grinder_front.png b/textures/technic_grinder_front.png new file mode 100644 index 0000000..a28dbc1 Binary files /dev/null and b/textures/technic_grinder_front.png differ diff --git a/textures/technic_grinder_side.png b/textures/technic_grinder_side.png new file mode 100644 index 0000000..af562f2 Binary files /dev/null and b/textures/technic_grinder_side.png differ diff --git a/textures/technic_grinder_top.png b/textures/technic_grinder_top.png new file mode 100644 index 0000000..b074e13 Binary files /dev/null and b/textures/technic_grinder_top.png differ diff --git a/textures/technic_iron_chest_front.png b/textures/technic_iron_chest_front.png new file mode 100644 index 0000000..79d5b49 Binary files /dev/null and b/textures/technic_iron_chest_front.png differ diff --git a/textures/technic_iron_chest_locked.png b/textures/technic_iron_chest_locked.png new file mode 100644 index 0000000..6229487 Binary files /dev/null and b/textures/technic_iron_chest_locked.png differ diff --git a/textures/technic_iron_chest_side.png b/textures/technic_iron_chest_side.png new file mode 100644 index 0000000..e12daa5 Binary files /dev/null and b/textures/technic_iron_chest_side.png differ diff --git a/textures/technic_iron_chest_top.png b/textures/technic_iron_chest_top.png new file mode 100644 index 0000000..da1ab7b Binary files /dev/null and b/textures/technic_iron_chest_top.png differ diff --git a/textures/technic_iron_dust.png b/textures/technic_iron_dust.png new file mode 100644 index 0000000..6038df6 Binary files /dev/null and b/textures/technic_iron_dust.png differ diff --git a/textures/technic_laser_beam.png b/textures/technic_laser_beam.png new file mode 100644 index 0000000..4814a9b Binary files /dev/null and b/textures/technic_laser_beam.png differ diff --git a/textures/technic_lv_cable.png b/textures/technic_lv_cable.png new file mode 100644 index 0000000..6155c32 Binary files /dev/null and b/textures/technic_lv_cable.png differ diff --git a/textures/technic_lv_cable_wield.png b/textures/technic_lv_cable_wield.png new file mode 100644 index 0000000..eb8abe2 Binary files /dev/null and b/textures/technic_lv_cable_wield.png differ diff --git a/textures/technic_machine_bottom.png b/textures/technic_machine_bottom.png new file mode 100644 index 0000000..48a47b0 Binary files /dev/null and b/textures/technic_machine_bottom.png differ diff --git a/textures/technic_mineral_diamond.png b/textures/technic_mineral_diamond.png new file mode 100644 index 0000000..2d91505 Binary files /dev/null and b/textures/technic_mineral_diamond.png differ diff --git a/textures/technic_mining_laser_mk1.png b/textures/technic_mining_laser_mk1.png new file mode 100644 index 0000000..acde392 Binary files /dev/null and b/textures/technic_mining_laser_mk1.png differ diff --git a/textures/technic_mithril_chest_front.png b/textures/technic_mithril_chest_front.png new file mode 100644 index 0000000..9f7ca7e Binary files /dev/null and b/textures/technic_mithril_chest_front.png differ diff --git a/textures/technic_mithril_chest_locked.png b/textures/technic_mithril_chest_locked.png new file mode 100644 index 0000000..abff384 Binary files /dev/null and b/textures/technic_mithril_chest_locked.png differ diff --git a/textures/technic_mithril_chest_side.png b/textures/technic_mithril_chest_side.png new file mode 100644 index 0000000..0763511 Binary files /dev/null and b/textures/technic_mithril_chest_side.png differ diff --git a/textures/technic_mithril_chest_top.png b/textures/technic_mithril_chest_top.png new file mode 100644 index 0000000..2429576 Binary files /dev/null and b/textures/technic_mithril_chest_top.png differ diff --git a/textures/technic_mithril_dust.png b/textures/technic_mithril_dust.png new file mode 100644 index 0000000..6afc44a Binary files /dev/null and b/textures/technic_mithril_dust.png differ diff --git a/textures/technic_music_player_bottom.png b/textures/technic_music_player_bottom.png new file mode 100644 index 0000000..bd8fd55 Binary files /dev/null and b/textures/technic_music_player_bottom.png differ diff --git a/textures/technic_music_player_side.png b/textures/technic_music_player_side.png new file mode 100644 index 0000000..6c34fea Binary files /dev/null and b/textures/technic_music_player_side.png differ diff --git a/textures/technic_music_player_top.png b/textures/technic_music_player_top.png new file mode 100644 index 0000000..0d34563 Binary files /dev/null and b/textures/technic_music_player_top.png differ diff --git a/textures/technic_power_meter.png b/textures/technic_power_meter.png new file mode 100644 index 0000000..f1e5120 Binary files /dev/null and b/textures/technic_power_meter.png differ diff --git a/textures/technic_power_meter_bg.png b/textures/technic_power_meter_bg.png new file mode 100644 index 0000000..9667cda Binary files /dev/null and b/textures/technic_power_meter_bg.png differ diff --git a/textures/technic_power_meter_fg.png b/textures/technic_power_meter_fg.png new file mode 100644 index 0000000..7f2dde8 Binary files /dev/null and b/textures/technic_power_meter_fg.png differ diff --git a/textures/technic_rebar.png b/textures/technic_rebar.png new file mode 100644 index 0000000..16d1fc5 Binary files /dev/null and b/textures/technic_rebar.png differ diff --git a/textures/technic_silver_chest_front.png b/textures/technic_silver_chest_front.png new file mode 100644 index 0000000..fe5ce2c Binary files /dev/null and b/textures/technic_silver_chest_front.png differ diff --git a/textures/technic_silver_chest_locked.png b/textures/technic_silver_chest_locked.png new file mode 100644 index 0000000..0f8b1f0 Binary files /dev/null and b/textures/technic_silver_chest_locked.png differ diff --git a/textures/technic_silver_chest_side.png b/textures/technic_silver_chest_side.png new file mode 100644 index 0000000..3a2ed4a Binary files /dev/null and b/textures/technic_silver_chest_side.png differ diff --git a/textures/technic_silver_chest_top.png b/textures/technic_silver_chest_top.png new file mode 100644 index 0000000..353a11c Binary files /dev/null and b/textures/technic_silver_chest_top.png differ diff --git a/textures/technic_silver_dust.png b/textures/technic_silver_dust.png new file mode 100644 index 0000000..947e059 Binary files /dev/null and b/textures/technic_silver_dust.png differ diff --git a/textures/technic_solar_panel_side.png b/textures/technic_solar_panel_side.png new file mode 100644 index 0000000..b22447e Binary files /dev/null and b/textures/technic_solar_panel_side.png differ diff --git a/textures/technic_solar_panel_top.png b/textures/technic_solar_panel_top.png new file mode 100644 index 0000000..492764b Binary files /dev/null and b/textures/technic_solar_panel_top.png differ diff --git a/textures/technic_tin_dust.png b/textures/technic_tin_dust.png new file mode 100644 index 0000000..9bdc2db Binary files /dev/null and b/textures/technic_tin_dust.png differ diff --git a/textures/technic_workshop_bottom.png b/textures/technic_workshop_bottom.png new file mode 100644 index 0000000..bd8fd55 Binary files /dev/null and b/textures/technic_workshop_bottom.png differ diff --git a/textures/technic_workshop_side.png b/textures/technic_workshop_side.png new file mode 100644 index 0000000..9e3e7a7 Binary files /dev/null and b/textures/technic_workshop_side.png differ diff --git a/textures/technic_workshop_top.png b/textures/technic_workshop_top.png new file mode 100644 index 0000000..feae141 Binary files /dev/null and b/textures/technic_workshop_top.png differ diff --git a/tool_workshop.lua b/tool_workshop.lua new file mode 100644 index 0000000..86130ff --- /dev/null +++ b/tool_workshop.lua @@ -0,0 +1,93 @@ +minetest.register_alias("tool_workshop", "technic:tool_workshop") +minetest.register_craft({ + output = 'technic:tool_workshop', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:wood', 'technic:diamond', 'default:wood'}, + {'default:stone', 'moreores:copper_ingot', 'default:stone'}, + } +}) + +minetest.register_craftitem("technic:tool_workshop", { + description = "Tool Workshop", + stack_max = 99, +}) + +workshop_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "list[current_name;src;3,1;1,1;]".. + "label[0,0;Tool Workshop]".. + "label[1,3;Power level]".. + "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(), + technic_power_machine=1, + internal_EU_buffer=0; + internal_EU_buffer_size=2000; + + 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_float("internal_EU_buffer", 1) + meta:set_float("internal_EU_buffer_size", 2000) + 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 + 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 charge= meta:get_float("internal_EU_buffer") + local max_charge= meta:get_float("internal_EU_buffer_size") + local load_step=2000 + local load_cost=200 + local inv = meta:get_inventory() + if inv:is_empty("src")==false then + srcstack = inv:get_stack("src", 1) + src_item=srcstack:to_table() + local load1=tonumber((src_item["wear"])) + if charge>load_cost then + if load1>1 then + if load1-load_step<0 then load_step=load1 load1=1 + else load1=load1-load_step end + charge=charge-load_cost + src_item["wear"]=tostring(load1) + inv:set_stack("src", 1, src_item) + end + end + end + + meta:set_float("internal_EU_buffer",charge) + + + local load = math.floor((charge/max_charge)*100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "list[current_name;src;3,1;1,1;]".. + "label[0,0;Tool Workshop]".. + "label[1,3;Power level]".. + "list[current_player;main;0,5;8,4;]") + end +}) \ No newline at end of file diff --git a/water.lua b/water.lua new file mode 100644 index 0000000..6ddaa46 --- /dev/null +++ b/water.lua @@ -0,0 +1,588 @@ +minetest.register_alias("battery", "technic:battery") +minetest.register_alias("battery_box", "technic:battery_box") +minetest.register_alias("electric_furnace", "technic:electric_furnace") + + +minetest.register_craft({ + output = 'technic:battery 1', + recipe = { + {'default:wood', 'moreores:copper_ingot', 'default:wood'}, + {'default:wood', 'moreores:tin_ingot', 'default:wood'}, + {'default:wood', 'moreores:copper_ingot', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'technic:battery_box 1', + recipe = { + {'technic:battery', 'default:wood', 'technic:battery'}, + {'technic:battery', 'moreores:copper_ingot', 'technic:battery'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + } +}) + +minetest.register_craft({ + output = 'technic:electric_furnace', + recipe = { + {'default:brick', 'default:brick', 'default:brick'}, + {'default:brick', '', 'default:brick'}, + {'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'}, + } +}) + + +--minetest.register_craftitem("technic:battery", { +-- description = "Recharcheable battery", +-- inventory_image = "technic_battery.png", +-- stack_max = 1, +--}) + +minetest.register_tool("technic:battery", +{description = "RE Battery", +inventory_image = "technic_battery.png", +energy_charge = 0, +tool_capabilities = {max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}}) + +minetest.register_craftitem("technic:battery_box", { + description = "Battery box", + stack_max = 99, +}) + + + +battery_box_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "list[current_name;src;3,1;1,1;]".. + "image[4,1;1,1;technic_battery_reload.png]".. + "list[current_name;dst;5,1;1,1;]".. + "label[0,0;Battery box]".. + "label[3,0;Charge]".. + "label[5,0;Discharge]".. + "label[1,3;Power level]".. + "list[current_player;main;0,5;8,4;]" + +minetest.register_node("technic:battery_box", { + description = "Battery box", + tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png", "technic_battery_box_side.png", + "technic_battery_box_side.png", "technic_battery_box_side.png", "technic_battery_box_side.png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + technic_power_machine=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("infotext", "Battery box") + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", battery_box_formspec) + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 1) + battery_charge = 0 + max_charge = 60000 + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +electric_furnace_formspec = + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png]".. + "list[current_name;src;3,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "label[0,0;Electric Furnace]".. + "label[1,3;Power level]" + +minetest.register_node("technic:electric_furnace", { + description = "Electric furnace", + tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png", + "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"}, + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + technic_power_machine=1, + internal_EU_buffer=0; + interal_EU_buffer_size=2000; + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("infotext", "Electric furnace") + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + local EU_used = 0 + local furnace_is_cookin = 0 + local cooked = nil + meta:set_float("internal_EU_buffer",0) + meta:set_float("internal_EU_buffer_size",2000) + + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +minetest.register_node("technic:electric_furnace_active", { + description = "Electric Furnace", + tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png", + "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"}, + paramtype2 = "facedir", + light_source = 8, + drop = "technic:electric_furnace", + groups = {cracky=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + internal_EU_buffer=0; + interal_EU_buffer_size=2000; + technic_power_machine=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_float("technic_power_machine", 1) + meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("infotext", "Electric furnace"); + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + local EU_used = 0 + local furnace_is_cookin = 0 + local cooked = nil + end, + can_dig = function(pos,player) + local meta = minetest.env:get_meta(pos); + local inv = meta:get_inventory() + if not inv:is_empty("dst") then + return false + elseif not inv:is_empty("src") then + return false + end + return true + end, +}) + +minetest.register_abm({ + nodenames = {"technic:electric_furnace","technic:electric_furnace_active"}, + interval = 1, + chance = 1, + + action = function(pos, node, active_object_count, active_object_count_wider) + + local meta = minetest.env:get_meta(pos) + internal_EU_buffer=meta:get_float("internal_EU_buffer") + internal_EU_buffer_size=meta:get_float("internal_EU_buffer") + local load = math.floor(internal_EU_buffer/2000 * 100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "list[current_name;src;3,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "label[0,0;Electric Furnace]".. + "label[1,3;Power level]") + + local inv = meta:get_inventory() + + local furnace_is_cookin = meta:get_float("furnace_is_cookin") + + + local srclist = inv:get_list("src") + local cooked=nil + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + end + + + if (furnace_is_cookin == 1) then + if internal_EU_buffer>=150 then + internal_EU_buffer=internal_EU_buffer-150; + meta:set_float("internal_EU_buffer",internal_EU_buffer) + meta:set_float("src_time", meta:get_float("src_time") + 3) + if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then + -- check if there's room for output in "dst" list + if inv:room_for_item("dst",cooked.item) then + -- Put result in "dst" list + inv:add_item("dst", cooked.item) + -- take stuff from "src" list + srcstack = inv:get_stack("src", 1) + srcstack:take_item() + inv:set_stack("src", 1, srcstack) + else + print("Furnace inventory full!") + end + meta:set_string("src_time", 0) + end + end + end + + + + + if srclist then + cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + if cooked.time>0 then + hacky_swap_node(pos,"technic:electric_furnace_active") + meta:set_string("infotext","Furnace active") + meta:set_string("furnace_is_cookin",1) + -- meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("src_time", 0) + return + end + + end + + hacky_swap_node(pos,"technic:electric_furnace") + meta:set_string("infotext","Furnace inactive") + meta:set_string("furnace_is_cookin",0) + -- meta:set_string("formspec", electric_furnace_formspec) + meta:set_string("src_time", 0) + + +end, +}) + + + + +function take_EU_from_net(pos, EU_to_take) + local meta = minetest.env:get_meta(pos) + local pos1=pos + pos1.z=pos1.z +1 + local meta1 = minetest.env:get_meta(pos1) + charge=meta1:get_float("battery_charge") + charge=charge - EU_to_take + meta1:set_float("battery_charge",charge) +end + + LV_nodes_visited = {} + +function 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 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 + +minetest.register_abm({ + nodenames = {"technic:battery_box"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.env:get_meta(pos) + charge= meta:get_float("battery_charge") + max_charge= 60000 + + local inv = meta:get_inventory() + if inv:is_empty("src")==false then + srcstack = inv:get_stack("src", 1) + src_item=srcstack:to_table() + if src_item["name"]== "technic:battery" then + local load1=tonumber((src_item["wear"])) + load1=get_RE_item_load(load1,10000) + load_step=1000 + if load1<10000 and charge>0 then + if charge-load_step<0 then load_step=charge end + if load1+load_step>10000 then load_step=10000-load1 end + load1=load1+load_step + charge=charge-load_step + + load1=set_RE_item_load(load1,10000) + src_item["wear"]=tostring(load1) + inv:set_stack("src", 1, src_item) + end + end + end + meta:set_float("battery_charge",charge) + + + if inv:is_empty("src")==false then + srcstack = inv:get_stack("src", 1) + src_item=srcstack:to_table() + if src_item["name"]== "technic:laser_mk1" then + local load1=tonumber((src_item["wear"])) + load1=get_RE_item_load(load1,40000) + load_step=1000 + if load1<40000 and charge>0 then + if charge-load_step<0 then load_step=charge end + if load1+load_step>40000 then load_step=40000-load1 end + load1=load1+load_step + charge=charge-load_step + load1=set_RE_item_load(load1,40000) + src_item["wear"]=tostring(load1) + inv:set_stack("src", 1, src_item) + end + end + end + meta:set_float("battery_charge",charge) + + + if inv:is_empty("dst") == false then + srcstack = inv:get_stack("dst", 1) + src_item=srcstack:to_table() + if src_item["name"]== "technic:battery" then + local load1=tonumber((src_item["wear"])) + load1=get_RE_item_load(load1,10000) + load_step=1000 + if load1>0 and chargemax_charge then load_step=max_charge-charge end + if load1-load_step<0 then load_step=load1 end + load1=load1-load_step + charge=charge+load_step + + load1=set_RE_item_load(load1,10000) + src_item["wear"]=tostring(load1) + inv:set_stack("dst", 1, src_item) + end + end + end + + + meta:set_float("battery_charge",charge) + meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge); + + local load = math.floor(charge/60000 * 100) + meta:set_string("formspec", + "invsize[8,9;]".. + "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. + (load)..":technic_power_meter_fg.png]".. + "list[current_name;src;3,1;1,1;]".. + "image[4,1;1,1;technic_battery_reload.png]".. + "list[current_name;dst;5,1;1,1;]".. + "label[0,0;Battery box]".. + "label[3,0;Charge]".. + "label[5,0;Discharge]".. + "label[1,3;Power level]".. + "list[current_player;main;0,5;8,4;]") + + local pos1={} + + pos1.y=pos.y-1 + pos1.x=pos.x + pos1.z=pos.z + + + meta1 = minetest.env:get_meta(pos1) + if meta1:get_float("cablelike")~=1 then return end + + local LV_nodes = {} + local PR_nodes = {} + local RE_nodes = {} + + LV_nodes[1]={} + LV_nodes[1].x=pos1.x + LV_nodes[1].y=pos1.y + LV_nodes[1].z=pos1.z + LV_nodes[1].visited=false + + +table_index=1 + repeat + check_LV_node (PR_nodes,RE_nodes,LV_nodes,table_index) + table_index=table_index+1 + if LV_nodes[table_index]==nil then break end + until false + + +local pos1={} +i=1 + repeat + if PR_nodes[i]==nil then break end + pos1.x=PR_nodes[i].x + pos1.y=PR_nodes[i].y + pos1.z=PR_nodes[i].z + local meta1 = minetest.env:get_meta(pos1) + local active=meta1:get_float("active") + if active==1 then charge=charge+80 end + i=i+1 + until false + +if charge>max_charge then charge=max_charge end + +i=1 + repeat + if RE_nodes[i]==nil then break end + pos1.x=RE_nodes[i].x -- loading all conected machines buffers + pos1.y=RE_nodes[i].y + pos1.z=RE_nodes[i].z + local meta1 = minetest.env:get_meta(pos1) + local internal_EU_buffer=meta1:get_float("internal_EU_buffer") + local internal_EU_buffer_size=meta1:get_float("internal_EU_buffer_size") + + local charge_to_give=200 + if internal_EU_buffer+charge_to_give>internal_EU_buffer_size then + charge_to_give=internal_EU_buffer_size-internal_EU_buffer + end + if charge-charge_to_give<0 then charge_to_give=charge end + + internal_EU_buffer=internal_EU_buffer+charge_to_give + meta1:set_float("internal_EU_buffer",internal_EU_buffer) + charge=charge-charge_to_give; + + i=i+1 + until false + + meta:set_float("battery_charge",charge) + meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge); + + +end +}) + +function add_new_cable_node (LV_nodes,pos1) +local i=1 + repeat + if LV_nodes[i]==nil then break end + if pos1.x==LV_nodes[i].x and pos1.y==LV_nodes[i].y and pos1.z==LV_nodes[i].z then return false end + i=i+1 + until false +LV_nodes[i]={} +LV_nodes[i].x=pos1.x +LV_nodes[i].y=pos1.y +LV_nodes[i].z=pos1.z +LV_nodes[i].visited=false +return true +end + +function check_LV_node (PR_nodes,RE_nodes,LV_nodes,i) + local pos1={} + pos1.x=LV_nodes[i].x + pos1.y=LV_nodes[i].y + pos1.z=LV_nodes[i].z + LV_nodes[i].visited=true + new_node_added=false + + pos1.x=pos1.x+1 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.x=pos1.x-2 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.x=pos1.x+1 + + pos1.y=pos1.y+1 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.y=pos1.y-2 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.y=pos1.y+1 + + pos1.z=pos1.z+1 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.z=pos1.z-2 + check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) + pos1.z=pos1.z+1 +return new_node_added +end + +function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) +meta = minetest.env:get_meta(pos1) +if meta:get_float("cablelike")==1 then new_node_added=add_new_cable_node(LV_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:solar_panel" then new_node_added=add_new_cable_node(PR_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:electric_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:electric_furnace_active" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:tool_workshop" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:music_player" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +if minetest.env:get_node(pos1).name == "technic:grinder" then new_node_added=add_new_cable_node(RE_nodes,pos1) end +end + + +function get_connected_charge (charge,pos1) + local charge1=0 + local meta={} + if minetest.env:get_node(pos1).name == "technic:battery_box" then + print ("found batbox") + meta = minetest.env:get_meta(pos1) + return meta:get_float("cable_OUT") + end + + if minetest.env:get_node(pos1).name == "technic:lv_cable" then + meta = minetest.env:get_meta(pos1) + charge1=meta:get_float("cable_OUT") + if charge1>charge then + charge=charge1 + end + end +return charge +end + +minetest.register_node("technic:solar_panel", { + tiles = {"technic_solar_panel_top.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png", + "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + description="Solar Panel", + active = false, + technic_power_machine=1, + drawtype = "nodebox", + paramtype = "light", + is_ground_content = true, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_float("technic_power_machine", 1) + meta:set_string("infotext", "Solar Panel") + meta:set_float("active", false) + end, +}) + +minetest.register_craft({ + output = 'technic:solar_panel 1', + recipe = { + {'default:sand', 'default:sand','default:sand'}, + {'default:sand', 'moreores:copper_ingot','default:sand'}, + {'default:sand', 'default:sand','default:sand'}, + + } +}) + +minetest.register_abm( + {nodenames = {"technic:solar_panel"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + + local pos1={} + pos1.y=pos.y+1 + pos1.x=pos.x + pos1.z=pos.z + + local light = minetest.env:get_node_light(pos1, nil) + local meta = minetest.env:get_meta(pos) + if light == nil then light = 0 end + if light >= 12 then + meta:set_string("infotext", "Solar Panel is active ") + meta:set_float("active",1) + else + meta:set_string("infotext", "Solar Panel is inactive"); + meta:set_float("active",0) + end + end, +}) \ No newline at end of file diff --git a/wires.lua b/wires.lua new file mode 100644 index 0000000..039dda6 --- /dev/null +++ b/wires.lua @@ -0,0 +1,400 @@ +--LV cable node boxes + + +minetest.register_alias("lv_cable", "technic:lv_cable") + +minetest.register_craft({ + output = 'technic:lv_cable 6', + recipe = { + {'moreores:copper_ingot', 'moreores:copper_ingot', 'moreores: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", + 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 +