This commit is contained in:
Maciej Kasatkin 2012-08-21 07:18:33 +02:00
commit 167434085c
111 changed files with 3733 additions and 0 deletions

22
.gitattributes vendored Normal file
View File

@ -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

163
.gitignore vendored Normal file
View File

@ -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

74
concrete.lua Normal file
View File

@ -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(),
})

162
copper_chest.lua Normal file
View File

@ -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,
})

7
depends.txt Normal file
View File

@ -0,0 +1,7 @@
default
moreores
stairs
flowers
dye

40
dyes.lua Normal file
View File

@ -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",
})

588
electric.lua Normal file
View File

@ -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 charge<max_charge then
if charge+load_step>max_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,
})

452
gold_chest.lua Normal file
View File

@ -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

236
grinder.lua Normal file
View File

@ -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

55
init.lua Normal file
View File

@ -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

151
iron_chest.lua Normal file
View File

@ -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,
})

153
mining_laser_mk1.lua Normal file
View File

@ -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

145
mithril_chest.lua Normal file
View File

@ -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,
})

124
music_player.lua Normal file
View File

@ -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
})

60
ores.lua Normal file
View File

@ -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)

197
silver_chest.lua Normal file
View File

@ -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,
})

23
solar.lua Normal file
View File

@ -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,
})

BIN
sounds/technic_laser.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

BIN
textures/technic_rebar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Some files were not shown because too many files have changed in this diff Show More