Add sun generator and begin for electro tools

This commit is contained in:
ConfidentOwl 2023-05-15 20:02:44 +03:00
parent 7d416e5f29
commit ce5195e1b5
10 changed files with 192 additions and 4 deletions

View File

@ -5,6 +5,36 @@ local energy_hatch_table ={
{"base","Base",32,64000,"#575757","owl_tech:copper_electro_wire","steel"}
}
for i, value in ipairs(energy_hatch_table) do
local function set_formspect_battery(meta)
local charge_curent = owl_tech:get_charge(meta)
local charge = owl_tech:get_charge_max(meta)
local formspec = "size[9,8.75]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Battery"))).."]"..
"label[0,1.5;"..minetest.formspec_escape(minetest.colorize("#313131", ("Charge --"..charge_curent.."/"..charge))).."]"..
"list[context;input_in;2.5,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,1.5,1,1)..
"list[context;dst;3.5,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(3.5,1.5,1,1)..
"list[context;input_in_add;2.5,3.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,3.5,1,1)..
"list[context;dst_add;3.5,3.5;1,1;]"..
mcl_formspec.get_itemslot_bg(3.5,3.5,1,1)..
"listring[context;dst]"..
"listring[current_player;main]"..
"listring[current_player;main]"..
"listring[context;input_in]"..
"listring[context;input_in_add]"..
"listring[context;dst_add]"..
"listring[current_player;main]"
meta:set_string("formspec", formspec)
end
minetest.register_node("owl_tech:"..energy_hatch_table[i][1].."_battery", {
description = S(energy_hatch_table[i][2].." baattery"),
_doc_items_longdesc = S("Contains electricity tire"..i), --
@ -27,13 +57,30 @@ for i, value in ipairs(energy_hatch_table) do
local meta = minetest.get_meta(pos)
owl_tech.set_mashine_tire(meta,i+1)
owl_tech:add_electro(pos,energy_hatch_table[i][3],energy_hatch_table[i][4])
local inv = meta:get_inventory()
inv:set_size("input_in", 1) --for input
inv:set_size("dst", 1) --for input
inv:set_size("input_in_add", 1) --for output
inv:set_size("dst_add", 1) --for output
local timer =minetest.get_node_timer(pos)
meta:set_string("infotext",owl_tech:get_charge(meta).."/"..owl_tech:get_charge_max(meta))
set_formspect_battery(meta)
timer:start(0.2)
end,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local cell_input_1 = inv:get_stack("input_in", 1)
local cell_output_1 = inv:get_stack("dst", 1)
local cell_input_2 = inv:get_stack("input_in_add", 1)
local cell_output_2 = inv:get_stack("dst_add", 1)
if not cell_input_1:is_empty() and minetest.get_item_group(cell_input_1:get_name(), "electro_tool") and owl_tech:get_charge(meta)>=owl_tech:get_charge_max(meta) then
minetest.chat_send_all(cell_input_1:get_wear())
end
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})).name,"owl_tech_electro_wire")>0
and owl_tech:get_charge_max(meta)-owl_tech:get_charge(meta)>=owl_tech:get_voltage(meta) then --get from wire electro
local meta_up = minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z})
@ -49,6 +96,7 @@ for i, value in ipairs(energy_hatch_table) do
end
end
meta:set_string("infotext",owl_tech:get_charge(meta).."/"..owl_tech:get_charge_max(meta))
set_formspect_battery(meta)
timer:start(0.2)
end
})

View File

@ -3,3 +3,4 @@ local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
dofile(path .. "/electro_generator/small_turbins.lua")
dofile(path .. "/electro_generator/sun_generator.lua")

View File

