Browse Source

upload

pull/2/head
Maciej Kasatkin 8 years ago
commit
167434085c
100 changed files with 2652 additions and 0 deletions
  1. +22
    -0
      .gitattributes
  2. +163
    -0
      .gitignore
  3. +74
    -0
      concrete.lua
  4. +162
    -0
      copper_chest.lua
  5. +7
    -0
      depends.txt
  6. +40
    -0
      dyes.lua
  7. +588
    -0
      electric.lua
  8. +452
    -0
      gold_chest.lua
  9. +236
    -0
      grinder.lua
  10. +55
    -0
      init.lua
  11. +151
    -0
      iron_chest.lua
  12. +153
    -0
      mining_laser_mk1.lua
  13. +145
    -0
      mithril_chest.lua
  14. +124
    -0
      music_player.lua
  15. +60
    -0
      ores.lua
  16. +197
    -0
      silver_chest.lua
  17. +23
    -0
      solar.lua
  18. BIN
      sounds/technic_laser.ogg
  19. BIN
      textures/technic_battery.png
  20. BIN
      textures/technic_battery_box_bottom.png
  21. BIN
      textures/technic_battery_box_side.png
  22. BIN
      textures/technic_battery_box_top.png
  23. BIN
      textures/technic_battery_reload.png
  24. BIN
      textures/technic_coal_dust.png
  25. BIN
      textures/technic_concrete_block.png
  26. BIN
      textures/technic_copper_chest_front.png
  27. BIN
      textures/technic_copper_chest_locked.png
  28. BIN
      textures/technic_copper_chest_side.png
  29. BIN
      textures/technic_copper_chest_top.png
  30. BIN
      textures/technic_copper_dust.png
  31. BIN
      textures/technic_diamond.png
  32. BIN
      textures/technic_electric_furnace_bottom.png
  33. BIN
      textures/technic_electric_furnace_front.png
  34. BIN
      textures/technic_electric_furnace_front_active.png
  35. BIN
      textures/technic_electric_furnace_side.png
  36. BIN
      textures/technic_electric_furnace_top.png
  37. BIN
      textures/technic_gold_chest_front.png
  38. BIN
      textures/technic_gold_chest_front_black.png
  39. BIN
      textures/technic_gold_chest_front_blue.png
  40. BIN
      textures/technic_gold_chest_front_brown.png
  41. BIN
      textures/technic_gold_chest_front_cyan.png
  42. BIN
      textures/technic_gold_chest_front_dark_green.png
  43. BIN
      textures/technic_gold_chest_front_dark_grey.png
  44. BIN
      textures/technic_gold_chest_front_green.png
  45. BIN
      textures/technic_gold_chest_front_grey.png
  46. BIN
      textures/technic_gold_chest_front_magenta.png
  47. BIN
      textures/technic_gold_chest_front_orange.png
  48. BIN
      textures/technic_gold_chest_front_pink.png
  49. BIN
      textures/technic_gold_chest_front_red.png
  50. BIN
      textures/technic_gold_chest_front_violet.png
  51. BIN
      textures/technic_gold_chest_front_white.png
  52. BIN
      textures/technic_gold_chest_front_yellow.png
  53. BIN
      textures/technic_gold_chest_locked.png
  54. BIN
      textures/technic_gold_chest_locked_black.png
  55. BIN
      textures/technic_gold_chest_locked_blue.png
  56. BIN
      textures/technic_gold_chest_locked_brown.png
  57. BIN
      textures/technic_gold_chest_locked_cyan.png
  58. BIN
      textures/technic_gold_chest_locked_dark_green.png
  59. BIN
      textures/technic_gold_chest_locked_dark_grey.png
  60. BIN
      textures/technic_gold_chest_locked_green.png
  61. BIN
      textures/technic_gold_chest_locked_grey.png
  62. BIN
      textures/technic_gold_chest_locked_magenta.png
  63. BIN
      textures/technic_gold_chest_locked_orange.png
  64. BIN
      textures/technic_gold_chest_locked_pink.png
  65. BIN
      textures/technic_gold_chest_locked_red.png
  66. BIN
      textures/technic_gold_chest_locked_violet.png
  67. BIN
      textures/technic_gold_chest_locked_white.png
  68. BIN
      textures/technic_gold_chest_locked_yellow.png
  69. BIN
      textures/technic_gold_chest_side.png
  70. BIN
      textures/technic_gold_chest_top.png
  71. BIN
      textures/technic_gold_dust.png
  72. BIN
      textures/technic_grinder_front.png
  73. BIN
      textures/technic_grinder_side.png
  74. BIN
      textures/technic_grinder_top.png
  75. BIN
      textures/technic_iron_chest_front.png
  76. BIN
      textures/technic_iron_chest_locked.png
  77. BIN
      textures/technic_iron_chest_side.png
  78. BIN
      textures/technic_iron_chest_top.png
  79. BIN
      textures/technic_iron_dust.png
  80. BIN
      textures/technic_laser_beam.png
  81. BIN
      textures/technic_lv_cable.png
  82. BIN
      textures/technic_lv_cable_wield.png
  83. BIN
      textures/technic_machine_bottom.png
  84. BIN
      textures/technic_mineral_diamond.png
  85. BIN
      textures/technic_mining_laser_mk1.png
  86. BIN
      textures/technic_mithril_chest_front.png
  87. BIN
      textures/technic_mithril_chest_locked.png
  88. BIN
      textures/technic_mithril_chest_side.png
  89. BIN
      textures/technic_mithril_chest_top.png
  90. BIN
      textures/technic_mithril_dust.png
  91. BIN
      textures/technic_music_player_bottom.png
  92. BIN
      textures/technic_music_player_side.png
  93. BIN
      textures/technic_music_player_top.png
  94. BIN
      textures/technic_power_meter.png
  95. BIN
      textures/technic_power_meter_bg.png
  96. BIN
      textures/technic_power_meter_fg.png
  97. BIN
      textures/technic_rebar.png
  98. BIN
      textures/technic_silver_chest_front.png
  99. BIN
      textures/technic_silver_chest_locked.png
  100. BIN
      textures/technic_silver_chest_side.png

+ 22
- 0
.gitattributes 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
- 0
.gitignore 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
- 0
concrete.lua 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
- 0
copper_chest.lua 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
- 0
depends.txt View File

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



+ 40
- 0
dyes.lua 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
- 0
electric.lua 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
- 0
gold_chest.lua 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
- 0
grinder.lua 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
- 0
init.lua 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
- 0
iron_chest.lua 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
- 0
mining_laser_mk1.lua 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)