@ -0,0 +1,103 @@
local S = minetest.get_translator(minetest.get_current_modname())
local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
--[[
1)name 2)Name 3)material mame 4)add_coponent ,5)circuit 6)fluid input 7)energy modif 8)Voltage 9)max-electro
]]
local small_turbins_conf={
{"base_sun_generator","Base sun generator","steel","owl_tech:gold_stick","owl_tech:circuit_tire_1",2,32,16000},
}
for i = 1, #small_turbins_conf, 1 do
local function set_formspect_base_steam_turbine(meta)
local fluid_1_name = owl_tech.get_pull_fluid_name(meta,1)
local fluid_1_volume = owl_tech.get_pull_volume(meta,1)
local max_charge = owl_tech:get_charge_max(meta)
local curent_charge = owl_tech:get_charge(meta)
local voltage = owl_tech:get_voltage(meta)
local formspec = "size[9,8.75]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S(small_turbins_conf[i][2]))).."]"..
"label[0,2.5;"..minetest.formspec_escape(minetest.colorize("#313131", (max_charge.."--"..curent_charge.."--"..voltage))).."]"..
"list[context;battari_slot;2.5,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,2.5,1,1)..
"label[0,1.5;"..minetest.formspec_escape(minetest.colorize("#313131", (fluid_1_name.."--"..fluid_1_volume))).."]"..
"listring[current_player;main]"..
"listring[context;battari_slot]"..
"listring[current_player;main]"..
"listring[current_player;main]"
meta:set_string("formspec", formspec)
end
minetest.register_node("owl_tech:"..small_turbins_conf[i][1].."sun_gen", {
description = S(small_turbins_conf[i][2]),
_doc_items_longdesc = S("Generate electro from sun"),-- owl_tech_base_electro_turbine.png
tiles = {
"(owl_tech_base_meshanism_side.png^[colorize:#575757:128)^owl_tech_base_solat_panel.png",
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
"owl_tech_base_meshanism_side.png^[colorize:#575757:128",
},
is_ground_content = false,
stack_max = 64,
groups = {pickaxey=2,owl_tech_electro_gen=1 ,fluid_in=1,fuel=1,dst=1 ,owl_tech_generator=1},
sounds = mcl_sounds.node_sound_metal_defaults(),
paramtype2 = "facedir",
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
owl_tech:add_electro(pos,small_turbins_conf[i][7],small_turbins_conf[i][8])
set_formspect_base_steam_turbine(meta)
local timer =minetest.get_node_timer(pos)
local inv = meta:get_inventory()
inv:set_size("battari_slot", 1) ---Can charge items in slot WIP
timer:start(0.2)
end,
on_timer = function(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("battari_slot", 1)
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, minetest.get_timeofday())>8 and minetest.get_timeofday()>0.25 and minetest.get_timeofday()<0.75 then
if owl_tech:get_charge_max(meta)>=owl_tech:get_charge(meta)+(owl_tech:get_voltage(meta)/16) then
owl_tech:set_charge(meta,owl_tech:get_charge(meta)+(owl_tech:get_voltage(meta)/16))
end
end
if owl_tech:get_charge_max(meta)-owl_tech:get_charge(meta)>owl_tech:get_voltage(meta)*small_turbins_conf[i][6] and owl_tech.get_pull_volume(meta,1)>=owl_tech:get_voltage(meta) then
owl_tech.set_pull_volume(meta,1, owl_tech.get_pull_volume(meta,1)-owl_tech:get_voltage(meta) )
owl_tech:set_charge(meta,owl_tech:get_charge(meta)+owl_tech:get_voltage(meta)*small_turbins_conf[i][6])
end
if minetest.get_item_group((minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})).name,"owl_tech_electro_wire")>0
and owl_tech:get_charge(meta)-owl_tech:get_voltage(meta)>=0 then --Send to wire electro
local meta_up = minetest.get_meta({x=pos.x,y=pos.y-1,z=pos.z})
if owl_tech:get_charge(meta_up)+owl_tech:get_voltage(meta_up)<=owl_tech:get_charge_max(meta_up) and owl_tech:get_voltage(meta)==owl_tech:get_voltage(meta_up) then
owl_tech.send_electro_from_wire_in_pos(meta,{x=pos.x,y=pos.y-1,z=pos.z})
end
end
set_formspect_base_steam_turbine(meta)
timer:start(0.2)
end
})
--Crafte bronze boiler
minetest.register_craft({
type = "shaped",
output = "owl_tech:"..small_turbins_conf[i][1].."sun_gen",
recipe = {
{"owl_tech:"..small_turbins_conf[i][3].."_plate",small_turbins_conf[i][4],"owl_tech:"..small_turbins_conf[i][3].."_plate"},
{small_turbins_conf[i][4],"owl_tech:"..small_turbins_conf[i][3].."_frames",small_turbins_conf[i][4]},
{"owl_tech:"..small_turbins_conf[i][3].."_plate",small_turbins_conf[i][5],"owl_tech:"..small_turbins_conf[i][3].."_plate"}
}
})
end

View File

@ -12,7 +12,7 @@ minetest.register_node("owl_tech:copper_electro_wire",{
stack_max = 64,
sunlight_propagates = true,
walkable = true,
groups = {owl_tech_electro_wire=1},
groups = {handy = 1 , owl_tech_electro_wire = 1},
drawtype = "nodebox",
node_box = {
type = "connected",

View File

@ -313,7 +313,7 @@ for i = 1, #table_all_machines, 1 do
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.25,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Stean sieve"))).."]"..
"label[2.25,0;"..minetest.formspec_escape(minetest.colorize("#313131", S( table_all_machines[i][1].." Siev"))).."]"..
"list[context;input_in;2.5,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,2.5,1,1)..
"list[context;dst;5.5,1.5;1,1;]"..

View File

@ -12,6 +12,7 @@ local function set_formspect_tank(meta)
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Tank"))).."]"..
"label[0,1.5;"..minetest.formspec_escape(minetest.colorize("#313131", (fluid_1_name.."--"..fluid_1_volume))).."]"..
"list[context;input_in;2.5,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,1.5,1,1)..
"list[context;dst;3.5,1.5;1,1;]"..

View File

@ -33,7 +33,8 @@ local function set_formspect_tank(meta)
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Tank"))).."]"..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Water Concetrator"))).."]"..
"label[0,1.5;"..minetest.formspec_escape(minetest.colorize("#313131", (fluid_1_name.."--"..fluid_1_volume))).."]"..
"list[context;input_in;2.5,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.5,1.5,1,1)..
"list[context;dst;3.5,1.5;1,1;]"..

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

32
tools/electro_tools.lua Normal file
View File

@ -0,0 +1,32 @@
local S = minetest.get_translator(minetest.get_current_modname())
local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
minetest.register_tool("owl_tech:base_drill", {
description = S("Base drill"),
_doc_items_longdesc = "Pick from owl tech",
inventory_image = "owl_tech_base_drill.png",
wield_scale = mcl_vars.tool_wield_scale,
groups = { tool=1, pickaxe=1, dig_speed_class=4, enchantability=14 ,electro_tool=1},
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
max_drop_level=4,
damage_groups = {fleshy=4},
punch_attack_uses = (16),
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { speed = 6, level = 4, uses = 16*2}
},
})
minetest.register_craft({
type = "shaped",
output ="owl_tech:base_drill",
recipe = {
{"owl_tech:steel_plate","owl_tech:tin_plate","owl_tech:steel_plate"},
{"owl_tech:bronze_plate","owl_tech:circuit_tire_1","owl_tech:tin_plate"},
{"owl_tech:circuit_tire_1","owl_tech:bronze_plate","owl_tech:steel_plate"}
}
})

View File

@ -4,6 +4,8 @@ local S = minetest.get_translator(minetest.get_current_modname())
local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
dofile(minetest.get_modpath("owl_tech") .. "/tools/electro_tools.lua") --electro tools load
--Work hammer
minetest.register_craftitem("owl_tech:work_hammer", {
description = S("Work hammer"),