mirror of
https://github.com/minetest-mods/technic.git
synced 2025-06-30 15:20:37 +02:00
Compare commits
526 Commits
frames-exp
...
488f80d950
Author | SHA1 | Date | |
---|---|---|---|
488f80d950 | |||
d74c250a40 | |||
2e7859c35e | |||
86a04d860e | |||
9b40d02fbd | |||
d1b54a573c | |||
f013d2dd1f | |||
80c6a14566 | |||
fb93388f06 | |||
41f175986d | |||
6af0376c23 | |||
0fcc7a14c2 | |||
68fac3ed7b | |||
395089dfd8 | |||
6664714313 | |||
c93bfefd9f | |||
689766f15a | |||
a5db87f0f1 | |||
86fb981b44 | |||
215de5487b | |||
930c51eef9 | |||
37d49142cf | |||
e056800cea | |||
a84b5f3b28 | |||
9d5bd90b57 | |||
16146231b8 | |||
d4162be9a7 | |||
db480011fb | |||
4cc124ff9e | |||
bf58c77316 | |||
a495541c09 | |||
1a75cd9254 | |||
51f9df2cf2 | |||
9167d4fc6f | |||
844e2fad47 | |||
e1bb29c338 | |||
987cc5a6a4 | |||
83a4bb60ca | |||
97e1c8b7f2 | |||
9cc1a78371 | |||
42efc7e47c | |||
adc638bd8c | |||
557dc4db1b | |||
e65c8b7130 | |||
69feeef0af | |||
fc2f6d8976 | |||
06abe11dd0 | |||
6b8011eba7 | |||
1d20af1bcb | |||
7c11ff1876 | |||
a34ea59105 | |||
33455328bd | |||
14e0c4c48c | |||
170d3e09c5 | |||
970f608078 | |||
39bfb76cfb | |||
d2fb249d94 | |||
fab2c492c4 | |||
54004f4951 | |||
8479a8c984 | |||
0e9caf069d | |||
869d0597ef | |||
ca86550f26 | |||
a3a959ab5e | |||
3f8478086d | |||
092ab7e738 | |||
b6d343e928 | |||
bdd45f161a | |||
5d05f59482 | |||
a353a807bd | |||
db0f8e04a1 | |||
64f38f423e | |||
ceead2b5ab | |||
4eaf48290f | |||
11f20da744 | |||
7244f86ee5 | |||
af39221df9 | |||
72c536c04e | |||
b67bca1277 | |||
ef8bb38bfd | |||
6c4e90d39c | |||
4dda59da0c | |||
338f3b6a99 | |||
eb344ad804 | |||
78f16c3e8e | |||
9755127ffd | |||
b7cecd7f3d | |||
6abd857b3f | |||
383f7df22d | |||
767f5346e9 | |||
df15a5ee65 | |||
cb5e3e8ff4 | |||
600fc6ff7e | |||
f420aa4d37 | |||
7d76ff8d38 | |||
408128d800 | |||
2a7dbe0506 | |||
018d66f791 | |||
6341ac9638 | |||
0a701a0dcf | |||
7ea645496d | |||
10307f23a7 | |||
7d5329834d | |||
ae7625d9f7 | |||
0ad8012cd3 | |||
3ba5354f83 | |||
bf3498b736 | |||
e5f40f5c39 | |||
c4acb7225a | |||
8b222bc66b | |||
9382558d82 | |||
343c7946d9 | |||
5b473927ca | |||
088eea1e3b | |||
9cc5ad3d90 | |||
b4659d9356 | |||
186f9b70ac | |||
ec6354b6a5 | |||
67d5a88d05 | |||
35da22fcd2 | |||
60b5ca5594 | |||
dd580e7684 | |||
663d272870 | |||
32b6ca9816 | |||
05dfc14fdb | |||
314d8c6c23 | |||
8596ca7c19 | |||
d26797d9de | |||
ed2aab46e1 | |||
e3b33e21c7 | |||
ff6675ef28 | |||
d3f40e0fd0 | |||
1765c31eaa | |||
11610cd9cb | |||
fd609d0f7b | |||
1b0669d5eb | |||
dab5fa7105 | |||
5e19514c60 | |||
0139eab9a2 | |||
1f49ef973d | |||
cbe97434dc | |||
73afc40d9c | |||
b739ed6cb1 | |||
51be33deea | |||
1810f417d2 | |||
4888581bee | |||
8cab1a0aec | |||
5dd6191175 | |||
06dec20326 | |||
1da213a5e4 | |||
26de2f7c88 | |||
8ccb6d97ec | |||
6b52c78963 | |||
5f1919d2bc | |||
d39797aad8 | |||
1475ee6e40 | |||
e501c4622b | |||
cfd4cb7871 | |||
2b0a283556 | |||
63efc395cd | |||
7890ffe46b | |||
428b1b8709 | |||
99bebc8008 | |||
03df68461a | |||
e8ac23e111 | |||
413d20d6c8 | |||
322615542e | |||
3db3a9cc32 | |||
2258adb2a9 | |||
097d033585 | |||
584cd82b58 | |||
0c144cd75c | |||
85a984982c | |||
4a993c2de8 | |||
83c6494166 | |||
f9a8593c87 | |||
c5127f4b1b | |||
46f3f8ec7d | |||
e16a39b385 | |||
8ef83e8f7e | |||
798a885807 | |||
71b13ab0e8 | |||
2d86ee64e3 | |||
54b6d9976c | |||
e7d06b33d1 | |||
1b1780946e | |||
28ed3b29a3 | |||
ec3e3b348d | |||
cfd788358c | |||
e2ca7166f9 | |||
32d776293b | |||
a529baba47 | |||
a793747d92 | |||
d732c8dfbd | |||
7cd848a050 | |||
fcef0ef987 | |||
ae7f49de38 | |||
84812d2307 | |||
055ee23431 | |||
a4f7996b56 | |||
24eca043d0 | |||
e393617fa1 | |||
35b0f068af | |||
4cf1e63adb | |||
1615681e89 | |||
3f179e4c53 | |||
6b800758fb | |||
137695ea67 | |||
b00e942824 | |||
cf75916ea7 | |||
4874e29025 | |||
78bfa4f893 | |||
ab6f2b2556 | |||
b8c9028681 | |||
19f74d11ba | |||
3624aabcf9 | |||
e6f715062d | |||
db35c9b54b | |||
fe6965d89a | |||
01fd5d6e6b | |||
8b16fc1176 | |||
0113975160 | |||
c8cbd261ee | |||
c6464d3ebe | |||
3eefa2f181 | |||
4b179821d3 | |||
7ed1aa9398 | |||
ce40d1cfb8 | |||
5ac93cccc9 | |||
cbfeb0192c | |||
bccefd6997 | |||
d5db189cf4 | |||
48e02b8452 | |||
72d541a607 | |||
a13e7b7ed1 | |||
91e12c41fd | |||
96788677bb | |||
6ef3438832 | |||
41a10a86d5 | |||
c17732b16f | |||
49e82a604b | |||
3fd53dfe95 | |||
3bcd99f098 | |||
122e97ebd9 | |||
63fa7a856e | |||
4735055b94 | |||
d452d16fa6 | |||
e08de57ec6 | |||
9444eff7f7 | |||
18265de3b3 | |||
3dc01a6720 | |||
d9bf9830b0 | |||
0c3f55e0c9 | |||
6dd7ffc455 | |||
a0cf9eb8f3 | |||
b9173be3b8 | |||
91fceece18 | |||
5a395928fa | |||
f330d58354 | |||
56e96b2593 | |||
80f79f5e1e | |||
a8c097bcd9 | |||
3cc568ddbd | |||
9d3f7304fb | |||
e4c34c9c32 | |||
1d81e6d4d1 | |||
581afee261 | |||
9087abcde0 | |||
00f61dfb81 | |||
a8b711a7f4 | |||
fe4372649f | |||
3252da05d1 | |||
f250e1632f | |||
86dd5852aa | |||
c38da0945c | |||
ec73a8508f | |||
7e92fe0a46 | |||
9e1c5740d3 | |||
d6b0deb989 | |||
1a7a17f3d7 | |||
3726bd9bd2 | |||
80cb6a495a | |||
0114feaf04 | |||
2e04374de8 | |||
bc0ac581aa | |||
4ac36e9d27 | |||
5382a88aef | |||
a413904ecd | |||
dd30838245 | |||
8da4d057b0 | |||
f13570b59b | |||
30a37a490f | |||
aef07eb604 | |||
f205e5f404 | |||
7c6c3b9679 | |||
42d0081367 | |||
4d1f9753e3 | |||
6d90ebb94e | |||
0defb2e66d | |||
0de4fec07c | |||
fd527c2d98 | |||
23423ab79b | |||
1d46d71b25 | |||
45919b871a | |||
706e880f05 | |||
7c85726e9a | |||
8cec4180af | |||
04e911f94b | |||
3b1abaaa56 | |||
ec069aa43e | |||
16302cffce | |||
78646b2d89 | |||
0cf4133b97 | |||
7ab3f9bed2 | |||
2912e2da78 | |||
7a9d2ffe5f | |||
7d610b7c80 | |||
814646b542 | |||
d0efa15b98 | |||
390ade6e54 | |||
d0001a20c9 | |||
35b10adb40 | |||
849526cd76 | |||
830de45936 | |||
6cc471e986 | |||
1d0687556a | |||
049129d9b8 | |||
772c21cb04 | |||
baf7f61665 | |||
3b16a2858f | |||
b001a67979 | |||
38e85e9775 | |||
df7bf8c713 | |||
7112e742f4 | |||
5692c29a45 | |||
eed803349c | |||
ddb522d4cc | |||
e3b44be6ec | |||
488070c1ee | |||
7cfb3874a3 | |||
ab567e21ca | |||
4996d1824c | |||
a2d1fefe14 | |||
fc87eca4cd | |||
8275091347 | |||
daa6135211 | |||
beb480bec2 | |||
0003ec6a79 | |||
2a7ee141eb | |||
88bdac62e3 | |||
12d0c6522b | |||
0dfac3f484 | |||
60bc80692b | |||
b0faa70873 | |||
d60e3fe939 | |||
9f0b41fe71 | |||
dd65a68ce9 | |||
84cf6504c5 | |||
d59055dd2b | |||
67b90f3ad1 | |||
ec008d7045 | |||
17c5b66524 | |||
e64fdbf03b | |||
e11f0f8817 | |||
c5e9480d99 | |||
366fc3bc65 | |||
62e04b9c0d | |||
6771ad9d33 | |||
cca72f43f1 | |||
6a4cb16392 | |||
1bf52c2d5a | |||
1d7cb74053 | |||
2d9e06c479 | |||
29c7ff5228 | |||
ad0c310b6b | |||
14b30bfd0d | |||
7d5edcf23e | |||
87fc21443c | |||
37c06a9110 | |||
22a4bcf80d | |||
dd468c3aaa | |||
6ec12b51cb | |||
9290e6f00d | |||
69487e530b | |||
efd5ff644c | |||
7065ba9155 | |||
1af6313c69 | |||
1c617f2c5e | |||
563a4c071d | |||
871ded6e6a | |||
83e9cab3ad | |||
78128fd49a | |||
5e4a87b925 | |||
5e7c47a619 | |||
5ec2d10dbc | |||
f7819b4cb8 | |||
3f717cbb9e | |||
4958a77e21 | |||
68ea0acbd0 | |||
e8a5a6652d | |||
430b310eb4 | |||
636b0f20df | |||
611c7760eb | |||
e5cc3359e0 | |||
ad157d1b8f | |||
0e6b3ce86b | |||
5727a84bd8 | |||
8f1c202eaa | |||
d55ecc39f9 | |||
95fcc435f1 | |||
5f2d09b8a9 | |||
2d6f34df15 | |||
c0a17396bf | |||
aa8af0c871 | |||
88cbc6c2a7 | |||
2a23587445 | |||
4ea213c1e0 | |||
96ad67b9ef | |||
51c02e9c8a | |||
9019ebe496 | |||
c636582707 | |||
c394984ae5 | |||
7c4b7046cc | |||
f7d103cd96 | |||
23603e7f41 | |||
c2bc4e9d56 | |||
9181666cdc | |||
799c1b3409 | |||
ebc122fb35 | |||
7c2f2d9630 | |||
b74c2d38b9 | |||
4d20e4473e | |||
623fcae4a4 | |||
29429f636e | |||
a5fc7ac41e | |||
6a08071d86 | |||
68b7bcc28e | |||
ecb53e9717 | |||
b204090acc | |||
c7a4c05860 | |||
45e1f05ffc | |||
30adc3b651 | |||
67b709744f | |||
5c689acc22 | |||
00d7c9bdea | |||
0294fc8f3a | |||
9b64ffea8c | |||
c9bf799e32 | |||
03a5375e55 | |||
99fd5dfee5 | |||
ca69473664 | |||
1a94fdc601 | |||
70fb21ef36 | |||
5c59d97070 | |||
db79675570 | |||
60c75bce74 | |||
e10335e952 | |||
f504178421 | |||
e748af927a | |||
04c6f5bea3 | |||
18cae761af | |||
593972b156 | |||
628a18977b | |||
39c41a06f4 | |||
db20250371 | |||
44dbc75b61 | |||
061d1a3ab4 | |||
7dc21cec40 | |||
179364ff8f | |||
5dd09aeff4 | |||
9ab5846d56 | |||
1b7fa38082 | |||
a6dae893d6 | |||
49052d6f4a | |||
252156d653 | |||
8684fa1733 | |||
8a88812b8b | |||
0201135231 | |||
8bdbe1e451 | |||
821fba9b02 | |||
187fd90a7c | |||
2db9121bdb | |||
b28001e36f | |||
e1c995f654 | |||
52e7014b7c | |||
8c1be3b48e | |||
8fba5e1140 | |||
68f7d34e1b | |||
ebc114df71 | |||
dc324816db | |||
749df3b581 | |||
93b0d25cbc | |||
8e2cb0121b | |||
2df417feb7 | |||
018b248d51 | |||
c5a2f0facc | |||
731a82169b | |||
0d32e05b52 | |||
82f4862e73 | |||
f3bba0aaac | |||
92db8e1f76 | |||
dd2962aba6 | |||
d8437faebc | |||
78cacdcbc6 | |||
c5d287f5f5 | |||
64db3d14d8 | |||
bab8517b2a | |||
5cf765b2f1 | |||
0ea1bd1fa2 | |||
ae235ee8f3 | |||
8ef3f20c3c | |||
f3d8b47b20 | |||
818a0e5ff0 | |||
47b0b59884 | |||
7a3cd49597 | |||
ef70cbfbf2 | |||
37acdc77f7 | |||
163457ed9a | |||
05b28f553e | |||
a35db449b3 | |||
354ee6f313 | |||
0809dd747e | |||
76a8acbe5b | |||
08db41ee4d | |||
bde49aca61 | |||
2d8ff45d9a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -48,7 +48,6 @@ local.properties
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
|
4
.mailmap
Normal file
4
.mailmap
Normal file
@ -0,0 +1,4 @@
|
||||
RealBadAngel <maciej.kasatkin@o2.pl> <mk@realbadangel.pl>
|
||||
Vanessa Ezekowitz <vanessaezekowitz@gmail.com>
|
||||
Vanessa Ezekowitz <vanessaezekowitz@gmail.com> <vanessa@rainbird.(none)>
|
||||
kaeza <kaeza@users.sf.net> Diego Martínez <kaeza@users.sf.net>
|
31
README.md
31
README.md
@ -1,14 +1,23 @@
|
||||
technic 0.4.7
|
||||
Technic
|
||||
=======
|
||||
|
||||
Technic mod for Minetest 0.4.7
|
||||
Credits for contributing to the project (in alphabetical order):
|
||||
* kpoppel
|
||||
* Nekogloop
|
||||
* Nore/Ekdohibs
|
||||
* ShadowNinja
|
||||
* VanessaE
|
||||
* And many others...
|
||||
|
||||
Credits for contributing to the project:
|
||||
Nekogloop
|
||||
ShadowNinja
|
||||
VanessaE
|
||||
Nore/Novatux
|
||||
kpoppel
|
||||
And many others for ideas/inspiring
|
||||
FAQ
|
||||
---
|
||||
|
||||
License:
|
||||
LGPLv2+
|
||||
1. My technic circuit doesn't work. No power is distrubuted.
|
||||
* A: Make sure you have a switching station connected.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Unless otherwise stated, all components of this modpack are licensed under the
|
||||
LGPL, V2 or later. See also the individual mod folders for their
|
||||
secondary/alternate licenses, if any.
|
||||
|
@ -1 +1,3 @@
|
||||
default
|
||||
intllib?
|
||||
|
||||
|
@ -1,21 +1,34 @@
|
||||
--Minetest 0.4.7 mod: concrete
|
||||
--(c) 2013 by RealBadAngel <mk@realbadangel.pl>
|
||||
|
||||
local technic = technic or {}
|
||||
local technic = rawget(_G, "technic") or {}
|
||||
technic.concrete_posts = {}
|
||||
|
||||
minetest.register_alias("technic:concrete_post", "technic:concrete_post0")
|
||||
minetest.register_alias("technic:concrete_post32", "technic:concrete_post12")
|
||||
minetest.register_alias("technic:concrete_post33", "technic:concrete_post3")
|
||||
minetest.register_alias("technic:concrete_post34", "technic:concrete_post28")
|
||||
minetest.register_alias("technic:concrete_post35", "technic:concrete_post19")
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||
|
||||
for i = 0, 31 do
|
||||
minetest.register_alias("technic:concrete_post"..i,
|
||||
"technic:concrete_post")
|
||||
end
|
||||
for i = 32, 63 do
|
||||
minetest.register_alias("technic:concrete_post"..i,
|
||||
"technic:concrete_post_with_platform")
|
||||
end
|
||||
|
||||
local steel_ingot
|
||||
if minetest.get_modpath("technic_worldgen") then
|
||||
steel_ingot = "technic:carbon_steel_ingot"
|
||||
else
|
||||
steel_ingot = "default:steel_ingot"
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:rebar 6',
|
||||
recipe = {
|
||||
{'','', 'default:steel_ingot'},
|
||||
{'','default:steel_ingot',''},
|
||||
{'default:steel_ingot', '', ''},
|
||||
{'','', steel_ingot},
|
||||
{'',steel_ingot,''},
|
||||
{steel_ingot, '', ''},
|
||||
}
|
||||
})
|
||||
|
||||
@ -31,12 +44,12 @@ minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
output = 'technic:concrete_post_platform 6',
|
||||
recipe = {
|
||||
{'technic:concrete','technic:concrete_post0','technic:concrete'},
|
||||
{'technic:concrete','technic:concrete_post','technic:concrete'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:concrete_post0 12',
|
||||
output = 'technic:concrete_post 12',
|
||||
recipe = {
|
||||
{'default:stone','technic:rebar','default:stone'},
|
||||
{'default:stone','technic:rebar','default:stone'},
|
||||
@ -53,47 +66,42 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
local box_platform = {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}
|
||||
local box_center = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
|
||||
local box_x1 = {0, -0.3, -0.1, 0.5, 0.3, 0.1}
|
||||
local box_z1 = {-0.1, -0.3, 0, 0.1, 0.3, 0.5}
|
||||
local box_x2 = {0, -0.3, -0.1, -0.5, 0.3, 0.1}
|
||||
local box_z2 = {-0.1, -0.3, 0, 0.1, 0.3, -0.5}
|
||||
|
||||
minetest.register_craftitem(":technic:rebar", {
|
||||
description = "Rebar",
|
||||
description = S("Rebar"),
|
||||
inventory_image = "technic_rebar.png",
|
||||
})
|
||||
|
||||
minetest.register_node(":technic:concrete", {
|
||||
description = "Concrete Block",
|
||||
tile_images = {"technic_concrete_block.png",},
|
||||
description = S("Concrete Block"),
|
||||
tiles = {"technic_concrete_block.png",},
|
||||
groups = {cracky=1, level=2, concrete=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
technic.update_posts(pos, false)
|
||||
end,
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
technic.update_posts(pos, false)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node(":technic:blast_resistant_concrete", {
|
||||
description = "Blast-resistant Concrete Block",
|
||||
tile_images = {"technic_blast_resistant_concrete_block.png",},
|
||||
description = S("Blast-resistant Concrete Block"),
|
||||
tiles = {"technic_blast_resistant_concrete_block.png",},
|
||||
groups = {cracky=1, level=3, concrete=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
after_place_node = function(pos, player, itemstack)
|
||||
technic.update_posts(pos, false)
|
||||
end,
|
||||
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
||||
technic.update_posts(pos, false)
|
||||
on_blast = function(pos, intensity)
|
||||
if intensity > 9 then
|
||||
minetest.remove_node(pos)
|
||||
return {"technic:blast_resistant_concrete"}
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
local box_platform = {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}
|
||||
local box_post = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
|
||||
local box_front = {-0.1, -0.3, -0.5, 0.1, 0.3, 0}
|
||||
local box_back = {-0.1, -0.3, 0, 0.1, 0.3, 0.5}
|
||||
local box_left = {-0.5, -0.3, -0.1, 0, 0.3, 0.1}
|
||||
local box_right = {0, -0.3, -0.1, 0.5, 0.3, 0.1}
|
||||
|
||||
minetest.register_node(":technic:concrete_post_platform", {
|
||||
description = "Concrete Post Platform",
|
||||
tile_images = {"technic_concrete_block.png",},
|
||||
description = S("Concrete Post Platform"),
|
||||
tiles = {"technic_concrete_block.png",},
|
||||
groups={cracky=1, level=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
paramtype = "light",
|
||||
@ -104,144 +112,45 @@ minetest.register_node(":technic:concrete_post_platform", {
|
||||
},
|
||||
on_place = function (itemstack, placer, pointed_thing)
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if not technic.concrete_posts[node.name] then
|
||||
if node.name ~= "technic:concrete_post" then
|
||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
end
|
||||
local links = technic.concrete_posts[node.name]
|
||||
if links[5] ~= 0 then -- The post already has a platform
|
||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
end
|
||||
local id = technic.get_post_id({links[1], links[2], links[3], links[4], 1})
|
||||
minetest.set_node(pointed_thing.under, {name="technic:concrete_post"..id})
|
||||
minetest.set_node(pointed_thing.under, {name="technic:concrete_post_with_platform"})
|
||||
itemstack:take_item()
|
||||
placer:set_wielded_item(itemstack)
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
local function gen_post_nodebox(x1, x2, z1, z2, platform)
|
||||
local box = {box_center}
|
||||
if x1 ~= 0 then
|
||||
table.insert(box, box_x1)
|
||||
end
|
||||
if x2 ~= 0 then
|
||||
table.insert(box, box_x2)
|
||||
end
|
||||
if z1 ~= 0 then
|
||||
table.insert(box, box_z1)
|
||||
end
|
||||
if z2 ~= 0 then
|
||||
table.insert(box, box_z2)
|
||||
end
|
||||
if platform ~= 0 then
|
||||
table.insert(box, box_platform)
|
||||
end
|
||||
return box
|
||||
end
|
||||
|
||||
local function dig_post_with_platform(pos, oldnode, oldmetadata)
|
||||
oldnode.name = "technic:concrete_post0"
|
||||
minetest.set_node(pos, oldnode)
|
||||
technic.update_posts(pos, true)
|
||||
end
|
||||
|
||||
function technic.posts_should_connect(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if technic.concrete_posts[node.name] then
|
||||
return "post"
|
||||
elseif minetest.get_item_group(node.name, "concrete") ~= 0 then
|
||||
return "block"
|
||||
end
|
||||
end
|
||||
|
||||
function technic.get_post_id(links)
|
||||
return (links[4] * 1) + (links[3] * 2)
|
||||
+ (links[2] * 4) + (links[1] * 8)
|
||||
+ (links[5] * 16)
|
||||
end
|
||||
|
||||
function technic.update_posts(pos, set, secondrun)
|
||||
local node = minetest.get_node(pos)
|
||||
local link_positions = {
|
||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||
{x=pos.x, y=pos.y, z=pos.z-1},
|
||||
}
|
||||
|
||||
local links = {0, 0, 0, 0, 0}
|
||||
|
||||
for i, link_pos in pairs(link_positions) do
|
||||
local connecttype = technic.posts_should_connect(link_pos)
|
||||
if connecttype then
|
||||
links[i] = 1
|
||||
-- Have posts next to us update theirselves,
|
||||
-- but only once. (We don't want to start an
|
||||
-- infinite loop of updates)
|
||||
if not secondrun and connecttype == "post" then
|
||||
technic.update_posts(link_pos, true, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- We don't want to set ourselves if we have been removed or we are
|
||||
-- updating a concrete node
|
||||
if set then
|
||||
-- Preserve platform
|
||||
local oldlinks = technic.concrete_posts[node.name]
|
||||
if oldlinks then
|
||||
links[5] = oldlinks[5]
|
||||
end
|
||||
minetest.set_node(pos, {name="technic:concrete_post"
|
||||
..technic.get_post_id(links)})
|
||||
end
|
||||
end
|
||||
|
||||
for x1 = 0, 1 do
|
||||
for x2 = 0, 1 do
|
||||
for z1 = 0, 1 do
|
||||
for z2 = 0, 1 do
|
||||
for platform = 0, 1 do
|
||||
local links = {x1, x2, z1, z2, platform}
|
||||
local id = technic.get_post_id(links)
|
||||
technic.concrete_posts["technic:concrete_post"..id] = links
|
||||
|
||||
local groups = {cracky=1, level=2, concrete_post=1}
|
||||
if id ~= 0 then
|
||||
groups.not_in_creative_inventory = 1
|
||||
end
|
||||
|
||||
local drop = "technic:concrete_post0"
|
||||
local after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
technic.update_posts(pos, false)
|
||||
end
|
||||
if platform ~= 0 then
|
||||
drop = "technic:concrete_post_platform"
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
dig_post_with_platform(pos, oldnode, oldmetadata)
|
||||
local after_dig_node = nil
|
||||
if platform == 1 then
|
||||
after_dig_node = function(pos, old_node)
|
||||
old_node.name = "technic:concrete_post"
|
||||
minetest.set_node(pos, old_node)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node(":technic:concrete_post"..id, {
|
||||
description = "Concrete Post",
|
||||
minetest.register_node(":technic:concrete_post"..(platform == 1 and "_with_platform" or ""), {
|
||||
description = S("Concrete Post"),
|
||||
tiles = {"technic_concrete_block.png"},
|
||||
groups = groups,
|
||||
groups = {cracky=1, level=2, concrete_post=1, not_in_creative_inventory=platform},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
drop = drop,
|
||||
drop = (platform == 1 and "technic:concrete_post_platform" or
|
||||
"technic:concrete_post"),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
connects_to = {"group:concrete", "group:concrete_post"},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = gen_post_nodebox(x1, x2, z1, z2, platform),
|
||||
type = "connected",
|
||||
fixed = {box_post, (platform == 1 and box_platform or nil)},
|
||||
connect_front = box_front,
|
||||
connect_back = box_back,
|
||||
connect_left = box_left,
|
||||
connect_right = box_right,
|
||||
},
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
technic.update_posts(pos, true)
|
||||
end,
|
||||
after_dig_node = after_dig_node,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
10
concrete/locale/de.txt
Normal file
10
concrete/locale/de.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# German Translation for technic_concrete
|
||||
# Deutsche Übersetzung von technic_concrete
|
||||
# by Xanthin
|
||||
|
||||
Rebar = Bewehrungsstab
|
||||
Concrete Block = Betonblock
|
||||
Blast-resistant Concrete Block = Explosionsbestaendiger Betonblock
|
||||
Concrete Post Platform = Betonpfostenplattform
|
||||
Concrete Post = Betonpfosten
|
||||
|
8
concrete/locale/es.txt
Normal file
8
concrete/locale/es.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# technic_concrete traducido por Carlos Barraza
|
||||
|
||||
Rebar = Barra de refuerzo
|
||||
Concrete Block = Bloque de concreto
|
||||
Blast-resistant Concrete Block = Bloque de concreto resistente a explosiones
|
||||
Concrete Post Platform = Plataforma de concreto
|
||||
Concrete Post = Postes de concreto
|
||||
|
8
concrete/locale/template.txt
Normal file
8
concrete/locale/template.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# technic_concrete translation template
|
||||
|
||||
Rebar =
|
||||
Concrete Block =
|
||||
Blast-resistant Concrete Block =
|
||||
Concrete Post Platform =
|
||||
Concrete Post =
|
||||
|
7
concrete/locale/tr.txt
Normal file
7
concrete/locale/tr.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# turkish translation by mahmutelmas06
|
||||
|
||||
Rebar = Beton demiri
|
||||
Concrete Block = Beton blok
|
||||
Blast-resistant Concrete Block = Patlamaya dayanıklı beton blok
|
||||
Concrete Post Platform = Beton direk platformu
|
||||
Concrete Post = Beton direk
|
@ -1,4 +1,6 @@
|
||||
default
|
||||
moreblocks
|
||||
technic_worldgen
|
||||
concrete
|
||||
unifieddyes?
|
||||
intllib?
|
||||
moreblocks?
|
||||
|
@ -1,46 +1,67 @@
|
||||
-- Minetest 0.4.6 mod: extranodes
|
||||
-- namespace: technic
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||
|
||||
--register stairslike nodes
|
||||
register_stair_slab_panel_micro("technic", "marble", "technic:marble",
|
||||
{cracky=2, not_in_creative_inventory=1},
|
||||
{"technic_marble.png"},
|
||||
"Marble",
|
||||
"marble",
|
||||
"facedir",
|
||||
0)
|
||||
if minetest.get_modpath("moreblocks") then
|
||||
|
||||
register_stair_slab_panel_micro("technic", "marble_bricks", "technic:marble_bricks",
|
||||
{cracky=2, not_in_creative_inventory=1},
|
||||
{"technic_marble_bricks.png"},
|
||||
"Marble Bricks",
|
||||
"marble_bricks",
|
||||
"facedir",
|
||||
0)
|
||||
-- register stairsplus/circular_saw nodes
|
||||
-- we skip blast resistant concrete and uranium intentionally
|
||||
-- chrome seems to be too hard of a metal to be actually sawable
|
||||
|
||||
register_stair_slab_panel_micro("technic", "granite", "technic:granite",
|
||||
{cracky=3, not_in_creative_inventory=1},
|
||||
{"technic_granite.png"},
|
||||
"Granite",
|
||||
"granite",
|
||||
"facedir",
|
||||
0)
|
||||
stairsplus:register_all("technic", "marble", "technic:marble", {
|
||||
description=S("Marble"),
|
||||
groups={cracky=3, not_in_creative_inventory=1},
|
||||
tiles={"technic_marble.png"},
|
||||
})
|
||||
|
||||
register_stair_slab_panel_micro("technic", "concrete", "technic:concrete",
|
||||
{cracky=3, not_in_creative_inventory=1},
|
||||
{"technic_concrete_block.png"},
|
||||
"Concrete",
|
||||
"concrete",
|
||||
"facedir",
|
||||
0)
|
||||
stairsplus:register_all("technic", "marble_bricks", "technic:marble_bricks", {
|
||||
description=S("Marble Bricks"),
|
||||
groups={cracky=3, not_in_creative_inventory=1},
|
||||
tiles={"technic_marble_bricks.png"},
|
||||
})
|
||||
|
||||
--register nodes in circular saw if aviable
|
||||
if circular_saw then
|
||||
for i,v in ipairs({"concrete", "marble", "marble_bricks", "granite", "default:obsidian"}) do
|
||||
table.insert(circular_saw.known_stairs, "technic:" ..v);
|
||||
end
|
||||
end
|
||||
stairsplus:register_all("technic", "granite", "technic:granite", {
|
||||
description=S("Granite"),
|
||||
groups={cracky=1, not_in_creative_inventory=1},
|
||||
tiles={"technic_granite.png"},
|
||||
})
|
||||
|
||||
stairsplus:register_all("technic", "concrete", "technic:concrete", {
|
||||
description=S("Concrete"),
|
||||
groups={cracky=3, not_in_creative_inventory=1},
|
||||
tiles={"technic_concrete_block.png"},
|
||||
})
|
||||
|
||||
stairsplus:register_all("technic", "zinc_block", "technic:zinc_block", {
|
||||
description=S("Zinc Block"),
|
||||
groups={cracky=1, not_in_creative_inventory=1},
|
||||
tiles={"technic_zinc_block.png"},
|
||||
})
|
||||
|
||||
stairsplus:register_all("technic", "cast_iron_block", "technic:cast_iron_block", {
|
||||
description=S("Cast Iron Block"),
|
||||
groups={cracky=1, not_in_creative_inventory=1},
|
||||
tiles={"technic_cast_iron_block.png"},
|
||||
})
|
||||
|
||||
stairsplus:register_all("technic", "carbon_steel_block", "technic:carbon_steel_block", {
|
||||
description=S("Carbon Steel Block"),
|
||||
groups={cracky=1, not_in_creative_inventory=1},
|
||||
tiles={"technic_carbon_steel_block.png"},
|
||||
})
|
||||
|
||||
stairsplus:register_all("technic", "stainless_steel_block", "technic:stainless_steel_block", {
|
||||
description=S("Stainless Steel Block"),
|
||||
groups={cracky=1, not_in_creative_inventory=1},
|
||||
tiles={"technic_stainless_steel_block.png"},
|
||||
})
|
||||
|
||||
stairsplus:register_all("technic", "brass_block", "technic:brass_block", {
|
||||
description=S("Brass Block"),
|
||||
groups={cracky=1, not_in_creative_inventory=1},
|
||||
tiles={"technic_brass_block.png"},
|
||||
})
|
||||
|
||||
function register_technic_stairs_alias(modname, origname, newmod, newname)
|
||||
minetest.register_alias(modname .. ":slab_" .. origname, newmod..":slab_" .. newname)
|
||||
@ -78,3 +99,89 @@ register_technic_stairs_alias("stairsplus", "concrete", "technic", "concrete")
|
||||
register_technic_stairs_alias("stairsplus", "marble", "technic", "marble")
|
||||
register_technic_stairs_alias("stairsplus", "granite", "technic", "granite")
|
||||
register_technic_stairs_alias("stairsplus", "marble_bricks", "technic", "marble_bricks")
|
||||
|
||||
end
|
||||
|
||||
local iclip_def = {
|
||||
description = "Insulator/cable clip",
|
||||
drawtype = "mesh",
|
||||
mesh = "technic_insulator_clip.obj",
|
||||
tiles = {"technic_insulator_clip.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1 },
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
}
|
||||
|
||||
local iclipfence_def = {
|
||||
description = "Insulator/cable clip",
|
||||
tiles = {"technic_insulator_clip.png"},
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {
|
||||
{ -0.25, 0.75, -0.25, 0.25, 1.25, 0.25 }, -- the clip on top
|
||||
{ -0.125, 0.6875, -0.125, 0.125, 0.75, 0.125 },
|
||||
{ -0.1875, 0.625, -0.1875, 0.1875, 0.6875, 0.1875 },
|
||||
{ -0.125, 0.5625, -0.125, 0.125, 0.625, 0.125 },
|
||||
{ -0.1875, 0.5, -0.1875, 0.1875, 0.5625, 0.1875 },
|
||||
{ -0.125, 0.4375, -0.125, 0.125, 0.5, 0.125 },
|
||||
{ -0.1875, 0.375, -0.1875, 0.1875, 0.4375, 0.1875 },
|
||||
{ -0.125, -0.5, -0.125, 0.125, 0.375, 0.125 }, -- the post, slightly short
|
||||
},
|
||||
-- connect_top =
|
||||
-- connect_bottom =
|
||||
connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
|
||||
{-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
|
||||
connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
|
||||
{-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
|
||||
connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
|
||||
{-1/16,-5/16,1/8,1/16,-3/16,1/2}},
|
||||
connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
|
||||
{1/8,-5/16,-1/16,1/2,-3/16,1/16}},
|
||||
},
|
||||
connects_to = {"group:fence", "group:wood", "group:tree"},
|
||||
groups = {fence=1, choppy=1, snappy=1, oddly_breakable_by_hand=1 },
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
}
|
||||
|
||||
if minetest.get_modpath("unifieddyes") then
|
||||
iclip_def.paramtype2 = "colorwallmounted"
|
||||
iclip_def.palette = "unifieddyes_palette_colorwallmounted.png"
|
||||
iclip_def.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)
|
||||
unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
iclip_def.after_dig_node = unifieddyes.after_dig_node
|
||||
iclip_def.groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1, ud_param2_colorable = 1}
|
||||
|
||||
iclipfence_def.paramtype2 = "color"
|
||||
iclipfence_def.palette = "unifieddyes_palette_extended.png"
|
||||
iclipfence_def.on_construct = unifieddyes.on_construct
|
||||
iclipfence_def.after_place_node = unifieddyes.recolor_on_place
|
||||
iclipfence_def.after_dig_node = unifieddyes.after_dig_node
|
||||
iclipfence_def.groups = {fence=1, choppy=1, snappy=1, oddly_breakable_by_hand=1, ud_param2_colorable = 1}
|
||||
iclipfence_def.place_param2 = 171 -- medium amber, low saturation, closest color to default:wood
|
||||
end
|
||||
|
||||
minetest.register_node(":technic:insulator_clip", iclip_def)
|
||||
minetest.register_node(":technic:insulator_clip_fencepost", iclipfence_def)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "technic:insulator_clip",
|
||||
recipe = {
|
||||
{ "", "dye:white", ""},
|
||||
{ "", "technic:raw_latex", ""},
|
||||
{ "technic:raw_latex", "default:stone", "technic:raw_latex"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "technic:insulator_clip_fencepost 2",
|
||||
recipe = {
|
||||
{ "", "dye:white", ""},
|
||||
{ "", "technic:raw_latex", ""},
|
||||
{ "technic:raw_latex", "default:fence_wood", "technic:raw_latex"},
|
||||
}
|
||||
})
|
||||
|
9
extranodes/locale/de.txt
Normal file
9
extranodes/locale/de.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# German Translation for technic_extranodes
|
||||
# Deutsche Übersetzung von technic_extranodes
|
||||
# by Xanthin
|
||||
|
||||
Marble = Marmor
|
||||
Marble Bricks = Marmorziegel
|
||||
Granite = Granit
|
||||
Concrete = Beton
|
||||
|
7
extranodes/locale/es.txt
Normal file
7
extranodes/locale/es.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# technic_extranodes traducido por Carlos Barraza
|
||||
|
||||
Marble = Mármol
|
||||
Marble Bricks = Ladrillos de mármol
|
||||
Granite = Granito
|
||||
Concrete = Concreto
|
||||
|
7
extranodes/locale/template.txt
Normal file
7
extranodes/locale/template.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# technic_extranodes translation template
|
||||
|
||||
Marble =
|
||||
Marble Bricks =
|
||||
Granite =
|
||||
Concrete =
|
||||
|
6
extranodes/locale/tr.txt
Normal file
6
extranodes/locale/tr.txt
Normal file
@ -0,0 +1,6 @@
|
||||
# turkish translation by mahmutelmas06
|
||||
|
||||
Marble = Mermer
|
||||
Marble Bricks = Mermer tuğla
|
||||
Granite = Granit
|
||||
Concrete = Beton
|
173
extranodes/models/technic_insulator_clip.obj
Normal file
173
extranodes/models/technic_insulator_clip.obj
Normal file
@ -0,0 +1,173 @@
|
||||
# Blender v2.72 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
o Cube
|
||||
v -0.500000 -0.500000 0.500000
|
||||
v -0.500000 -0.500000 -0.500000
|
||||
v 0.500000 -0.500000 -0.500000
|
||||
v 0.500000 -0.500000 0.500000
|
||||
v -0.249997 0.500000 0.249997
|
||||
v -0.249997 0.500000 -0.249997
|
||||
v 0.249997 0.500000 -0.249997
|
||||
v 0.249997 0.500000 0.249997
|
||||
v -0.187500 0.500000 0.187500
|
||||
v -0.187500 0.500000 -0.187500
|
||||
v 0.187500 0.500000 -0.187500
|
||||
v 0.187500 0.500000 0.187500
|
||||
v -0.187500 0.750000 0.187500
|
||||
v -0.187500 0.750000 -0.187500
|
||||
v 0.187500 0.750000 -0.187500
|
||||
v 0.187500 0.750000 0.187500
|
||||
v -0.250000 0.750000 0.250000
|
||||
v -0.250000 0.750000 -0.250000
|
||||
v 0.250000 0.750000 -0.250000
|
||||
v 0.250000 0.750000 0.250000
|
||||
v -0.250000 1.250000 0.250000
|
||||
v -0.250000 1.250000 -0.250000
|
||||
v 0.250000 1.250000 -0.250000
|
||||
v 0.250000 1.250000 0.250000
|
||||
v -0.500000 0.312500 0.500000
|
||||
v -0.500000 0.312500 -0.500000
|
||||
v 0.500000 0.312500 -0.500000
|
||||
v 0.500000 0.312500 0.500000
|
||||
v 0.187500 0.625000 0.187500
|
||||
v 0.187500 0.625000 -0.187500
|
||||
v -0.187500 0.625000 -0.187500
|
||||
v -0.187500 0.625000 0.187500
|
||||
v 0.187500 0.562500 0.187500
|
||||
v 0.187500 0.687500 -0.187500
|
||||
v -0.187500 0.687500 -0.187500
|
||||
v -0.187500 0.562500 0.187500
|
||||
v 0.187500 0.687500 0.187500
|
||||
v 0.187500 0.562500 -0.187500
|
||||
v -0.187500 0.562500 -0.187500
|
||||
v -0.187500 0.687500 0.187500
|
||||
v 0.168668 0.531250 0.168668
|
||||
v 0.168668 0.718750 -0.168668
|
||||
v -0.168668 0.718750 -0.168668
|
||||
v -0.168668 0.531250 0.168668
|
||||
v 0.168668 0.656250 0.168668
|
||||
v 0.168668 0.593750 -0.168668
|
||||
v -0.168668 0.593750 -0.168668
|
||||
v -0.168668 0.656250 0.168668
|
||||
v 0.168668 0.593750 0.168668
|
||||
v 0.168668 0.656250 -0.168668
|
||||
v -0.168668 0.656250 -0.168668
|
||||
v -0.168668 0.593750 0.168668
|
||||
v 0.168668 0.718750 0.168668
|
||||
v 0.168668 0.531250 -0.168668
|
||||
v -0.168668 0.531250 -0.168668
|
||||
v -0.168668 0.718750 0.168668
|
||||
vt 1.000000 0.000000
|
||||
vt 1.000000 1.000000
|
||||
vt 0.000000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 0.749997 0.749997
|
||||
vt 0.749997 0.250003
|
||||
vt 0.250003 0.250003
|
||||
vt 0.250003 0.749997
|
||||
vt 0.000000 0.812500
|
||||
vt 1.000000 0.812500
|
||||
vt 0.312500 0.312500
|
||||
vt 0.312500 0.687500
|
||||
vt 0.687500 0.312500
|
||||
vt 0.687500 0.687500
|
||||
vt 0.331332 1.218750
|
||||
vt 0.668668 1.218750
|
||||
vt 0.687500 1.250000
|
||||
vt 0.312500 1.250000
|
||||
vt 0.750000 1.250000
|
||||
vt 0.750000 1.750000
|
||||
vt 0.250000 1.750000
|
||||
vt 0.250000 1.250000
|
||||
vt 0.331332 1.093750
|
||||
vt 0.668668 1.093750
|
||||
vt 0.687500 1.125000
|
||||
vt 0.312500 1.125000
|
||||
vt 0.331332 1.093750
|
||||
vt 0.668668 1.093750
|
||||
vt 0.331332 1.156250
|
||||
vt 0.668668 1.156250
|
||||
vt 0.687500 1.187500
|
||||
vt 0.312500 1.187500
|
||||
vt 0.331332 1.156250
|
||||
vt 0.668668 1.156250
|
||||
vt 0.331332 1.031250
|
||||
vt 0.668668 1.031250
|
||||
vt 0.687500 1.062500
|
||||
vt 0.312500 1.062500
|
||||
vt 0.312500 1.000000
|
||||
vt 0.687500 1.000000
|
||||
vn 0.000000 -1.000000 -0.000000
|
||||
vn -0.600000 0.800000 -0.000000
|
||||
vn 0.000000 0.800000 -0.600000
|
||||
vn 0.600000 0.800000 0.000000
|
||||
vn -0.000000 0.000000 1.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
vn 0.856500 -0.516200 0.000000
|
||||
vn 0.000000 -0.516200 -0.856500
|
||||
vn -0.000000 -0.516200 0.856500
|
||||
vn -0.856500 -0.516200 -0.000000
|
||||
vn -1.000000 0.000000 -0.000000
|
||||
vn 0.000000 -0.000000 -1.000000
|
||||
vn 1.000000 -0.000000 0.000000
|
||||
vn -0.000000 0.800000 0.600000
|
||||
vn 0.856500 0.516200 0.000000
|
||||
vn 0.000000 0.516200 -0.856500
|
||||
vn -0.000000 0.516200 0.856500
|
||||
vn -0.856500 0.516200 -0.000000
|
||||
g Cube_Cube_Material
|
||||
s off
|
||||
f 1/1/1 2/2/1 3/3/1 4/4/1
|
||||
f 25/2/2 5/5/2 6/6/2 26/1/2
|
||||
f 26/1/3 6/6/3 7/7/3 27/4/3
|
||||
f 27/4/4 7/7/4 8/8/4 28/3/4
|
||||
f 25/9/5 1/4/5 4/1/5 28/10/5
|
||||
f 8/8/6 7/7/6 11/11/6 12/12/6
|
||||
f 7/7/6 6/6/6 10/13/6 11/11/6
|
||||
f 5/5/6 8/8/6 12/12/6 9/14/6
|
||||
f 6/6/6 5/5/6 9/14/6 10/13/6
|
||||
f 53/15/7 42/16/7 15/17/7 16/18/7
|
||||
f 42/15/8 43/16/8 14/17/8 15/18/8
|
||||
f 56/15/9 53/16/9 16/17/9 13/18/9
|
||||
f 43/15/10 56/16/10 13/17/10 14/18/10
|
||||
f 14/4/1 18/4/1 19/4/1 15/4/1
|
||||
f 17/19/11 21/20/11 22/21/11 18/22/11
|
||||
f 18/19/12 22/20/12 23/21/12 19/22/12
|
||||
f 19/19/13 23/20/13 24/21/13 20/22/13
|
||||
f 21/21/5 17/22/5 20/19/5 24/20/5
|
||||
f 21/5/6 24/8/6 23/7/6 22/6/6
|
||||
f 15/4/1 19/4/1 20/4/1 16/4/1
|
||||
f 16/4/1 20/4/1 17/4/1 13/4/1
|
||||
f 13/4/1 17/4/1 18/4/1 14/4/1
|
||||
f 1/1/11 25/10/11 26/9/11 2/4/11
|
||||
f 2/1/12 26/10/12 27/9/12 3/4/12
|
||||
f 3/1/13 27/10/13 28/9/13 4/4/13
|
||||
f 5/5/14 25/2/14 28/3/14 8/8/14
|
||||
f 49/23/7 46/24/7 30/25/7 29/26/7
|
||||
f 46/27/8 47/28/8 31/25/8 30/26/8
|
||||
f 52/23/9 49/24/9 29/25/9 32/26/9
|
||||
f 47/23/10 52/24/10 32/25/10 31/26/10
|
||||
f 45/29/7 50/30/7 34/31/7 37/32/7
|
||||
f 50/33/8 51/34/8 35/31/8 34/32/8
|
||||
f 48/33/9 45/34/9 37/31/9 40/32/9
|
||||
f 51/29/10 48/30/10 40/31/10 35/32/10
|
||||
f 41/35/7 54/36/7 38/37/7 33/38/7
|
||||
f 54/35/8 55/36/8 39/37/8 38/38/8
|
||||
f 44/35/9 41/36/9 33/37/9 36/38/9
|
||||
f 55/35/10 44/36/10 36/37/10 39/38/10
|
||||
f 37/32/15 34/31/15 42/16/15 53/15/15
|
||||
f 34/32/16 35/31/16 43/16/16 42/15/16
|
||||
f 40/32/17 37/31/17 53/16/17 56/15/17
|
||||
f 35/32/18 40/31/18 56/16/18 43/15/18
|
||||
f 33/38/15 38/37/15 46/24/15 49/23/15
|
||||
f 38/38/16 39/37/16 47/28/16 46/27/16
|
||||
f 36/38/17 33/37/17 49/24/17 52/23/17
|
||||
f 39/38/18 36/37/18 52/24/18 47/23/18
|
||||
f 29/26/15 30/25/15 50/30/15 45/29/15
|
||||
f 30/26/16 31/25/16 51/34/16 50/33/16
|
||||
f 32/26/17 29/25/17 45/34/17 48/33/17
|
||||
f 31/26/18 32/25/18 48/30/18 51/29/18
|
||||
f 12/39/15 11/40/15 54/36/15 41/35/15
|
||||
f 11/39/16 10/40/16 55/36/16 54/35/16
|
||||
f 9/39/17 12/40/17 41/36/17 44/35/17
|
||||
f 10/39/18 9/40/18 44/36/18 55/35/18
|
BIN
extranodes/textures/technic_insulator_clip.png
Normal file
BIN
extranodes/textures/technic_insulator_clip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 226 B |
35
technic/README.md
Normal file
35
technic/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
Technic
|
||||
=======
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (C) 2012-2014 Maciej Kasatkin (RealBadAngel)
|
||||
|
||||
Technic chests code is licensed under the GNU LGPLv2+.
|
||||
|
||||
Texture licenses:
|
||||
|
||||
BlockMen modified by Zefram (CC BY-SA 3.0):
|
||||
* technic_chernobylite_block.png
|
||||
* technic_corium_flowing_animated.png
|
||||
* technic_corium_source_animated.png
|
||||
|
||||
celeron55 (Perttu Ahola) modified by Zefram (CC BY-SA 3.0):
|
||||
* technic_bucket_corium.png
|
||||
|
||||
sdzen (Elise Staudter) (CC BY-SA 3.0):
|
||||
* most of the older 16x16 textures
|
||||
|
||||
RealBadAngel: (WTFPL)
|
||||
* Everything else.
|
||||
|
||||
CC BY-SA 3.0: <http://creativecommons.org/licenses/by-sa/3.0/>
|
||||
|
||||
Sound licenses:
|
||||
|
||||
veikk0 (Veikko Mäkelä) (CC BY-SA 4.0):
|
||||
* technic_hv_nuclear_reactor_siren_danger_loop.ogg
|
||||
* Derived from "Nuclear alarm.wav" by Freesound.org user rene___ from <https://freesound.org/people/rene___/sounds/56778/>. Originally licensed under CC0 1.0 <https://creativecommons.org/publicdomain/zero/1.0/>
|
||||
|
||||
CC BY-SA 4.0: <https://creativecommons.org/licenses/by-sa/4.0/>
|
@ -1,7 +1,4 @@
|
||||
|
||||
local worldpath = minetest.get_worldpath()
|
||||
|
||||
technic.config = Settings(worldpath.."/technic.conf")
|
||||
technic.config = technic.config or Settings(minetest.get_worldpath().."/technic.conf")
|
||||
|
||||
local conf_table = technic.config:to_table()
|
||||
|
||||
@ -9,10 +6,13 @@ local defaults = {
|
||||
enable_mining_drill = "true",
|
||||
enable_mining_laser = "true",
|
||||
enable_flashlight = "false",
|
||||
enable_rubber_tree_generation = "true",
|
||||
enable_marble_generation = "true",
|
||||
enable_granite_generation = "true",
|
||||
enable_wind_mill = "false",
|
||||
enable_frames = "false",
|
||||
enable_corium_griefing = "true",
|
||||
enable_radiation_protection = "true",
|
||||
enable_entity_radiation_damage = "true",
|
||||
enable_longterm_radiation_damage = "true",
|
||||
enable_nuclear_reactor_digiline_selfdestruct = "false",
|
||||
}
|
||||
|
||||
for k, v in pairs(defaults) do
|
||||
@ -20,7 +20,3 @@ for k, v in pairs(defaults) do
|
||||
technic.config:set(k, v)
|
||||
end
|
||||
end
|
||||
|
||||
-- Create the config file if it doesn't exist
|
||||
technic.config:write()
|
||||
|
||||
|
@ -1,57 +1,45 @@
|
||||
-- check if we have the necessary dependencies to allow actually using these materials in the crafts
|
||||
local mesecons_materials = minetest.get_modpath("mesecons_materials")
|
||||
|
||||
-- Remove some recipes
|
||||
-- Bronze
|
||||
minetest.clear_craft({
|
||||
type = "shapeless",
|
||||
output = "default:bronze_ingot"
|
||||
})
|
||||
|
||||
-- Accelerator tube
|
||||
if pipeworks.enable_accelerator_tube then
|
||||
minetest.clear_craft({
|
||||
output = "pipeworks:accelerator_tube_1",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:accelerator_tube_1',
|
||||
recipe = {
|
||||
{'technic:copper_coil', 'pipeworks:tube_1', 'technic:copper_coil'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- Teleport tube
|
||||
if pipeworks.enable_teleport_tube then
|
||||
minetest.clear_craft({
|
||||
output = "pipeworks:teleport_tube_1",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:teleport_tube_1',
|
||||
recipe = {
|
||||
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
|
||||
{'pipeworks:tube_1', 'technic:control_logic_unit', 'pipeworks:tube_1'},
|
||||
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- tubes crafting recipes
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:tube_000000 9',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:mese_tube_000000',
|
||||
recipe = {
|
||||
{'default:mese_crystal_fragment', 'pipeworks:tube_000000', 'default:mese_crystal_fragment'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:accelerator_tube_000000',
|
||||
recipe = {
|
||||
{'technic:copper_coil', 'pipeworks:tube_000000', 'technic:copper_coil'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:detector_tube_off_000000',
|
||||
recipe = {
|
||||
{'mesecons:mesecon', 'pipeworks:tube_000000', 'mesecons:mesecon'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:sand_tube_000000',
|
||||
recipe = {
|
||||
{'default:sand', 'pipeworks:tube_000000', 'default:sand'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:mese_sand_tube_000000',
|
||||
recipe = {
|
||||
{'default:mese_crystal_fragment', 'pipeworks:sand_tube_000000', 'default:mese_crystal_fragment'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:teleport_tube_000000',
|
||||
recipe = {
|
||||
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
|
||||
{'pipeworks:tube_000000', 'technic:control_logic_unit', 'pipeworks:tube_000000'},
|
||||
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:diamond_drill_head',
|
||||
recipe = {
|
||||
@ -73,18 +61,18 @@ minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
output = 'technic:blue_energy_crystal',
|
||||
recipe = {
|
||||
{'default:gold_ingot', 'technic:battery', 'dye:blue'},
|
||||
{'moreores:mithril_ingot', 'technic:battery', 'dye:blue'},
|
||||
{'technic:battery', 'technic:green_energy_crystal', 'technic:battery'},
|
||||
{'dye:blue', 'technic:battery', 'default:gold_ingot'},
|
||||
{'dye:blue', 'technic:battery', 'moreores:mithril_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:red_energy_crystal',
|
||||
recipe = {
|
||||
{'default:gold_ingot', 'technic:battery', 'dye:red'},
|
||||
{'moreores:silver_ingot', 'technic:battery', 'dye:red'},
|
||||
{'technic:battery', 'default:diamondblock', 'technic:battery'},
|
||||
{'dye:red', 'technic:battery', 'default:gold_ingot'},
|
||||
{'dye:red', 'technic:battery', 'moreores:silver_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
@ -97,46 +85,66 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:fine_gold_wire 2',
|
||||
recipe = {
|
||||
{'', 'default:gold_ingot', ''},
|
||||
{'', 'default:gold_ingot', ''},
|
||||
{'', 'default:gold_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:fine_silver_wire 2',
|
||||
recipe = {
|
||||
{'', 'moreores:silver_ingot', ''},
|
||||
{'', 'moreores:silver_ingot', ''},
|
||||
{'', 'moreores:silver_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:copper_coil 1',
|
||||
recipe = {
|
||||
{'technic:fine_copper_wire', 'default:steel_ingot', 'technic:fine_copper_wire'},
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'technic:fine_copper_wire', 'default:steel_ingot', 'technic:fine_copper_wire'},
|
||||
{'technic:fine_copper_wire', 'technic:wrought_iron_ingot', 'technic:fine_copper_wire'},
|
||||
{'technic:wrought_iron_ingot', '', 'technic:wrought_iron_ingot'},
|
||||
{'technic:fine_copper_wire', 'technic:wrought_iron_ingot', 'technic:fine_copper_wire'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:motor',
|
||||
recipe = {
|
||||
{'default:steel_ingot', 'technic:copper_coil', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'technic:copper_coil', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
|
||||
{'technic:carbon_steel_ingot', 'technic:copper_coil', 'technic:carbon_steel_ingot'},
|
||||
{'technic:carbon_steel_ingot', 'technic:copper_coil', 'technic:carbon_steel_ingot'},
|
||||
{'technic:carbon_steel_ingot', 'default:copper_ingot', 'technic:carbon_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
local isolation = mesecons_materials and "mesecons_materials:fiber" or "technic:rubber"
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:lv_transformer',
|
||||
recipe = {
|
||||
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
|
||||
{'technic:copper_coil', 'default:iron_lump', 'technic:copper_coil'},
|
||||
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
|
||||
{isolation, 'technic:wrought_iron_ingot', isolation},
|
||||
{'technic:copper_coil', 'technic:wrought_iron_ingot', 'technic:copper_coil'},
|
||||
{'technic:wrought_iron_ingot', 'technic:wrought_iron_ingot', 'technic:wrought_iron_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_transformer',
|
||||
recipe = {
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
{'technic:copper_coil', 'default:steel_ingot', 'technic:copper_coil'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
{isolation, 'technic:carbon_steel_ingot', isolation},
|
||||
{'technic:copper_coil', 'technic:carbon_steel_ingot', 'technic:copper_coil'},
|
||||
{'technic:carbon_steel_ingot', 'technic:carbon_steel_ingot', 'technic:carbon_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_transformer',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
|
||||
{isolation, 'technic:stainless_steel_ingot', isolation},
|
||||
{'technic:copper_coil', 'technic:stainless_steel_ingot', 'technic:copper_coil'},
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
@ -145,9 +153,9 @@ minetest.register_craft({
|
||||
minetest.register_craft({
|
||||
output = 'technic:control_logic_unit',
|
||||
recipe = {
|
||||
{'', 'default:gold_ingot', ''},
|
||||
{'', 'technic:fine_gold_wire', ''},
|
||||
{'default:copper_ingot', 'technic:silicon_wafer', 'default:copper_ingot'},
|
||||
{'', 'default:copper_ingot', ''},
|
||||
{'', 'technic:chromium_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
@ -156,7 +164,7 @@ minetest.register_craft({
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
|
||||
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
|
||||
{'moreores:tin_ingot', 'moreores:tin_ingot', 'moreores:tin_ingot'},
|
||||
{'default:tin_ingot', 'default:tin_ingot', 'default:tin_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
@ -167,22 +175,24 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:nothing", {
|
||||
description = "",
|
||||
inventory_image = "blank.png",
|
||||
minetest.register_craft({
|
||||
output = "technic:machine_casing",
|
||||
recipe = {
|
||||
{ "technic:cast_iron_ingot", "technic:cast_iron_ingot", "technic:cast_iron_ingot" },
|
||||
{ "technic:cast_iron_ingot", "technic:brass_ingot", "technic:cast_iron_ingot" },
|
||||
{ "technic:cast_iron_ingot", "technic:cast_iron_ingot", "technic:cast_iron_ingot" },
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "default:dirt 2",
|
||||
type = "shapeless",
|
||||
output = "technic:nothing",
|
||||
recipe = {"default:copper_ingot", "default:steel_ingot"}
|
||||
replacements = {{"bucket:bucket_water","bucket:bucket_empty"}},
|
||||
recipe = {
|
||||
"technic:stone_dust",
|
||||
"group:leaves",
|
||||
"bucket:bucket_water",
|
||||
"group:sand",
|
||||
},
|
||||
})
|
||||
|
||||
if minetest.register_craft_predict then
|
||||
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv)
|
||||
if itemstack:get_name() == "technic:nothing" then
|
||||
return ItemStack("")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
default
|
||||
moreores
|
||||
pipeworks
|
||||
mesecons
|
||||
technic_worldgen
|
||||
bucket?
|
||||
screwdriver?
|
||||
mesecons?
|
||||
mesecons_mvps?
|
||||
digilines?
|
||||
digiline_remote?
|
||||
intllib?
|
||||
unified_inventory?
|
||||
vector_extras?
|
||||
|
133
technic/doc/api.md
Normal file
133
technic/doc/api.md
Normal file
@ -0,0 +1,133 @@
|
||||
This file is fairly incomplete. Help is welcome.
|
||||
|
||||
Tiers
|
||||
-----
|
||||
The tier is a string, currently `"LV"`, `"MV"` and `"HV"` are supported.
|
||||
|
||||
Network
|
||||
-------
|
||||
The network is the cable with the connected machine nodes. Currently the
|
||||
switching station handles the network activity.
|
||||
|
||||
Helper functions
|
||||
----------------
|
||||
* `technic.EU_string(num)`
|
||||
* Converts num to a human-readable string (see pretty_num)
|
||||
and adds the `EU` unit
|
||||
* Use this function when showing players energy values
|
||||
* `technic.pretty_num(num)`
|
||||
* Converts the number `num` to a human-readable string with SI prefixes
|
||||
* `technic.swap_node(pos, nodename)`
|
||||
* Same as `mintest.swap_node` but it only changes the nodename.
|
||||
* It uses `minetest.get_node` before swapping to ensure the new nodename
|
||||
is not the same as the current one.
|
||||
* `technic.get_or_load_node(pos)`
|
||||
* If the mapblock is loaded, it returns the node at pos,
|
||||
else it loads the chunk and returns `nil`.
|
||||
* `technic.set_RE_wear(itemstack, item_load, max_charge)`
|
||||
* If the `wear_represents` field in the item's nodedef is
|
||||
`"technic_RE_charge"`, this function does nothing.
|
||||
* `technic.refill_RE_charge(itemstack)`
|
||||
* This function fully recharges an RE chargeable item.
|
||||
* If `technic.power_tools[itemstack:get_name()]` is `nil` (or `false`), this
|
||||
function does nothing, else that value is the maximum charge.
|
||||
* The itemstack metadata is changed to contain the charge.
|
||||
* `technic.is_tier_cable(nodename, tier)`
|
||||
* Tells whether the node `nodename` is the cable of the tier `tier`.
|
||||
* `technic.get_cable_tier(nodename)`
|
||||
* Returns the tier of the cable `nodename` or `nil`.
|
||||
* `technic.trace_node_ray(pos, dir, range)`
|
||||
* Returns an iteration function (usable in the for loop) to iterate over the
|
||||
node positions along the specified ray.
|
||||
* The returned positions will not include the starting position `pos`.
|
||||
* `technic.trace_node_ray_fat(pos, dir, range)`
|
||||
* Like `technic.trace_node_ray` but includes extra positions near the ray.
|
||||
* The node ray functions are used for mining lasers.
|
||||
* `technic.config:get(name)`
|
||||
* Some configuration function
|
||||
* `technic.tube_inject_item(pos, start_pos, velocity, item)`
|
||||
* Same as `pipeworks.tube_inject_item`
|
||||
|
||||
Registration functions
|
||||
----------------------
|
||||
* `technic.register_power_tool(itemname, max_charge)`
|
||||
* Same as `technic.power_tools[itemname] = max_charge`
|
||||
* This function makes the craftitem `itemname` chargeable.
|
||||
* `technic.register_machine(tier, nodename, machine_type)`
|
||||
* Same as `technic.machines[tier][nodename] = machine_type`
|
||||
* Currently this is requisite to make technic recognize your node.
|
||||
* See also `Machine types`
|
||||
* `technic.register_tier(tier)`
|
||||
* Same as `technic.machines[tier] = {}`
|
||||
* See also `tiers`
|
||||
|
||||
### Specific machines
|
||||
* `technic.register_solar_array(data)`
|
||||
* data is a table
|
||||
|
||||
Used itemdef fields
|
||||
-------------------
|
||||
* groups:
|
||||
* `technic_<ltier> = 1` ltier is a tier in small letters; this group makes
|
||||
the node connect to the cable(s) of the right tier.
|
||||
* `technic_machine = 1` Currently used for
|
||||
* `connect_sides`
|
||||
* In addition to the default use (see lua_api.txt), this tells where the
|
||||
machine can be connected.
|
||||
#
|
||||
#
|
||||
* `technic_run(pos, node)`
|
||||
* This function is currently used to update the node.
|
||||
Modders have to manually change the information about supply etc. in the
|
||||
node metadata.
|
||||
|
||||
Machine types
|
||||
-------------
|
||||
There are currently following types:
|
||||
* `technic.receiver = "RE"` e.g. grinder
|
||||
* `technic.producer = "PR"` e.g. solar panel
|
||||
* `technic.producer_receiver = "PR_RE"` supply converter
|
||||
* `technic.battery = "BA"` e.g. LV batbox
|
||||
|
||||
Switching Station
|
||||
-----------------
|
||||
The switching station is the center of all power distribution on an electric
|
||||
network.
|
||||
|
||||
The station collects power from sources (PR), distributes it to sinks (RE),
|
||||
and uses the excess/shortfall to charge and discharge batteries (BA).
|
||||
|
||||
For now, all supply and demand values are expressed in kW.
|
||||
|
||||
It works like this:
|
||||
All PR,BA,RE nodes are indexed and tagged with the switching station.
|
||||
The tagging is a workaround to allow more stations to be built without allowing
|
||||
a cheat with duplicating power.
|
||||
All the RE nodes are queried for their current EU demand. Those which are off
|
||||
would require no or a small standby EU demand, while those which are on would
|
||||
require more.
|
||||
If the total demand is less than the available power they are all updated with
|
||||
the demand number.
|
||||
If any surplus exists from the PR nodes the batteries will be charged evenly
|
||||
with this.
|
||||
If the total demand requires draw on the batteries they will be discharged
|
||||
evenly.
|
||||
|
||||
If the total demand is more than the available power all RE nodes will be shut
|
||||
down. We have a brown-out situation.
|
||||
|
||||
Hence for now all the power distribution logic resides in this single node.
|
||||
|
||||
### Node meta usage
|
||||
Nodes connected to the network will have one or more of these parameters as meta
|
||||
data:
|
||||
* `<LV|MV|HV>_EU_supply` : Exists for PR and BA node types.
|
||||
This is the EU value supplied by the node. Output
|
||||
* `<LV|MV|HV>_EU_demand` : Exists for RE and BA node types.
|
||||
This is the EU value the node requires to run. Output
|
||||
* `<LV|MV|HV>_EU_input` : Exists for RE and BA node types.
|
||||
This is the actual EU value the network can give the node. Input
|
||||
|
||||
The reason the LV|MV|HV type is prepended to meta data is because some machine
|
||||
could require several supplies to work.
|
||||
This way the supplies are separated per network.
|
@ -1,10 +1,224 @@
|
||||
function get_item_meta (string)
|
||||
if string.find(string, "return {") then
|
||||
return minetest.deserialize(string)
|
||||
else return nil
|
||||
local constant_digit_count = technic.config:get("constant_digit_count")
|
||||
|
||||
-- converts a number to a readable string with SI prefix, e.g. 10000 → "10 k",
|
||||
-- 15 → "15 ", 0.1501 → "150.1 m"
|
||||
-- a non-breaking space (U+a0) instead of a usual one is put after number
|
||||
-- The precision is 4 digits
|
||||
local prefixes = {[-8] = "y", [-7] = "z", [-6] = "a", [-5] = "f", [-4] = "p",
|
||||
[-3] = "n", [-2] = "µ", [-1] = "m", [0] = "", [1] = "k", [2] = "M",
|
||||
[3] = "G", [4] = "T", [5] = "P", [6] = "E", [7] = "Z", [8] = "Y"}
|
||||
function technic.pretty_num(num)
|
||||
-- the small number added is due to floating point inaccuracy
|
||||
local b = math.floor(math.log10(math.abs(num)) +0.000001)
|
||||
local pref_i
|
||||
if b ~= 0 then
|
||||
-- b is decremented by 1 to avoid a single digit with many decimals,
|
||||
-- e.g. instead of 1.021 MEU, 1021 kEU is shown
|
||||
pref_i = math.floor((b - 1) / 3)
|
||||
else
|
||||
-- as special case, avoid showing e.g. 1100 mEU instead of 1.1 EU
|
||||
pref_i = 0
|
||||
end
|
||||
if not prefixes[pref_i] then
|
||||
-- This happens for 0, nan, inf, very big values, etc.
|
||||
if num == 0 then
|
||||
-- handle 0 explicilty to avoid showing "-0"
|
||||
if not constant_digit_count then
|
||||
return "0 "
|
||||
end
|
||||
-- gives 0.000
|
||||
return string.format("%.3f ", 0)
|
||||
end
|
||||
return string.format("%.4g ", num)
|
||||
end
|
||||
|
||||
num = num * 10 ^ (-3 * pref_i)
|
||||
if constant_digit_count then
|
||||
local comma_digits_cnt = 3 - (b - 3 * pref_i)
|
||||
return string.format("%." .. comma_digits_cnt .. "f %s",
|
||||
num, prefixes[pref_i])
|
||||
end
|
||||
return string.format("%.4g %s", num, prefixes[pref_i])
|
||||
end
|
||||
|
||||
-- some unittests
|
||||
assert(technic.pretty_num(-0) == "0 ")
|
||||
assert(technic.pretty_num(0) == "0 ")
|
||||
assert(technic.pretty_num(1234) == "1234 ")
|
||||
assert(technic.pretty_num(123456789) == "123.5 M")
|
||||
|
||||
|
||||
-- used to display power values
|
||||
function technic.EU_string(num)
|
||||
return technic.pretty_num(num) .. "EU"
|
||||
end
|
||||
|
||||
|
||||
--- Same as minetest.swap_node, but only changes name
|
||||
-- and doesn't re-set if already set.
|
||||
function technic.swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name ~= name then
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
function set_item_meta (table)
|
||||
return minetest.serialize(table)
|
||||
|
||||
--- Fully charge RE chargeable item.
|
||||
-- Must be defined early to reference in item definitions.
|
||||
function technic.refill_RE_charge(stack)
|
||||
local max_charge = technic.power_tools[stack:get_name()]
|
||||
if not max_charge then return stack end
|
||||
technic.set_RE_wear(stack, max_charge, max_charge)
|
||||
local meta = minetest.deserialize(stack:get_metadata()) or {}
|
||||
meta.charge = max_charge
|
||||
stack:set_metadata(minetest.serialize(meta))
|
||||
return stack
|
||||
end
|
||||
|
||||
|
||||
-- If the node is loaded, returns it. If it isn't loaded, load it and return nil.
|
||||
function technic.get_or_load_node(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node then return node end
|
||||
local vm = VoxelManip()
|
||||
local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
technic.tube_inject_item = pipeworks.tube_inject_item or function(pos, start_pos, velocity, item)
|
||||
local tubed = pipeworks.tube_item(vector.new(pos), item)
|
||||
tubed:get_luaentity().start_pos = vector.new(start_pos)
|
||||
tubed:setvelocity(velocity)
|
||||
tubed:setacceleration(vector.new(0, 0, 0))
|
||||
end
|
||||
|
||||
|
||||
--- Iterates over the node positions along the specified ray.
|
||||
-- The returned positions will not include the starting position.
|
||||
function technic.trace_node_ray(pos, dir, range)
|
||||
local x_step = dir.x > 0 and 1 or -1
|
||||
local y_step = dir.y > 0 and 1 or -1
|
||||
local z_step = dir.z > 0 and 1 or -1
|
||||
|
||||
local i = 1
|
||||
return function(p)
|
||||
-- Approximation of where we should be if we weren't rounding
|
||||
-- to nodes. This moves forward a bit faster then we do.
|
||||
-- A correction is done below.
|
||||
local real_x = pos.x + (dir.x * i)
|
||||
local real_y = pos.y + (dir.y * i)
|
||||
local real_z = pos.z + (dir.z * i)
|
||||
|
||||
-- How far off we've gotten from where we should be.
|
||||
local dx = math.abs(real_x - p.x)
|
||||
local dy = math.abs(real_y - p.y)
|
||||
local dz = math.abs(real_z - p.z)
|
||||
|
||||
-- If the real position moves ahead too fast, stop it so we
|
||||
-- can catch up. If it gets too far ahead it will smooth
|
||||
-- out our movement too much and we won't turn fast enough.
|
||||
if dx + dy + dz < 2 then
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
-- Step in whichever direction we're most off course in.
|
||||
if dx > dy then
|
||||
if dx > dz then
|
||||
p.x = p.x + x_step
|
||||
else
|
||||
p.z = p.z + z_step
|
||||
end
|
||||
elseif dy > dz then
|
||||
p.y = p.y + y_step
|
||||
else
|
||||
p.z = p.z + z_step
|
||||
end
|
||||
if vector.distance(pos, p) > range then
|
||||
return nil
|
||||
end
|
||||
return p
|
||||
end, vector.round(pos)
|
||||
end
|
||||
|
||||
|
||||
--- Like trace_node_ray, but includes extra positions close to the ray.
|
||||
function technic.trace_node_ray_fat(pos, dir, range)
|
||||
local x_step = dir.x > 0 and 1 or -1
|
||||
local y_step = dir.y > 0 and 1 or -1
|
||||
local z_step = dir.z > 0 and 1 or -1
|
||||
|
||||
local next_poses = {}
|
||||
|
||||
local i = 1
|
||||
return function(p)
|
||||
local ni, np = next(next_poses)
|
||||
if np then
|
||||
next_poses[ni] = nil
|
||||
return np
|
||||
end
|
||||
|
||||
-- Approximation of where we should be if we weren't rounding
|
||||
-- to nodes. This moves forward a bit faster then we do.
|
||||
-- A correction is done below.
|
||||
local real_x = pos.x + (dir.x * i)
|
||||
local real_y = pos.y + (dir.y * i)
|
||||
local real_z = pos.z + (dir.z * i)
|
||||
|
||||
-- How far off we've gotten from where we should be.
|
||||
local dx = math.abs(real_x - p.x)
|
||||
local dy = math.abs(real_y - p.y)
|
||||
local dz = math.abs(real_z - p.z)
|
||||
|
||||
-- If the real position moves ahead too fast, stop it so we
|
||||
-- can catch up. If it gets too far ahead it will smooth
|
||||
-- out our movement too much and we won't turn fast enough.
|
||||
if dx + dy + dz < 2 then
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
-- Step in whichever direction we're most off course in.
|
||||
local sx, sy, sz -- Whether we've already stepped along each axis
|
||||
if dx > dy then
|
||||
if dx > dz then
|
||||
sx = true
|
||||
p.x = p.x + x_step
|
||||
else
|
||||
sz = true
|
||||
p.z = p.z + z_step
|
||||
end
|
||||
elseif dy > dz then
|
||||
sy = true
|
||||
p.y = p.y + y_step
|
||||
else
|
||||
sz = true
|
||||
p.z = p.z + z_step
|
||||
end
|
||||
|
||||
if vector.distance(pos, p) > range then
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Add other positions that we're significantly off on.
|
||||
-- We can just use fixed integer keys here because the
|
||||
-- table will be completely cleared before we reach this
|
||||
-- code block again.
|
||||
local dlen = math.sqrt(dx*dx + dy*dy + dz*dz)
|
||||
-- Normalized axis deltas
|
||||
local dxn, dyn, dzn = dx / dlen, dy / dlen, dz / dlen
|
||||
if not sx and dxn > 0.5 then
|
||||
next_poses[1] = vector.new(p.x + x_step, p.y, p.z)
|
||||
end
|
||||
if not sy and dyn > 0.5 then
|
||||
next_poses[2] = vector.new(p.x, p.y + y_step, p.z)
|
||||
end
|
||||
if not sz and dzn > 0.5 then
|
||||
next_poses[3] = vector.new(p.x, p.y, p.z + z_step)
|
||||
end
|
||||
|
||||
return p
|
||||
end, vector.round(pos)
|
||||
end
|
||||
|
||||
|
@ -2,17 +2,21 @@
|
||||
-- namespace: technic
|
||||
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
|
||||
|
||||
technic = {}
|
||||
|
||||
local load_start = os.clock()
|
||||
|
||||
technic = rawget(_G, "technic") or {}
|
||||
technic.creative_mode = minetest.settings:get_bool("creative_mode")
|
||||
|
||||
|
||||
local modpath = minetest.get_modpath("technic")
|
||||
technic.modpath = modpath
|
||||
|
||||
|
||||
-- Boilerplate to support intllib
|
||||
if intllib then
|
||||
if rawget(_G, "intllib") then
|
||||
technic.getter = intllib.Getter()
|
||||
else
|
||||
technic.getter = function(s) return s end
|
||||
technic.getter = function(s,a,...)if a==nil then return s end a={a,...}return s:gsub("(@?)@(%(?)(%d+)(%)?)",function(e,o,n,c)if e==""then return a[tonumber(n)]..(o==""and c or"")else return"@"..o..n..c end end) end
|
||||
end
|
||||
local S = technic.getter
|
||||
|
||||
@ -31,6 +35,9 @@ dofile(modpath.."/crafts.lua")
|
||||
-- Register functions
|
||||
dofile(modpath.."/register.lua")
|
||||
|
||||
-- Radiation
|
||||
dofile(modpath.."/radiation.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(modpath.."/machines/init.lua")
|
||||
|
||||
@ -40,28 +47,7 @@ dofile(modpath.."/tools/init.lua")
|
||||
-- Aliases for legacy node/item names
|
||||
dofile(modpath.."/legacy.lua")
|
||||
|
||||
function has_locked_chest_privilege(meta, player)
|
||||
if player:get_player_name() ~= meta:get_string("owner") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Swap nodes out. Return the node name.
|
||||
function hacky_swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name ~= name then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta_table = meta:to_table()
|
||||
node.name = name
|
||||
minetest.set_node(pos, node)
|
||||
meta = minetest.get_meta(pos)
|
||||
meta:from_table(meta_table)
|
||||
end
|
||||
return node.name
|
||||
end
|
||||
|
||||
if minetest.setting_get("log_mod") then
|
||||
if minetest.settings:get_bool("log_mods") then
|
||||
print(S("[Technic] Loaded in %f seconds"):format(os.clock() - load_start))
|
||||
end
|
||||
|
||||
|
@ -11,11 +11,6 @@ minetest.register_craftitem( "technic:doped_silicon_wafer", {
|
||||
inventory_image = "technic_doped_silicon_wafer.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:enriched_uranium", {
|
||||
description = S("Enriched Uranium"),
|
||||
inventory_image = "technic_enriched_uranium.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:uranium_fuel", {
|
||||
description = S("Uranium Fuel"),
|
||||
inventory_image = "technic_uranium_fuel.png",
|
||||
@ -32,6 +27,8 @@ minetest.register_tool("technic:blue_energy_crystal", {
|
||||
"technic_diamond_block_blue.png",
|
||||
"technic_diamond_block_blue.png",
|
||||
"technic_diamond_block_blue.png"),
|
||||
wear_represents = "technic_RE_charge",
|
||||
on_refill = technic.refill_RE_charge,
|
||||
tool_capabilities = {
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
@ -46,6 +43,8 @@ minetest.register_tool("technic:green_energy_crystal", {
|
||||
"technic_diamond_block_green.png",
|
||||
"technic_diamond_block_green.png",
|
||||
"technic_diamond_block_green.png"),
|
||||
wear_represents = "technic_RE_charge",
|
||||
on_refill = technic.refill_RE_charge,
|
||||
tool_capabilities = {
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
@ -60,6 +59,8 @@ minetest.register_tool("technic:red_energy_crystal", {
|
||||
"technic_diamond_block_red.png",
|
||||
"technic_diamond_block_red.png",
|
||||
"technic_diamond_block_red.png"),
|
||||
wear_represents = "technic_RE_charge",
|
||||
on_refill = technic.refill_RE_charge,
|
||||
tool_capabilities = {
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
@ -74,6 +75,16 @@ minetest.register_craftitem("technic:fine_copper_wire", {
|
||||
inventory_image = "technic_fine_copper_wire.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:fine_gold_wire", {
|
||||
description = S("Fine Gold Wire"),
|
||||
inventory_image = "technic_fine_gold_wire.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:fine_silver_wire", {
|
||||
description = S("Fine Silver Wire"),
|
||||
inventory_image = "technic_fine_silver_wire.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:copper_coil", {
|
||||
description = S("Copper Coil"),
|
||||
inventory_image = "technic_copper_coil.png",
|
||||
@ -89,10 +100,6 @@ minetest.register_craftitem("technic:lv_transformer", {
|
||||
inventory_image = "technic_lv_transformer.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:lv_transformer", {
|
||||
description = S("Low Voltage Transformer"),
|
||||
inventory_image = "technic_lv_transformer.png",
|
||||
})
|
||||
minetest.register_craftitem("technic:mv_transformer", {
|
||||
description = S("Medium Voltage Transformer"),
|
||||
inventory_image = "technic_mv_transformer.png",
|
||||
@ -138,3 +145,80 @@ minetest.register_craftitem("technic:carbon_cloth", {
|
||||
inventory_image = "technic_carbon_cloth.png",
|
||||
})
|
||||
|
||||
minetest.register_node("technic:machine_casing", {
|
||||
description = S("Machine Casing"),
|
||||
groups = {cracky=2},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
drawtype = "allfaces",
|
||||
tiles = {"technic_machine_casing.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
for p = 0, 35 do
|
||||
local nici = (p ~= 0 and p ~= 7 and p ~= 35) and 1 or nil
|
||||
local psuffix = p == 7 and "" or p
|
||||
local ingot = "technic:uranium"..psuffix.."_ingot"
|
||||
local block = "technic:uranium"..psuffix.."_block"
|
||||
local ov = p == 7 and minetest.override_item or nil;
|
||||
(ov or minetest.register_craftitem)(ingot, {
|
||||
description = string.format(S("%.1f%%-Fissile Uranium Ingot"), p/10),
|
||||
inventory_image = "technic_uranium_ingot.png",
|
||||
groups = {uranium_ingot=1, not_in_creative_inventory=nici},
|
||||
});
|
||||
-- Note on radioactivity of blocks:
|
||||
-- Source: <http://www.wise-uranium.org/rup.html>
|
||||
-- The baseline radioactivity of an isotope is not especially
|
||||
-- correlated with whether it's fissile (i.e., suitable as
|
||||
-- reactor fuel). Natural uranium consists mainly of fissile
|
||||
-- U-235 and non-fissile U-238, and both U-235 and U-238 are
|
||||
-- significantly radioactive. U-235's massic activity is
|
||||
-- about 80.0 MBq/kg, and U-238's is about 12.4 MBq/kg, which
|
||||
-- superficially suggests that 3.5%-fissile uranium should have
|
||||
-- only 1.19 times the activity of fully-depleted uranium.
|
||||
-- But a third isotope affects the result hugely: U-234 has
|
||||
-- massic activity of 231 GBq/kg. Natural uranium has massic
|
||||
-- composition of 99.2837% U-238, 0.711% U-235, and 0.0053% U-234,
|
||||
-- so its activity comes roughly 49% each from U-234 and U-238
|
||||
-- and only 2% from U-235. During enrichment via centrifuge,
|
||||
-- the U-234 fraction is concentrated along with the U-235, with
|
||||
-- the U-234:U-235 ratio remaining close to its original value.
|
||||
-- (Actually the U-234 gets separated from U-238 slightly more
|
||||
-- than the U-235 is, so the U-234:U-235 ratio is slightly
|
||||
-- higher in enriched uranium.) A typical massic composition
|
||||
-- for 3.5%-fissile uranium is 96.47116% U-238, 3.5% U-235, and
|
||||
-- 0.02884% U-234. This gives 3.5%-fissile uranium about 6.55
|
||||
-- times the activity of fully-depleted uranium. The values we
|
||||
-- compute here for the "radioactive" group value are based on
|
||||
-- linear interpolation of activity along that scale, rooted at
|
||||
-- a natural (0.7%-fissile) uranium block having the activity of
|
||||
-- 9 uranium ore blocks (due to 9 ingots per block). The group
|
||||
-- value is proportional to the square root of the activity, and
|
||||
-- uranium ore has radioactive=1. This yields radioactive=1.0
|
||||
-- for a fully-depleted uranium block and radioactive=2.6 for
|
||||
-- a 3.5%-fissile uranium block.
|
||||
local radioactivity = math.floor(math.sqrt((1+5.55*p/35) * 18 / (1+5.55*7/35)) + 0.5);
|
||||
(ov or minetest.register_node)(block, {
|
||||
description = string.format(S("%.1f%%-Fissile Uranium Block"), p/10),
|
||||
tiles = {"technic_uranium_block.png"},
|
||||
is_ground_content = true,
|
||||
groups = {uranium_block=1, not_in_creative_inventory=nici,
|
||||
cracky=1, level=2, radioactive=radioactivity},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
});
|
||||
if not ov then
|
||||
minetest.register_craft({
|
||||
output = block,
|
||||
recipe = {
|
||||
{ingot, ingot, ingot},
|
||||
{ingot, ingot, ingot},
|
||||
{ingot, ingot, ingot},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = ingot.." 9",
|
||||
recipe = {{block}},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -17,16 +17,25 @@ technic.legacy_nodenames = {
|
||||
["technic:electric_furnace_active"] = "technic:lv_electric_furnace_active",
|
||||
["technic:grinder"] = "technic:lv_grinder",
|
||||
["technic:grinder_active"] = "technic:lv_grinder_active",
|
||||
["technic:extractor"] = "technic:lv_extractor",
|
||||
["technic:extractor_active"] = "technic:lv_extractor_active",
|
||||
["technic:compressor"] = "technic:lv_compressor",
|
||||
["technic:compressor_active"] = "technic:lv_compressor_active",
|
||||
["technic:hv_battery_box"] = "technic:hv_battery_box0",
|
||||
["technic:hv_cable"] = "technic:hv_cable0",
|
||||
["technic:lv_cable"] = "technic:lv_cable0",
|
||||
["technic:mv_cable"] = "technic:mv_cable0",
|
||||
["technic:mv_battery_box"] = "technic:mv_battery_box0",
|
||||
["technic:generator"] = "technic:lv_generator",
|
||||
["technic:generator_active"] = "technic:lv_generator_active",
|
||||
["technic:iron_dust"] = "technic:wrought_iron_dust",
|
||||
["technic:enriched_uranium"] = "technic:uranium35_ingot",
|
||||
}
|
||||
|
||||
for old, new in pairs(technic.legacy_nodenames) do
|
||||
minetest.register_alias(old, new)
|
||||
end
|
||||
|
||||
for i = 0, 64 do
|
||||
minetest.register_alias("technic:hv_cable"..i, "technic:hv_cable")
|
||||
minetest.register_alias("technic:mv_cable"..i, "technic:mv_cable")
|
||||
minetest.register_alias("technic:lv_cable"..i, "technic:lv_cable")
|
||||
end
|
||||
|
||||
|
204
technic/locale/de.txt
Normal file
204
technic/locale/de.txt
Normal file
@ -0,0 +1,204 @@
|
||||
# German Translation for Technic Mod
|
||||
# Deutsche Uebersetzung des Technic Mods
|
||||
# by Xanthin
|
||||
|
||||
## Misc
|
||||
[Technic] Loaded in %f seconds = [Technic] ist in %f Sekunden geladen
|
||||
|
||||
## Items
|
||||
Silicon Wafer = Siliziumscheibe
|
||||
Doped Silicon Wafer = Dotierte Siliziumscheibe
|
||||
Enriched Uranium = Angereichertes Uran
|
||||
Uranium Fuel = Uranbrennstoff
|
||||
Diamond Drill Head = Diamantbohrkopf
|
||||
Blue Energy Crystal = Blauer Energiekristall
|
||||
Green Energy Crystal = Gruener Energiekristall
|
||||
Red Energy Crystal = Roter Energiekristall
|
||||
Fine Copper Wire = Feinkupferdraht
|
||||
Copper Coil = Kupferspule
|
||||
Electric Motor = Elektromotor
|
||||
Low Voltage Transformer = Niederspannungstransformator
|
||||
Medium Voltage Transformer = Mittelspannungstransformator
|
||||
High Voltage Transformer = Hochspannungstransformator
|
||||
Control Logic Unit = Steuer- und Regelungseinheit
|
||||
Mixed Metal Ingot = Mischmetallbarren
|
||||
Composite Plate = Verbundplatte
|
||||
Copper Plate = Kupferplatte
|
||||
Carbon Plate = Kohlefaserplatte
|
||||
Graphite = Graphit
|
||||
Carbon Cloth = Kohlefasergewebe
|
||||
Raw Latex = Rohlatex
|
||||
Rubber Fiber = Gummifaser
|
||||
%.1f%%-Fissile Uranium Ingot =
|
||||
%.1f%%-Fissile Uranium Block =
|
||||
|
||||
## Machine misc
|
||||
Machine cannot be removed because it is not empty = Die Maschine kann nicht entfernt werden, weil sie noch nicht leer ist.
|
||||
Inventory move disallowed due to protection = Das Inventar ist geschuetzt, Zugriff verweigert.
|
||||
# $1: Machine name (Includes tier)
|
||||
@1 Active (@2 EU) = @1 ist eingeschaltet (@2 EU)
|
||||
%s Active = %s ist eingeschaltet
|
||||
%s Disabled = %s ist ausgeschaltet
|
||||
%s Enabled =
|
||||
%s Idle = %s ist bereit
|
||||
%s Improperly Placed = %s ist falsch plaziert
|
||||
%s Unpowered = %s hat keine Stromversorgung
|
||||
%s Out Of Fuel = %s hat keinen Brennstoff
|
||||
%s Has Bad Cabling = %s ist falsch verkabelt
|
||||
%s Has No Network = %s hat kein Netzwerk
|
||||
%s Finished = %s ist fertig
|
||||
Enable/Disable = Einschalten/Ausschalten
|
||||
Range = Reichweite
|
||||
Upgrade Slots = Verbesserungsfaecher
|
||||
In: = Rein:
|
||||
Out: = Raus:
|
||||
Slot %d = Fach %d
|
||||
Itemwise = Einzelstuecke
|
||||
Stackwise = Ganzer Stapel
|
||||
Owner: =
|
||||
Unlocked =
|
||||
Locked =
|
||||
Radius: =
|
||||
Enabled =
|
||||
Disabled =
|
||||
|
||||
## Machine names
|
||||
# $1: Tier
|
||||
%s Alloy Furnace = %s Legierungsofen
|
||||
%s Battery Box = %s Batteriebox
|
||||
%s Cable = %s Kabel
|
||||
%s CNC Machine = %s CNC-Maschine
|
||||
%s Compressor = %s Kompressor
|
||||
%s Extractor = %s Extraktor
|
||||
%s Forcefield Emitter = %s Kraftfeld-Emitter
|
||||
%s Furnace = %s Ofen
|
||||
%s Grinder = %s Schleifmaschine
|
||||
%s Music Player = %s Musikspieler
|
||||
%s Quarry = %s Steinbruch
|
||||
%s Tool Workshop = %s Werkzeugwerkstatt
|
||||
Arrayed Solar %s Generator = %s Solaranlage
|
||||
Fuel-Fired %s Generator = %s Kohle-Generator
|
||||
Geothermal %s Generator = %s Geothermie-Generator
|
||||
Hydro %s Generator = %s Wassermuehle
|
||||
Nuclear %s Generator Core = %s Reaktorkern
|
||||
Small Solar %s Generator = %s Solarmodul
|
||||
Wind %s Generator = %s Windmuehle
|
||||
Self-Contained Injector = Selbstversorger-Injektor
|
||||
Constructor Mk%d = Konstruktor Modell %d
|
||||
Frame = Rahmen
|
||||
Frame Motor = Rahmenmotor
|
||||
Template = Schablone
|
||||
Template (replacing) = Schablone (ersetzend)
|
||||
Template motor = Schablonenmotor
|
||||
Template tool = Schablonenwerkzeug
|
||||
Battery Box = Batteriebox
|
||||
Supply Converter = Stromumwandler
|
||||
Switching Station = Schaltanlage
|
||||
Fuel-Fired Alloy Furnace = Kohle-Legierungsofen
|
||||
Fuel-Fired Furnace = Kohle-Ofen
|
||||
Wind Mill Frame = Windmuehlengeruest
|
||||
Forcefield = Kraftfeld
|
||||
Nuclear Reactor Rod Compartment = Brennstabfaecher
|
||||
Administrative World Anchor =
|
||||
|
||||
## Machine-specific
|
||||
# $1: Pruduced EU
|
||||
Charge = Aufladen
|
||||
Discharge = Entladen
|
||||
Power level = Energiestufe
|
||||
# $1: Tier $2: current_charge $3: max_charge
|
||||
@1 Battery Box: @2/@3 = @1 Batteriebox: @2/@3
|
||||
# $1: Machine name $2: Supply $3: Demand
|
||||
@1. Supply: @2 Demand: @3 = @1. Versorgung: @2 Bedarf: @3
|
||||
Production at %d%% = Produktion bei %d%%
|
||||
Choose Milling Program: = Waehle ein Fraesprogramm:
|
||||
Slim Elements half / normal height: = Schmale Elemente von halber / normaler Hoehe:
|
||||
Current track %s = Aktueller Titel %s
|
||||
Stopped =
|
||||
Keeping %d/%d map blocks loaded =
|
||||
Digging not started =
|
||||
Digging finished =
|
||||
Digging %d m above machine =
|
||||
Digging %d m below machine =
|
||||
|
||||
## CNC
|
||||
Cylinder = Zylinder
|
||||
Element Cross = Halbes Kreuzelement
|
||||
Element Cross Double = Kreuzelement
|
||||
Element Edge = Halbes Eckelement
|
||||
Element Edge Double = Eckelement
|
||||
Element End = Halbes Endelement
|
||||
Element End Double = Endelement
|
||||
Element Straight = Halbes aufrechtes Element
|
||||
Element Straight Double = Aufrechtes Element
|
||||
Element T = Halbes T-Element
|
||||
Element T Double = T-Element
|
||||
Horizontal Cylinder = Liegender Zylinder
|
||||
One Curved Edge Block = Block mit einer abgerundeten Kante
|
||||
Pyramid = Pyramide
|
||||
Slope = Schraege
|
||||
Slope Edge = Schraege mit Ecke
|
||||
Slope Inner Edge = Schraege mit Innenecke
|
||||
Slope Lying = Liegende Schraege
|
||||
Slope Upside Down = Umgedrehte Schraege
|
||||
Slope Upside Down Edge = Umgedrehte Schraege mit Ecke
|
||||
Slope Upside Down Inner Edge = Umgedrehte Schraege mit Innenecke
|
||||
Sphere = Kugel
|
||||
Spike = Spitze
|
||||
Stick = Stange
|
||||
Two Curved Edge Block = Block mit zwei abgerundeten Kanten
|
||||
Brick = Ziegel:
|
||||
Cobble = Pflasterstein:
|
||||
Dirt = Erde:
|
||||
Leaves = Laub:
|
||||
Sandstone = Sandstein:
|
||||
Stone = Stein:
|
||||
Tree = Baumstamm:
|
||||
Wooden = Holz:
|
||||
|
||||
## Grinder Recipes
|
||||
# $1: Name
|
||||
%s Dust = %sstaub
|
||||
Akalin = Akalin
|
||||
Alatro = Alatro
|
||||
Arol = Arol
|
||||
Brass = Messing
|
||||
Bronze = Bronze
|
||||
Carbon Steel = Kohlenstoffstahl
|
||||
Cast Iron = Gusseisen
|
||||
Chromium = Chrom
|
||||
Coal = Kohle
|
||||
Copper = Kupfer
|
||||
Gold = Gold
|
||||
Mithril = Mithril
|
||||
Silver = Silber
|
||||
Stainless Steel = Edelstahl
|
||||
Talinite = Talinite
|
||||
Tin = Zinn
|
||||
Wrought Iron = Schmiedeeisen
|
||||
Zinc = Zink
|
||||
%.1f%%-Fissile Uranium =
|
||||
|
||||
## Tools
|
||||
RE Battery = Akkubatterie
|
||||
Water Can = Wasserkanister
|
||||
Lava Can = Lavakanister
|
||||
Chainsaw = Kettensaege
|
||||
Flashlight = Taschenlampe
|
||||
3 nodes deep. = 3 Bloecke tief.
|
||||
3 nodes tall. = 3 Bloecke hoch.
|
||||
3 nodes wide. = 3 Bloecke breit.
|
||||
3x3 nodes. = 3x3 Bloecke.
|
||||
Use while sneaking to change Mining Drill Mk%d modes. = Halte die Shift-Taste beim Benutzen gedrueckt, um die Funktion des Bergbaubohrers Modell %d zu aendern.
|
||||
Mining Drill Mk%d Mode %d = Bergbaubohrer Modell %d Funktion %d
|
||||
Mining Drill Mk%d = Bergbaubohrer Modell %d
|
||||
Mining Laser Mk%d = Bergbaulaser Modell %d
|
||||
Single node. = Einzelblock
|
||||
Sonic Screwdriver = Schallschraubendreher
|
||||
Tree Tap = Baumzapfhahn
|
||||
|
||||
## Craft descriptions
|
||||
Alloy cooking =
|
||||
Grinding =
|
||||
Compressing =
|
||||
Extracting =
|
@ -1,4 +1,3 @@
|
||||
# es.txt
|
||||
# Spanish Translation for Technic Mod
|
||||
# Traduccion al Español del Mod Technic
|
||||
# Autor: Diego Martínez <kaeza>
|
||||
@ -30,11 +29,16 @@ Graphite = Grafito
|
||||
Carbon Cloth = Tela de Carbon
|
||||
Raw Latex = Latex Crudo
|
||||
Rubber Fiber = Fibra de Hule
|
||||
%.1f%%-Fissile Uranium Ingot =
|
||||
%.1f%%-Fissile Uranium Block =
|
||||
|
||||
## Machine misc
|
||||
Machine cannot be removed because it is not empty = La maquina no puede removerse porque no esta vacia
|
||||
Inventory move disallowed due to protection =
|
||||
# $1: Machine name (Includes tier)
|
||||
@1 Active (@2 EU) = @1 Activo (@2 EU)
|
||||
%s Active = %s Activo
|
||||
%s Enabled =
|
||||
%s Idle = %s Quieto
|
||||
%s Unpowered = %s Sin Energia
|
||||
%s Out Of Fuel = %s Sin Combustible
|
||||
@ -45,35 +49,53 @@ Machine cannot be removed because it is not empty = La maquina no puede removers
|
||||
%s Improperly Placed = %s No Colocado Apropiadamente
|
||||
Range = Alcance
|
||||
Enable/Disable = Habilitar/Deshabilitar
|
||||
Itemwise =
|
||||
Stackwise =
|
||||
Owner: =
|
||||
Unlocked =
|
||||
Locked =
|
||||
Radius: =
|
||||
Enabled =
|
||||
Disabled =
|
||||
|
||||
## Machine names
|
||||
# $1: Tier
|
||||
%s Alloy Furnace = Horno de Aleacion %s
|
||||
%s Battery Box = Caja de Bateria %s
|
||||
%s Cable = Cable %s
|
||||
%s Electric Furnace = Horno Electrico %s
|
||||
%s CNC Machine = Maquina CNC %s
|
||||
%s Compressor = Compresor %s
|
||||
%s Extractor = Extractor %s
|
||||
%s Forcefield Emitter = Emisor de Campo de Fuerza %s
|
||||
%s Furnace = Horno %s
|
||||
%s Grinder = Amoladora %s
|
||||
%s Generator = Generador %s
|
||||
%s Solar Array = Panel Solar %s
|
||||
%s Music Player = Reproductor de Musica %s
|
||||
%s Quarry = Cantera %s
|
||||
%s Tool Workshop = Taller de Herramientas %s
|
||||
Arrayed Solar %s Generator = Panel Solar %s
|
||||
Fuel-Fired %s Generator = Generador a Carbon %s
|
||||
Geothermal %s Generator = Generador Geotermico %s
|
||||
Hydro %s Generator = Molino de Agua %s
|
||||
Nuclear %s Generator Core = Nucleo de Reactor Nuclear %s
|
||||
Small Solar %s Generator = Panel Solar %s
|
||||
Wind %s Generator = Molino de Viento %s
|
||||
Self-Contained Injector =
|
||||
Constructor Mk%d =
|
||||
Frame =
|
||||
Frame Motor =
|
||||
Template =
|
||||
Template (replacing) =
|
||||
Template Motor =
|
||||
Template Tool =
|
||||
Supply Converter = Convertidor de Alimentacion
|
||||
Switching Station = Estacion de Conmutacion
|
||||
Battery Box = Caja de Baterias
|
||||
Quarry = Cantera
|
||||
CNC Machine = Maquina CNC
|
||||
Music Player = Reproductor de Musica
|
||||
Extractor = Extractor
|
||||
Coal Alloy Furnace = Horno de Aleacion a Carbon
|
||||
Tool WorkShop = Taller de Herramientas
|
||||
Fuel-Fired Alloy Furnace = Horno de Aleacion a Carbon
|
||||
Fuel-Fired Furnace = Horno a Carbon
|
||||
Forcefield = Campo de Fuerza
|
||||
Forcefield Emitter = Emisor de Campo de Fuerza
|
||||
Compressor = Compresor
|
||||
Geothermal Generator = Generador Geotermico
|
||||
Water Mill = Molino de Agua
|
||||
Nuclear Reactor Rod Compartment = Compartimiento para Vara de Reactor Nuclear
|
||||
Nuclear Reactor Core = Nucleo de Reactor Nuclear
|
||||
Wind Mill = Molino de Viento
|
||||
Wind Mill Frame = Armazon de Molino de Viento
|
||||
Solar Panel = Panel Solar
|
||||
Administrative World Anchor =
|
||||
|
||||
## Machine-specific
|
||||
# $1: Pruduced EU
|
||||
@ -81,11 +103,17 @@ Charge = Cargar
|
||||
Discharge = Descargar
|
||||
Power level = Nivel de Poder
|
||||
# $1: Tier $2: current_charge $3: max_charge
|
||||
%s Battery Box: %d/%d = Caja de Bateria %s: %d/%d
|
||||
@1 Battery Box: @2/@3 = Caja de Bateria @1: @2/@3
|
||||
# $1: Machine name $2: Supply $3: Demand
|
||||
%s. Supply: %d Demand: %d = %s. Alimentacion: %d Demanda: %d
|
||||
@1. Supply: @2 Demand: @3 = @1. Alimentacion: @2 Demanda: @3
|
||||
# $1: Production percent
|
||||
Production at %d%% = Produccion en %d%%
|
||||
Stopped =
|
||||
Keeping %d/%d map blocks loaded =
|
||||
Digging not started =
|
||||
Digging finished =
|
||||
Digging %d m above machine =
|
||||
Digging %d m below machine =
|
||||
|
||||
## CNC Machine
|
||||
Element Edge = Elemento Borde
|
||||
@ -113,7 +141,6 @@ Slope Edge = Borde de Rampa
|
||||
Slope = Rampa
|
||||
Element T = Elemento T
|
||||
Cylinder = Cilindro
|
||||
Steel = Acero
|
||||
Cobble = Adoquines
|
||||
Stone = Piedra
|
||||
Brick = Ladrillo
|
||||
@ -130,19 +157,23 @@ Alatro = Alatro
|
||||
Arol = Arol
|
||||
Brass = Laton
|
||||
Bronze = Bronce
|
||||
Carbon Steel = Acero al Carbono
|
||||
Cast Iron = Hierro Fundido
|
||||
Chromium = Cromo
|
||||
Coal = Carbon
|
||||
Copper = Cobre
|
||||
Gold = Oro
|
||||
Iron = Hierro
|
||||
Mithril = Mitrilo
|
||||
Silver = Plata
|
||||
Stainless Steel = Acero Inoxidable
|
||||
Talinite = Talinita
|
||||
Tin = Estanio
|
||||
Wrought Iron = Hierro Forjado
|
||||
Zinc = Zinc
|
||||
%.1f%%-Fissile Uranium =
|
||||
|
||||
## Tools
|
||||
RE Battery =
|
||||
Water Can = Bidon de Agua
|
||||
Lava Can = Bidon de Lava
|
||||
Chainsaw = Motosierra
|
||||
@ -151,7 +182,7 @@ Flashlight = Linterna
|
||||
3 nodes tall. = 3 nodos de alto.
|
||||
3 nodes wide. = 3 nodos de ancho.
|
||||
3x3 nodes. = 3x3 nodos.
|
||||
Hold shift and use to change Mining Drill Mk%d modes. = Manten pulsado Mayus y Usar para cambiar el modo del Taladro de Mineria Mk%d.
|
||||
Use while sneaking to change Mining Drill Mk%d modes. = Manten pulsado Mayus y Usar para cambiar el modo del Taladro de Mineria Mk%d.
|
||||
Mining Drill Mk%d Mode %d = Taladro de Mineria Mk%d Modo %d
|
||||
Mining Drill Mk%d = Taladro de Mineria Mk%d
|
||||
Mining Laser Mk%d = Laser de Mineria Mk%d
|
||||
@ -159,3 +190,8 @@ Single node. = Nodo simple.
|
||||
Sonic Screwdriver = Destonillador Sonico
|
||||
Tree Tap = Grifo de Arbol
|
||||
|
||||
## Craft descriptions
|
||||
Alloy cooking =
|
||||
Grinding =
|
||||
Compressing =
|
||||
Extracting =
|
||||
|
@ -26,12 +26,17 @@ Graphite = Lastra in graffite
|
||||
Carbon Cloth = Fibra di carbonio
|
||||
Raw Latex = Latex grezzo
|
||||
Rubber Fiber = Fibra di gomma
|
||||
%.1f%%-Fissile Uranium Ingot = %.1f%%-Lingotto di uranio fissile
|
||||
%.1f%%-Fissile Uranium Block = %.1f%%-Blocco di uranio fissile
|
||||
|
||||
## Machine misc
|
||||
Machine cannot be removed because it is not empty = La macchina non può essere rimossa perchè non è vuota
|
||||
Inventory move disallowed due to protection = Impossibile muovere l'inventario a causa della protezione
|
||||
# $1: Machine name (Includes tier)
|
||||
@1 Active (@2 EU) = @1 Attivo (@2 EU)
|
||||
%s Active = %s Attivo
|
||||
%s Disabled = %s Disabilitato
|
||||
%s Enabled = %s Abilitato
|
||||
%s Idle = %s Inattivo
|
||||
%s Improperly Placed = %s Piazzato impropiamente
|
||||
%s Unpowered = %s Non alimentato
|
||||
@ -41,36 +46,57 @@ Machine cannot be removed because it is not empty = La macchina non può essere
|
||||
%s Finished = %s Finito
|
||||
Enable/Disable = Abilita/Disabilita
|
||||
Range = Raggio
|
||||
|
||||
Upgrade Slots = Alloggi di aggiornamento
|
||||
In: = Ingresso:
|
||||
Out: = Uscita:
|
||||
Slot %d = Alloggio %d
|
||||
Itemwise = Singolo elemento
|
||||
Stackwise = pila completa
|
||||
Owner: = Proprietario:
|
||||
Unlocked = Non chiuso a chiave
|
||||
Locked = Chiuso a chiave
|
||||
Radius: = Raggio:
|
||||
Enabled = Abilitato
|
||||
Disabled = Disabilitato
|
||||
|
||||
## Machine names
|
||||
# $1: Tier
|
||||
%s Alloy Furnace = %s Fornace per leghe
|
||||
%s Battery Box = %s Box batterie
|
||||
%s Cable = Cavo %s
|
||||
%s Electric Furnace = %s Fornace elettrica
|
||||
%s CNC Machine = Tornio CNC %s
|
||||
%s Compressor = Compressore %s
|
||||
%s Extractor = Estrattore %s
|
||||
%s Forcefield Emitter = Emettitore di campo di forza %s
|
||||
%s Furnace = %s Fornace
|
||||
%s Grinder = %s Tritatutto
|
||||
%s Generator = %s Generatore
|
||||
%s Solar Array = %s Pannello Solare
|
||||
%s Music Player = Music Player %s
|
||||
%s Quarry = Cava %s
|
||||
%s Tool Workshop = Officina per attrezzi %s
|
||||
Arrayed Solar %s Generator = %s Pannello Solare
|
||||
Fuel-Fired %s Generator = %s Generatore a carbone
|
||||
Geothermal %s Generator = %s Generatore Geotermico
|
||||
Hydro %s Generator = Turbina Elettrica %s
|
||||
Nuclear %s Generator Core = Reattore nucleare %s
|
||||
Small Solar %s Generator = %s Pannello solare
|
||||
Wind %s Generator = %s Generatore eolico
|
||||
Self-Contained Injector = Ignettore
|
||||
Constructor Mk%d = Costruttore Mk%d
|
||||
Frame = Cornice
|
||||
Frame Motor = Cornice del motore
|
||||
Template = Sagoma
|
||||
Template (replacing) = Sagoma (di rimpiazzo)
|
||||
Template Motor = Motore per sagome
|
||||
Template Tool = Strumento per sagome
|
||||
Battery Box = Box batterie
|
||||
Supply Converter = Trasformatore
|
||||
Switching Station = Stazione di controllo
|
||||
CNC Machine = Tornio CNC
|
||||
Coal Alloy Furnace = Fornace per leghe a carbone
|
||||
Extractor = Estrattore
|
||||
Compressor = Compressore
|
||||
Solar Panel = Pannello solare
|
||||
Geothermal Generator = Generatore Geotermico
|
||||
Music Player = Music Player
|
||||
Water Mill = Turbina Elettrica
|
||||
Tool WorkShop = Officina per attrezzi
|
||||
Wind Mill = Generatore eolico
|
||||
Fuel-Fired Alloy Furnace = Fornace per leghe a carbone
|
||||
Fuel-Fired Furnace = Fornace a carbone
|
||||
Wind Mill Frame = Pala eolica
|
||||
Forcefield Emitter = Emettitore di campo di forza
|
||||
Forcefield = Campo di forza
|
||||
Nuclear Reactor Core = Reattore nucleare
|
||||
Nuclear Reactor Rod Compartment = Compartimento combustibile nucleare
|
||||
Quarry = Cava
|
||||
Administrative World Anchor = Ancora-mondo amministrativa
|
||||
|
||||
## Machine-specific
|
||||
# $1: Pruduced EU
|
||||
@ -78,43 +104,51 @@ Charge = Carica
|
||||
Discharge = Scarica
|
||||
Power level = Livello di potenza
|
||||
# $1: Tier $2: current_charge $3: max_charge
|
||||
%s Battery Box: %d/%d = %s Box Batterie: %d/%d
|
||||
@1 Battery Box: @2/@3 = @1 Box Batterie: @2/@3
|
||||
# $1: Machine name $2: Supply $3: Demand
|
||||
%s. Supply: %d Demand: %d = %s. Prodotto: %d Consumato: %d
|
||||
@1. Supply: @2 Demand: @3 = @1. Prodotto: @2 Consumato: @3
|
||||
Production at %d%% = Produzione a %d%%
|
||||
Choose Milling Program: = Scegliere un programma di Fresatura
|
||||
Slim Elements half / normal height: = Metà elementi sottili / altezza normale:
|
||||
Current track %s = Traccia corrente %s
|
||||
Stopped = Fermato
|
||||
Keeping %d/%d map blocks loaded = Mantenimento di %d/%d blocchi mappa caricati
|
||||
Digging not started = Scavo non iniziato
|
||||
Digging finished = Scavo finito
|
||||
Digging %d m above machine = Scavo di %d m sopra la macchina
|
||||
Digging %d m below machine = Scavo di %d m sotto la macchina
|
||||
|
||||
## CNC
|
||||
Cylinder = Cilindro
|
||||
Element Cross = Elemento a croce
|
||||
Element Cross Double = Elemento a croce doppio
|
||||
Element Edge =
|
||||
Element Edge Double =
|
||||
Element Edge = Elemento bordo
|
||||
Element Edge Double = Elemento bordo doppio
|
||||
Element End = Elemento finale
|
||||
Element End Double = Elemento finale doppio
|
||||
Element Straight =
|
||||
Element Straight Double =
|
||||
Element Straight = Elemento dritto
|
||||
Element Straight Double = Elemento dritto doppio
|
||||
Element T = Elemento a T
|
||||
Element T Double = Elemento a T doppio
|
||||
Horizontal Cylinder = Cilindro orizzontale
|
||||
One Curved Edge Block =
|
||||
One Curved Edge Block = Blocco con bordo curvo
|
||||
Pyramid = Piramide
|
||||
Slope =
|
||||
Slope Edge =
|
||||
Slope Inner Edge =
|
||||
Slope Lying =
|
||||
Slope Upside Down =
|
||||
Slope Upside Down Edge =
|
||||
Slope Upside Down Inner Edge =
|
||||
Slope = Inclinato
|
||||
Slope Edge = Bordo inclinato
|
||||
Slope Inner Edge = Bordo interno inclinato
|
||||
Slope Lying = Pendenza bugiarda
|
||||
Slope Upside Down = Pendenza capovolta
|
||||
Slope Upside Down Edge = Bordo inclinato capovolto
|
||||
Slope Upside Down Inner Edge = Bordo interno inclinato capovolto
|
||||
Sphere = Sfera
|
||||
Spike =
|
||||
Spike = Spuntone
|
||||
Stick = Bastone
|
||||
Two Curved Edge Block =
|
||||
Two Curved Edge Block = Blocco con bordo a doppia curva
|
||||
Brick = Mattone
|
||||
Cobble = Ciottolato
|
||||
Dirt = Terra
|
||||
Leaves = Foglie
|
||||
Sandstone = Arenaria
|
||||
Steel = Acciaio
|
||||
Stone = Pietra
|
||||
Tree = Albero
|
||||
Wooden = Legno
|
||||
@ -127,19 +161,23 @@ Alatro = Alatro
|
||||
Arol = Arol
|
||||
Brass = Ottone
|
||||
Bronze = Bronzo
|
||||
Carbon Steel = Acciaio al Carbonio
|
||||
Cast Iron = Ghisa
|
||||
Chromium = Cromo
|
||||
Coal = Carbone
|
||||
Copper = Rame
|
||||
Gold = Oro
|
||||
Iron = Ferro
|
||||
Mithril = Mithril
|
||||
Silver = Argento
|
||||
Stainless Steel = Acciaio Inossidabile
|
||||
Talinite = Talinite
|
||||
Tin = Stagno
|
||||
Wrought Iron = Ferro Battuto
|
||||
Zinc = Zinco
|
||||
%.1f%%-Fissile Uranium = %.1f%%-Uranio fissile
|
||||
|
||||
## Tools
|
||||
RE Battery = Batteria RE
|
||||
Water Can = Serbatoio d'acqua
|
||||
Lava Can = Serbatoio di lava
|
||||
Chainsaw = Motosega
|
||||
@ -148,10 +186,16 @@ Flashlight = Torcia
|
||||
3 nodes tall. = 3 nodi in altezza.
|
||||
3 nodes wide. = 3 nodi in larghezza.
|
||||
3x3 nodes. = 3x3 nodi.
|
||||
Hold shift and use to change Mining Drill Mk%d modes. = Premi shift (freccia grossa) e usa per cambiare modalità nella trivella da miniera Mk%d.
|
||||
Use while sneaking to change Mining Drill Mk%d modes. = Premi shift (freccia grossa) e usa per cambiare modalità nella trivella da miniera Mk%d.
|
||||
Mining Drill Mk%d Mode %d = Trivella mk%d in modalità %d
|
||||
Mining Drill Mk%d = Trivella da miniera mk%d
|
||||
Mining Laser Mk%d = Laser da miniera mk%d
|
||||
Single node. = Nodo singolo.
|
||||
Sonic Screwdriver = Cacciavite sonico
|
||||
Tree Tap = Batti albero
|
||||
|
||||
## Craft descriptions
|
||||
Alloy cooking = Cottura lege
|
||||
Grinding = Macinazione
|
||||
Compressing = Compressione
|
||||
Extracting = Estrazione
|
||||
|
@ -29,51 +29,82 @@ Graphite =
|
||||
Carbon Cloth =
|
||||
Raw Latex =
|
||||
Rubber Fiber =
|
||||
%.1f%%-Fissile Uranium Ingot =
|
||||
%.1f%%-Fissile Uranium Block =
|
||||
|
||||
## Machine misc
|
||||
Machine cannot be removed because it is not empty =
|
||||
Inventory move disallowed due to protection =
|
||||
# $1: Machine name (Includes tier)
|
||||
@1 Active (@2 EU) =
|
||||
%s Active =
|
||||
%s Disabled =
|
||||
%s Enabled =
|
||||
%s Idle =
|
||||
%s Improperly Placed =
|
||||
%s is empty =
|
||||
%s Unpowered =
|
||||
%s Out Of Fuel =
|
||||
%s Has Bad Cabling =
|
||||
%s (Slave) =
|
||||
%s Has No Network =
|
||||
%s Finished =
|
||||
Enable/Disable =
|
||||
Range =
|
||||
|
||||
Upgrade Slots =
|
||||
In: =
|
||||
Out: =
|
||||
Slot %d =
|
||||
Itemwise =
|
||||
Stackwise =
|
||||
Ignoring Mesecon Signal =
|
||||
Controlled by Mesecon Signal =
|
||||
Owner: =
|
||||
Unlocked =
|
||||
Locked =
|
||||
Radius: =
|
||||
Enabled =
|
||||
Disabled =
|
||||
|
||||
## Machine names
|
||||
# $1: Tier
|
||||
%s Alloy Furnace =
|
||||
%s Battery Box =
|
||||
%s Cable =
|
||||
%s Electric Furnace =
|
||||
%s CNC Machine =
|
||||
%s Centrifuge =
|
||||
%s Compressor =
|
||||
%s Extractor =
|
||||
%s Forcefield Emitter =
|
||||
%s Furnace =
|
||||
%s Grinder =
|
||||
%s Generator =
|
||||
%s Solar Array =
|
||||
%s Music Player =
|
||||
%s Quarry =
|
||||
%s Tool Workshop =
|
||||
Arrayed Solar %s Generator =
|
||||
Fuel-Fired %s Generator =
|
||||
Geothermal %s Generator =
|
||||
Hydro %s Generator =
|
||||
Nuclear %s Generator Core =
|
||||
Small Solar %s Generator =
|
||||
Wind %s Generator =
|
||||
Self-Contained Injector =
|
||||
Constructor Mk%d =
|
||||
Frame =
|
||||
Frame Motor =
|
||||
Template =
|
||||
Template (replacing) =
|
||||
Template Motor =
|
||||
Template Tool =
|
||||
Battery Box =
|
||||
Supply Converter =
|
||||
Switching Station =
|
||||
CNC Machine =
|
||||
Coal Alloy Furnace =
|
||||
Extractor =
|
||||
Compressor =
|
||||
Solar Panel =
|
||||
Geothermal Generator =
|
||||
Music Player =
|
||||
Water Mill =
|
||||
Tool WorkShop =
|
||||
Wind Mill =
|
||||
Fuel-Fired Alloy Furnace =
|
||||
Fuel-Fired Furnace =
|
||||
Wind Mill Frame =
|
||||
Forcefield Emitter =
|
||||
Forcefield =
|
||||
Nuclear Reactor Core =
|
||||
Nuclear Reactor Rod Compartment =
|
||||
Quarry =
|
||||
Administrative World Anchor =
|
||||
|
||||
## Machine-specific
|
||||
# $1: Pruduced EU
|
||||
@ -81,10 +112,20 @@ Charge =
|
||||
Discharge =
|
||||
Power level =
|
||||
# $1: Tier $2: current_charge $3: max_charge
|
||||
%s Battery Box: %d/%d =
|
||||
@1 Battery Box: @2/@3 =
|
||||
# $1: Machine name $2: Supply $3: Demand
|
||||
%s. Supply: %d Demand: %d =
|
||||
@1. Supply: @2 Demand: @3 =
|
||||
Production at %d%% =
|
||||
Choose Milling Program: =
|
||||
Slim Elements half / normal height: =
|
||||
Current track %s =
|
||||
Stopped =
|
||||
Keeping %d/%d map blocks loaded =
|
||||
Digging not started =
|
||||
Digging finished =
|
||||
Digging %d m above machine =
|
||||
Digging %d m below machine =
|
||||
@1 (@2 @3 -> @4 @5) =
|
||||
|
||||
## CNC
|
||||
Cylinder =
|
||||
@ -117,7 +158,6 @@ Cobble =
|
||||
Dirt =
|
||||
Leaves =
|
||||
Sandstone =
|
||||
Steel =
|
||||
Stone =
|
||||
Tree =
|
||||
Wooden =
|
||||
@ -130,19 +170,23 @@ Alatro =
|
||||
Arol =
|
||||
Brass =
|
||||
Bronze =
|
||||
Carbon Steel =
|
||||
Cast Iron =
|
||||
Chromium =
|
||||
Coal =
|
||||
Copper =
|
||||
Gold =
|
||||
Iron =
|
||||
Mithril =
|
||||
Silver =
|
||||
Stainless Steel =
|
||||
Talinite =
|
||||
Tin =
|
||||
Wrought Iron =
|
||||
Zinc =
|
||||
%.1f%%-Fissile Uranium =
|
||||
|
||||
## Tools
|
||||
RE Battery =
|
||||
Water Can =
|
||||
Lava Can =
|
||||
Chainsaw =
|
||||
@ -151,7 +195,7 @@ Flashlight =
|
||||
3 nodes tall. =
|
||||
3 nodes wide. =
|
||||
3x3 nodes. =
|
||||
Hold shift and use to change Mining Drill Mk%d modes. =
|
||||
Use while sneaking to change Mining Drill Mk%d modes. =
|
||||
Mining Drill Mk%d Mode %d =
|
||||
Mining Drill Mk%d =
|
||||
Mining Laser Mk%d =
|
||||
@ -159,4 +203,9 @@ Single node. =
|
||||
Sonic Screwdriver =
|
||||
Tree Tap =
|
||||
|
||||
|
||||
## Craft descriptions
|
||||
Alloy cooking =
|
||||
Grinding =
|
||||
Compressing =
|
||||
Extracting =
|
||||
Separating =
|
||||
|
@ -1,19 +1,22 @@
|
||||
-- HV battery box
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_battery_box0',
|
||||
recipe = {
|
||||
{'technic:mv_battery_box0', 'technic:mv_battery_box0', 'technic:mv_battery_box0'},
|
||||
{'technic:mv_battery_box0', 'technic:hv_transformer', 'technic:mv_battery_box0'},
|
||||
{'', 'technic:hv_cable0', ''},
|
||||
{'', 'technic:hv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_battery_box({
|
||||
tier = "HV",
|
||||
max_charge = 1500000,
|
||||
max_charge = 1000000,
|
||||
charge_rate = 100000,
|
||||
discharge_rate = 400000,
|
||||
charge_step = 10000,
|
||||
discharge_step = 40000,
|
||||
upgrade = 1,
|
||||
tube = 1,
|
||||
})
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_cable0 3',
|
||||
output = 'technic:hv_cable 3',
|
||||
recipe = {
|
||||
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
|
||||
{'technic:mv_cable0', 'technic:mv_cable0', 'technic:mv_cable0'},
|
||||
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
|
||||
{'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'},
|
||||
{'technic:mv_cable', 'technic:mv_cable', 'technic:mv_cable'},
|
||||
{'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1,26 +1,40 @@
|
||||
-- Forcefield mod by ShadowNinja
|
||||
-- Modified by kpoppel
|
||||
--- Forcefield generator.
|
||||
-- @author ShadowNinja
|
||||
--
|
||||
-- Forcefields are powerful barriers but they consume huge amounts of power.
|
||||
-- Forcefield Generator is a HV machine.
|
||||
-- The forcefield Generator is an HV machine.
|
||||
|
||||
-- How expensive is the generator?
|
||||
-- Leaves room for upgrades lowering the power drain?
|
||||
local digilines_path = minetest.get_modpath("digilines")
|
||||
|
||||
local forcefield_power_drain = 10
|
||||
local forcefield_step_interval = 1
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:forcefield_emitter_off',
|
||||
output = "technic:forcefield_emitter_off",
|
||||
recipe = {
|
||||
{'default:mese', 'technic:deployer_off', 'default:mese' },
|
||||
{'technic:deployer_off', 'technic:motor', 'technic:deployer_off'},
|
||||
{'default:mese', 'technic:deployer_off', 'default:mese' },
|
||||
{"default:mese", "technic:motor", "default:mese" },
|
||||
{"technic:deployer_off", "technic:machine_casing", "technic:deployer_off"},
|
||||
{"default:mese", "technic:hv_cable", "default:mese" },
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
local replaceable_cids = {}
|
||||
|
||||
minetest.after(0, function()
|
||||
for name, ndef in pairs(minetest.registered_nodes) do
|
||||
if ndef.buildable_to == true and name ~= "ignore" then
|
||||
replaceable_cids[minetest.get_content_id(name)] = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- Idea: Let forcefields have different colors by upgrade slot.
|
||||
-- Idea: Let forcefields add up by detecting if one hits another.
|
||||
-- ___ __
|
||||
@ -28,11 +42,12 @@ minetest.register_craft({
|
||||
-- | |
|
||||
-- \___/\___/
|
||||
|
||||
local function update_forcefield(pos, range, active)
|
||||
local function update_forcefield(pos, meta, active, first)
|
||||
local shape = meta:get_int("shape")
|
||||
local range = meta:get_int("range")
|
||||
local vm = VoxelManip()
|
||||
local p1 = {x = pos.x-range, y = pos.y-range, z = pos.z-range}
|
||||
local p2 = {x = pos.x+range, y = pos.y+range, z = pos.z+range}
|
||||
local MinEdge, MaxEdge = vm:read_from_map(p1, p2)
|
||||
local MinEdge, MaxEdge = vm:read_from_map(vector.subtract(pos, range),
|
||||
vector.add(pos, range))
|
||||
local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge})
|
||||
local data = vm:get_data()
|
||||
|
||||
@ -43,11 +58,23 @@ local function update_forcefield(pos, range, active)
|
||||
for y = -range, range do
|
||||
local vi = area:index(pos.x + (-range), pos.y + y, pos.z + z)
|
||||
for x = -range, range do
|
||||
if x*x+y*y+z*z <= range * range + range and
|
||||
x*x+y*y+z*z >= (range-1) * (range-1) + (range-1) then
|
||||
if active and data[vi] == c_air then
|
||||
local relevant
|
||||
if shape == 0 then
|
||||
local squared = x * x + y * y + z * z
|
||||
relevant =
|
||||
squared <= range * range + range and
|
||||
squared >= (range - 1) * (range - 1) + (range - 1)
|
||||
else
|
||||
relevant =
|
||||
x == -range or x == range or
|
||||
y == -range or y == range or
|
||||
z == -range or z == range
|
||||
end
|
||||
if relevant then
|
||||
local cid = data[vi]
|
||||
if active and replaceable_cids[cid] then
|
||||
data[vi] = c_field
|
||||
elseif not active and data[vi] == c_field then
|
||||
elseif not active and cid == c_field then
|
||||
data[vi] = c_air
|
||||
end
|
||||
end
|
||||
@ -59,55 +86,214 @@ local function update_forcefield(pos, range, active)
|
||||
vm:set_data(data)
|
||||
vm:update_liquids()
|
||||
vm:write_to_map()
|
||||
-- update_map is very slow, but if we don't call it we'll
|
||||
-- get phantom blocks on the client.
|
||||
if not active or first then
|
||||
vm:update_map()
|
||||
end
|
||||
end
|
||||
|
||||
local get_forcefield_formspec = function(range)
|
||||
return "size[3,1.5]"..
|
||||
"field[1,0.5;2,1;range;"..S("Range")..";"..range.."]"..
|
||||
"button[0,1;3,1;toggle;"..S("Enable/Disable").."]"
|
||||
local function set_forcefield_formspec(meta)
|
||||
local formspec
|
||||
if digilines_path then
|
||||
formspec = "size[5,3.25]"..
|
||||
"field[0.3,3;5,1;channel;Digiline Channel;"..meta:get_string("channel").."]"
|
||||
else
|
||||
formspec = "size[5,2.25]"
|
||||
end
|
||||
formspec = formspec..
|
||||
"field[0.3,0.5;2,1;range;"..S("Range")..";"..meta:get_int("range").."]"
|
||||
-- The names for these toggle buttons are explicit about which
|
||||
-- state they'll switch to, so that multiple presses (arising
|
||||
-- from the ambiguity between lag and a missed press) only make
|
||||
-- the single change that the user expects.
|
||||
if meta:get_int("shape") == 0 then
|
||||
formspec = formspec.."button[3,0.2;2,1;shape1;"..S("Sphere").."]"
|
||||
else
|
||||
formspec = formspec.."button[3,0.2;2,1;shape0;"..S("Cube").."]"
|
||||
end
|
||||
if meta:get_int("mesecon_mode") == 0 then
|
||||
formspec = formspec.."button[0,1;5,1;mesecon_mode_1;"..S("Ignoring Mesecon Signal").."]"
|
||||
else
|
||||
formspec = formspec.."button[0,1;5,1;mesecon_mode_0;"..S("Controlled by Mesecon Signal").."]"
|
||||
end
|
||||
if meta:get_int("enabled") == 0 then
|
||||
formspec = formspec.."button[0,1.75;5,1;enable;"..S("%s Disabled"):format(S("%s Forcefield Emitter"):format("HV")).."]"
|
||||
else
|
||||
formspec = formspec.."button[0,1.75;5,1;disable;"..S("%s Enabled"):format(S("%s Forcefield Emitter"):format("HV")).."]"
|
||||
end
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
|
||||
local forcefield_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local range = tonumber(fields.range) or 0
|
||||
|
||||
if fields.toggle then
|
||||
if meta:get_int("enabled") == 1 then
|
||||
meta:set_int("enabled", 0)
|
||||
else
|
||||
meta:set_int("enabled", 1)
|
||||
end
|
||||
end
|
||||
|
||||
local range = nil
|
||||
if fields.range then
|
||||
range = tonumber(fields.range) or 0
|
||||
-- Smallest field is 5. Anything less is asking for trouble.
|
||||
-- Largest is 20. It is a matter of pratical node handling.
|
||||
-- At the maximim range updating the forcefield takes about 0.2s
|
||||
range = math.max(range, 5)
|
||||
range = math.min(range, 20)
|
||||
|
||||
if meta:get_int("range") ~= range then
|
||||
update_forcefield(pos, meta:get_int("range"), false)
|
||||
meta:set_int("range", range)
|
||||
meta:set_string("formspec", get_forcefield_formspec(range))
|
||||
if range == meta:get_int("range") then range = nil end
|
||||
end
|
||||
if fields.shape0 or fields.shape1 or range then
|
||||
update_forcefield(pos, meta, false)
|
||||
end
|
||||
if range then meta:set_int("range", range) end
|
||||
if fields.channel then meta:set_string("channel", fields.channel) end
|
||||
if fields.shape0 then meta:set_int("shape", 0) end
|
||||
if fields.shape1 then meta:set_int("shape", 1) end
|
||||
if fields.enable then meta:set_int("enabled", 1) end
|
||||
if fields.disable then meta:set_int("enabled", 0) end
|
||||
if fields.mesecon_mode_0 then meta:set_int("mesecon_mode", 0) end
|
||||
if fields.mesecon_mode_1 then meta:set_int("mesecon_mode", 1) end
|
||||
set_forcefield_formspec(meta)
|
||||
end
|
||||
|
||||
local mesecons = {
|
||||
effector = {
|
||||
action_on = function(pos, node)
|
||||
minetest.get_meta(pos):set_int("enabled", 0)
|
||||
minetest.get_meta(pos):set_int("mesecon_effect", 1)
|
||||
end,
|
||||
action_off = function(pos, node)
|
||||
minetest.get_meta(pos):set_int("enabled", 1)
|
||||
minetest.get_meta(pos):set_int("mesecon_effect", 0)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
local digiline_def = {
|
||||
receptor = {action = function() end},
|
||||
effector = {
|
||||
action = function(pos, node, channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if channel ~= meta:get_string("channel") then
|
||||
return
|
||||
end
|
||||
local msgt = type(msg)
|
||||
if msgt == "string" then
|
||||
local smsg = msg:lower()
|
||||
msg = {}
|
||||
if smsg == "get" then
|
||||
msg.command = "get"
|
||||
elseif smsg == "off" then
|
||||
msg.command = "off"
|
||||
elseif smsg == "on" then
|
||||
msg.command = "on"
|
||||
elseif smsg == "toggle" then
|
||||
msg.command = "toggle"
|
||||
elseif smsg:sub(1, 5) == "range" then
|
||||
msg.command = "range"
|
||||
msg.value = tonumber(smsg:sub(7))
|
||||
elseif smsg:sub(1, 5) == "shape" then
|
||||
msg.command = "shape"
|
||||
msg.value = smsg:sub(7):lower()
|
||||
msg.value = tonumber(msg.value) or msg.value
|
||||
end
|
||||
elseif msgt ~= "table" then
|
||||
return
|
||||
end
|
||||
if msg.command == "get" then
|
||||
digilines.receptor_send(pos, digilines.rules.default, channel, {
|
||||
enabled = meta:get_int("enabled"),
|
||||
range = meta:get_int("range"),
|
||||
shape = meta:get_int("shape")
|
||||
})
|
||||
return
|
||||
elseif msg.command == "off" then
|
||||
meta:set_int("enabled", 0)
|
||||
elseif msg.command == "on" then
|
||||
meta:set_int("enabled", 1)
|
||||
elseif msg.command == "toggle" then
|
||||
local onn = meta:get_int("enabled")
|
||||
onn = 1-onn -- Mirror onn with pivot 0.5, so switch between 1 and 0.
|
||||
meta:set_int("enabled", onn)
|
||||
elseif msg.command == "range" then
|
||||
if type(msg.value) ~= "number" then
|
||||
return
|
||||
end
|
||||
msg.value = math.max(msg.value, 5)
|
||||
msg.value = math.min(msg.value, 20)
|
||||
update_forcefield(pos, meta, false)
|
||||
meta:set_int("range", msg.value)
|
||||
elseif msg.command == "shape" then
|
||||
local valuet = type(msg.value)
|
||||
if valuet == "string" then
|
||||
if msg.value == "sphere" then
|
||||
msg.value = 0
|
||||
elseif msg.value == "cube" then
|
||||
msg.value = 1
|
||||
end
|
||||
elseif valuet ~= "number" then
|
||||
return
|
||||
end
|
||||
if not msg.value then
|
||||
return
|
||||
end
|
||||
update_forcefield(pos, meta, false)
|
||||
meta:set_int("shape", msg.value)
|
||||
else
|
||||
return
|
||||
end
|
||||
set_forcefield_formspec(meta)
|
||||
end
|
||||
},
|
||||
}
|
||||
|
||||
local function run(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("HV_EU_input")
|
||||
local enabled = meta:get_int("enabled") ~= 0 and
|
||||
(meta:get_int("mesecon_mode") == 0 or meta:get_int("mesecon_effect") ~= 0)
|
||||
local machine_name = S("%s Forcefield Emitter"):format("HV")
|
||||
|
||||
local range = meta:get_int("range")
|
||||
local power_requirement
|
||||
if meta:get_int("shape") == 0 then
|
||||
power_requirement = math.floor(4 * math.pi * range * range)
|
||||
else
|
||||
power_requirement = 24 * range * range
|
||||
end
|
||||
power_requirement = power_requirement * forcefield_power_drain
|
||||
|
||||
if not enabled then
|
||||
if node.name == "technic:forcefield_emitter_on" then
|
||||
update_forcefield(pos, meta, false)
|
||||
technic.swap_node(pos, "technic:forcefield_emitter_off")
|
||||
meta:set_string("infotext", S("%s Disabled"):format(machine_name))
|
||||
end
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
meta:set_int("HV_EU_demand", power_requirement)
|
||||
if eu_input < power_requirement then
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
if node.name == "technic:forcefield_emitter_on" then
|
||||
update_forcefield(pos, meta, false)
|
||||
technic.swap_node(pos, "technic:forcefield_emitter_off")
|
||||
end
|
||||
elseif eu_input >= power_requirement then
|
||||
local first = false
|
||||
if node.name == "technic:forcefield_emitter_off" then
|
||||
first = true
|
||||
technic.swap_node(pos, "technic:forcefield_emitter_on")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
end
|
||||
update_forcefield(pos, meta, true, first)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:forcefield_emitter_off", {
|
||||
description = S("Forcefield Emitter"),
|
||||
tiles = {"technic_forcefield_emitter_off.png"},
|
||||
groups = {cracky = 1},
|
||||
description = S("%s Forcefield Emitter"):format("HV"),
|
||||
tiles = {
|
||||
"technic_forcefield_emitter_off.png",
|
||||
"technic_machine_bottom.png"..cable_entry,
|
||||
"technic_forcefield_emitter_off.png",
|
||||
"technic_forcefield_emitter_off.png",
|
||||
"technic_forcefield_emitter_off.png",
|
||||
"technic_forcefield_emitter_off.png"
|
||||
},
|
||||
groups = {cracky = 1, technic_machine = 1, technic_hv = 1},
|
||||
on_receive_fields = forcefield_receive_fields,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -115,37 +301,59 @@ minetest.register_node("technic:forcefield_emitter_off", {
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
meta:set_int("range", 10)
|
||||
meta:set_int("enabled", 0)
|
||||
meta:set_string("formspec", get_forcefield_formspec(10))
|
||||
meta:set_string("infotext", S("Forcefield Emitter"))
|
||||
meta:set_int("mesecon_mode", 0)
|
||||
meta:set_int("mesecon_effect", 0)
|
||||
if digilines_path then
|
||||
meta:set_string("channel", "forcefield"..minetest.pos_to_string(pos))
|
||||
end
|
||||
meta:set_string("infotext", S("%s Forcefield Emitter"):format("HV"))
|
||||
set_forcefield_formspec(meta)
|
||||
end,
|
||||
mesecons = mesecons
|
||||
mesecons = mesecons,
|
||||
digiline = digiline_def,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:forcefield_emitter_on", {
|
||||
description = S("Forcefield Emitter"),
|
||||
tiles = {"technic_forcefield_emitter_on.png"},
|
||||
groups = {cracky = 1, not_in_creative_inventory=1},
|
||||
description = S("%s Forcefield Emitter"):format("HV"),
|
||||
tiles = {
|
||||
"technic_forcefield_emitter_on.png",
|
||||
"technic_machine_bottom.png"..cable_entry,
|
||||
"technic_forcefield_emitter_on.png",
|
||||
"technic_forcefield_emitter_on.png",
|
||||
"technic_forcefield_emitter_on.png",
|
||||
"technic_forcefield_emitter_on.png"
|
||||
},
|
||||
groups = {cracky = 1, technic_machine = 1, technic_hv = 1,
|
||||
not_in_creative_inventory=1},
|
||||
drop = "technic:forcefield_emitter_off",
|
||||
on_receive_fields = forcefield_receive_fields,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local range = meta:get_int("range")
|
||||
meta:set_string("formspec", get_forcefield_formspec(range))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
update_forcefield(pos, meta:get_int("range"), false)
|
||||
update_forcefield(pos, meta, false)
|
||||
end,
|
||||
mesecons = mesecons,
|
||||
digiline = digiline_def,
|
||||
technic_run = run,
|
||||
technic_on_disable = function (pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
update_forcefield(pos, meta, false)
|
||||
technic.swap_node(pos, "technic:forcefield_emitter_off")
|
||||
end,
|
||||
on_blast = function(pos, intensity)
|
||||
minetest.dig_node(pos)
|
||||
return {"technic:forcefield_emitter_off"}
|
||||
end,
|
||||
mesecons = mesecons
|
||||
})
|
||||
|
||||
minetest.register_node("technic:forcefield", {
|
||||
description = S("Forcefield"),
|
||||
description = S("%s Forcefield"):format("HV"),
|
||||
sunlight_propagates = true,
|
||||
drawtype = "glasslike",
|
||||
groups = {not_in_creative_inventory=1, unbreakable=1},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
paramtype = "light",
|
||||
light_source = 15,
|
||||
light_source = default.LIGHT_MAX,
|
||||
diggable = false,
|
||||
drop = '',
|
||||
tiles = {{
|
||||
name = "technic_forcefield_animated.png",
|
||||
@ -156,53 +364,14 @@ minetest.register_node("technic:forcefield", {
|
||||
length = 1.0,
|
||||
},
|
||||
}},
|
||||
on_blast = function(pos, intensity)
|
||||
end,
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:forcefield_emitter_on", "technic:forcefield_emitter_off"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("HV_EU_input")
|
||||
local eu_demand = meta:get_int("HV_EU_demand")
|
||||
local enabled = meta:get_int("enabled")
|
||||
local machine_name = S("Forcefield Emitter")
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "HV")
|
||||
|
||||
local power_requirement = math.floor(
|
||||
4 * math.pi * math.pow(meta:get_int("range"), 2)
|
||||
) * forcefield_power_drain
|
||||
|
||||
if meta:get_int("enabled") == 0 then
|
||||
if node.name == "technic:forcefield_emitter_on" then
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
update_forcefield(pos, meta:get_int("range"), false)
|
||||
hacky_swap_node(pos, "technic:forcefield_emitter_off")
|
||||
meta:set_string("infotext", S("%s Disabled"):format(machine_name))
|
||||
return
|
||||
end
|
||||
elseif eu_input < power_requirement then
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
if node.name == "technic:forcefield_emitter_on" then
|
||||
update_forcefield(pos, meta:get_int("range"), false)
|
||||
hacky_swap_node(pos, "technic:forcefield_emitter_off")
|
||||
end
|
||||
elseif eu_input >= power_requirement then
|
||||
if node.name == "technic:forcefield_emitter_off" then
|
||||
hacky_swap_node(pos, "technic:forcefield_emitter_on")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
end
|
||||
update_forcefield(pos, meta:get_int("range"), true)
|
||||
end
|
||||
meta:set_int("HV_EU_demand", power_requirement)
|
||||
end
|
||||
})
|
||||
|
||||
if minetest.get_modpath("mesecons_mvps") then
|
||||
mesecon:register_mvps_stopper("technic:forcefield")
|
||||
mesecon.register_mvps_stopper("technic:forcefield")
|
||||
end
|
||||
-- TODO: Register a stopper for frames
|
||||
|
||||
technic.register_machine("HV", "technic:forcefield_emitter_on", technic.receiver)
|
||||
technic.register_machine("HV", "technic:forcefield_emitter_off", technic.receiver)
|
||||
|
@ -1,14 +1,13 @@
|
||||
|
||||
minetest.register_alias("hv_generator", "technic:hv_generator")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_generator',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_generator', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_000000', 'technic:hv_transformer', 'pipeworks:tube_000000'},
|
||||
{'technic:carbon_plate', 'technic:mv_generator', 'technic:composite_plate'},
|
||||
{'pipeworks:tube_1', 'technic:hv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_generator({tier="HV", supply=1200})
|
||||
technic.register_generator({tier="HV", tube=1, supply=1200})
|
||||
|
||||
|
@ -3,11 +3,16 @@ technic.register_tier("HV", "High Voltage")
|
||||
|
||||
local path = technic.modpath.."/machines/HV"
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/quarry.lua")
|
||||
dofile(path.."/forcefield.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/nuclear_reactor.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/quarry.lua")
|
||||
dofile(path.."/forcefield.lua")
|
||||
|
||||
|
@ -1,258 +1,482 @@
|
||||
-- The enriched uranium rod driven EU generator.
|
||||
-- A very large and advanced machine providing vast amounts of power.
|
||||
-- Very efficient but also expensive to run as it needs uranium. (10000EU 86400 ticks (24h))
|
||||
-- Provides HV EUs that can be down converted as needed.
|
||||
--
|
||||
-- The nuclear reactor core needs water and a protective shield to work.
|
||||
-- This is checked now and then and if the machine is tampered with... BOOM!
|
||||
--[[
|
||||
The enriched uranium rod driven EU generator.
|
||||
A very large and advanced machine providing vast amounts of power.
|
||||
Very efficient but also expensive to run as it needs uranium.
|
||||
Provides 10000 HV EUs for one week (only counted when loaded).
|
||||
|
||||
local burn_ticks = 7 * 24 * 60 * 60 -- (seconds).
|
||||
The nuclear reactor core requires a casing of water and a protective
|
||||
shield to work. This is checked now and then and if the casing is not
|
||||
intact the reactor will melt down!
|
||||
--]]
|
||||
|
||||
local burn_ticks = 7 * 24 * 60 * 60 -- Seconds
|
||||
local power_supply = 100000 -- EUs
|
||||
local fuel_type = "technic:uranium_fuel" -- The reactor burns this stuff
|
||||
local fuel_type = "technic:uranium_fuel" -- The reactor burns this
|
||||
local digiline_meltdown = technic.config:get_bool("enable_nuclear_reactor_digiline_selfdestruct")
|
||||
local digiline_remote_path = minetest.get_modpath("digiline_remote")
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
-- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator?
|
||||
local reactor_desc = S("@1 Nuclear Reactor Core", S("HV"))
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
-- FIXME: Recipe should make more sense like a rod recepticle, steam chamber, HV generator?
|
||||
minetest.register_craft({
|
||||
output = 'technic:hv_nuclear_reactor_core',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
|
||||
{'technic:carbon_plate', 'default:obsidian_glass', 'technic:carbon_plate'},
|
||||
{'technic:composite_plate', 'technic:machine_casing', 'technic:composite_plate'},
|
||||
{'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
local generator_formspec =
|
||||
"invsize[8,9;]"..
|
||||
local function make_reactor_formspec(meta)
|
||||
local f = "size[8,9]"..
|
||||
"label[0,0;"..S("Nuclear Reactor Rod Compartment").."]"..
|
||||
"list[current_name;src;2,1;3,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
-- "Boxy sphere"
|
||||
local nodebox = {
|
||||
{ -0.353, -0.353, -0.353, 0.353, 0.353, 0.353 }, -- Box
|
||||
{ -0.495, -0.064, -0.064, 0.495, 0.064, 0.064 }, -- Circle +-x
|
||||
{ -0.483, -0.128, -0.128, 0.483, 0.128, 0.128 },
|
||||
{ -0.462, -0.191, -0.191, 0.462, 0.191, 0.191 },
|
||||
{ -0.433, -0.249, -0.249, 0.433, 0.249, 0.249 },
|
||||
{ -0.397, -0.303, -0.303, 0.397, 0.303, 0.303 },
|
||||
{ -0.305, -0.396, -0.305, 0.305, 0.396, 0.305 }, -- Circle +-y
|
||||
{ -0.250, -0.432, -0.250, 0.250, 0.432, 0.250 },
|
||||
{ -0.191, -0.461, -0.191, 0.191, 0.461, 0.191 },
|
||||
{ -0.130, -0.482, -0.130, 0.130, 0.482, 0.130 },
|
||||
{ -0.066, -0.495, -0.066, 0.066, 0.495, 0.066 },
|
||||
{ -0.064, -0.064, -0.495, 0.064, 0.064, 0.495 }, -- Circle +-z
|
||||
{ -0.128, -0.128, -0.483, 0.128, 0.128, 0.483 },
|
||||
{ -0.191, -0.191, -0.462, 0.191, 0.191, 0.462 },
|
||||
{ -0.249, -0.249, -0.433, 0.249, 0.249, 0.433 },
|
||||
{ -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
|
||||
}
|
||||
|
||||
minetest.register_node("technic:hv_nuclear_reactor_core", {
|
||||
description = S("Nuclear Reactor Core"),
|
||||
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drawtype="nodebox",
|
||||
paramtype = "light",
|
||||
stack_max = 1,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Nuclear Reactor Core"))
|
||||
meta:set_int("HV_EU_supply", 0)
|
||||
-- Signal to the switching station that this device burns some
|
||||
-- sort of fuel and needs special handling
|
||||
meta:set_int("HV_EU_from_fuel", 1)
|
||||
meta:set_int("burn_time", 0)
|
||||
meta:set_string("formspec", generator_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 6)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[]"..
|
||||
"button[5.5,1.5;2,1;start;Start]"..
|
||||
"checkbox[5.5,2.5;autostart;automatic Start;"..meta:get_string("autostart").."]"
|
||||
if not digiline_remote_path then
|
||||
return f
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
||||
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop="technic:hv_nuclear_reactor_core",
|
||||
drawtype="nodebox",
|
||||
light_source = 15,
|
||||
paramtype = "light",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
local digiline_enabled = meta:get_string("enable_digiline")
|
||||
f = f.."checkbox[0.5,2.8;enable_digiline;Enable Digiline;"..digiline_enabled.."]"
|
||||
if digiline_enabled ~= "true" then
|
||||
return f
|
||||
end
|
||||
return f..
|
||||
"button_exit[4.6,3.69;2,1;save;Save]"..
|
||||
"field[1,4;4,1;remote_channel;Digiline Remote Channel;${remote_channel}]"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local check_reactor_structure = function(pos)
|
||||
-- The reactor consists of a 9x9x9 cube structure
|
||||
-- A cross section through the middle:
|
||||
-- CCCC CCCC
|
||||
-- CBBB BBBC
|
||||
-- CBSS SSBC
|
||||
-- CBSWWWSBC
|
||||
-- CBSW#WSBC
|
||||
-- CBSW|WSBC
|
||||
-- CBSS|SSBC
|
||||
-- CBBB|BBBC
|
||||
-- CCCC|CCCC
|
||||
-- C = Concrete, B = Blast resistant concrete, S = Stainless Steel,
|
||||
-- W = water node, # = reactor core, | = HV cable
|
||||
-- The man-hole and the HV cable is only in the middle
|
||||
-- The man-hole is optional
|
||||
local SS_OFF = 0
|
||||
local SS_DANGER = 1
|
||||
local SS_CLEAR = 2
|
||||
|
||||
local reactor_siren = {}
|
||||
local function siren_set_state(pos, state)
|
||||
local hpos = minetest.hash_node_position(pos)
|
||||
local siren = reactor_siren[hpos]
|
||||
if not siren then
|
||||
if state == SS_OFF then return end
|
||||
siren = {state=SS_OFF}
|
||||
reactor_siren[hpos] = siren
|
||||
end
|
||||
if state == SS_DANGER and siren.state ~= SS_DANGER then
|
||||
if siren.handle then minetest.sound_stop(siren.handle) end
|
||||
siren.handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_danger_loop",
|
||||
{pos=pos, gain=1.5, loop=true, max_hear_distance=48})
|
||||
siren.state = SS_DANGER
|
||||
elseif state == SS_CLEAR then
|
||||
if siren.handle then minetest.sound_stop(siren.handle) end
|
||||
local clear_handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_clear",
|
||||
{pos=pos, gain=1.5, loop=false, max_hear_distance=48})
|
||||
siren.handle = clear_handle
|
||||
siren.state = SS_CLEAR
|
||||
minetest.after(10, function()
|
||||
if siren.handle ~= clear_handle then return end
|
||||
minetest.sound_stop(clear_handle)
|
||||
if reactor_siren[hpos] == siren then
|
||||
reactor_siren[hpos] = nil
|
||||
end
|
||||
end)
|
||||
elseif state == SS_OFF and siren.state ~= SS_OFF then
|
||||
if siren.handle then minetest.sound_stop(siren.handle) end
|
||||
reactor_siren[hpos] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function siren_danger(pos, meta)
|
||||
meta:set_int("siren", 1)
|
||||
siren_set_state(pos, SS_DANGER)
|
||||
end
|
||||
|
||||
local function siren_clear(pos, meta)
|
||||
if meta:get_int("siren") ~= 0 then
|
||||
siren_set_state(pos, SS_CLEAR)
|
||||
meta:set_int("siren", 0)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
The standard reactor structure consists of a 9x9x9 cube. A cross
|
||||
section through the middle:
|
||||
|
||||
CCCC CCCC
|
||||
CBBB BBBC
|
||||
CBLL LLBC
|
||||
CBLWWWLBC
|
||||
CBLW#WLBC
|
||||
CBLW|WLBC
|
||||
CBLL|LLBC
|
||||
CBBB|BBBC
|
||||
CCCC|CCCC
|
||||
C = Concrete, B = Blast-resistant concrete, L = Lead,
|
||||
W = water node, # = reactor core, | = HV cable
|
||||
|
||||
The man-hole is optional (but necessary for refueling).
|
||||
|
||||
For the reactor to operate and not melt down, it insists on the inner
|
||||
7x7x7 portion (from the core out to the blast-resistant concrete)
|
||||
being intact. Intactness only depends on the number of nodes of the
|
||||
right type in each layer. The water layer must have water in all but
|
||||
at most one node; the steel and blast-resistant concrete layers must
|
||||
have the right material in all but at most two nodes. The permitted
|
||||
gaps are meant for the cable and man-hole, but can actually be anywhere
|
||||
and contain anything. For the reactor to be useful, a cable must
|
||||
connect to the core, but it can go in any direction.
|
||||
|
||||
The outer concrete layer of the standard structure is not required
|
||||
for the reactor to operate. It is noted here because it used to
|
||||
be mandatory, and for historical reasons (that it predates the
|
||||
implementation of radiation) it needs to continue being adequate
|
||||
shielding of legacy reactors. If it ever ceases to be adequate
|
||||
shielding for new reactors, legacy ones should be grandfathered.
|
||||
|
||||
For legacy reasons, if the reactor has a stainless steel layer instead
|
||||
of a lead layer it will be converted to a lead layer.
|
||||
--]]
|
||||
local function reactor_structure_badness(pos)
|
||||
local vm = VoxelManip()
|
||||
local pos1 = vector.subtract(pos, 4)
|
||||
local pos2 = vector.add(pos, 4)
|
||||
local pos1 = vector.subtract(pos, 3)
|
||||
local pos2 = vector.add(pos, 3)
|
||||
local MinEdge, MaxEdge = vm:read_from_map(pos1, pos2)
|
||||
local data = vm:get_data()
|
||||
local area = VoxelArea:new({MinEdge=MinEdge, MaxEdge=MaxEdge})
|
||||
|
||||
local c_concrete = minetest.get_content_id("technic:concrete")
|
||||
local c_blast_concrete = minetest.get_content_id("technic:blast_resistant_concrete")
|
||||
local c_stainless_steel = minetest.get_content_id("technic:stainless_steel_block")
|
||||
local c_lead = minetest.get_content_id("technic:lead_block")
|
||||
local c_steel = minetest.get_content_id("technic:stainless_steel_block")
|
||||
local c_water_source = minetest.get_content_id("default:water_source")
|
||||
local c_water_flowing = minetest.get_content_id("default:water_flowing")
|
||||
|
||||
local concretelayer, blastlayer, steellayer, waterlayer = 0, 0, 0, 0
|
||||
local blast_layer, steel_layer, lead_layer, water_layer = 0, 0, 0, 0
|
||||
|
||||
for z = pos1.z, pos2.z do
|
||||
for y = pos1.y, pos2.y do
|
||||
for x = pos1.x, pos2.x do
|
||||
-- If the position is in the outer layer
|
||||
local cid = data[area:index(x, y, z)]
|
||||
if x == pos1.x or x == pos2.x or
|
||||
y == pos1.y or y == pos2.y or
|
||||
z == pos1.z or z == pos2.z then
|
||||
if data[area:index(x, y, z)] == c_concrete then
|
||||
concretelayer = concretelayer + 1
|
||||
if cid == c_blast_concrete then
|
||||
blast_layer = blast_layer + 1
|
||||
end
|
||||
elseif x == pos1.x+1 or x == pos2.x-1 or
|
||||
y == pos1.y+1 or y == pos2.y-1 or
|
||||
z == pos1.z+1 or z == pos2.z-1 then
|
||||
if data[area:index(x, y, z)] == c_blast_concrete then
|
||||
blastlayer = blastlayer + 1
|
||||
if cid == c_lead then
|
||||
lead_layer = lead_layer + 1
|
||||
elseif cid == c_steel then
|
||||
steel_layer = steel_layer + 1
|
||||
end
|
||||
elseif x == pos1.x+2 or x == pos2.x-2 or
|
||||
y == pos1.y+2 or y == pos2.y-2 or
|
||||
z == pos1.z+2 or z == pos2.z-2 then
|
||||
if data[area:index(x, y, z)] == c_stainless_steel then
|
||||
steellayer = steellayer + 1
|
||||
end
|
||||
elseif x == pos1.x+3 or x == pos2.x-3 or
|
||||
y == pos1.y+3 or y == pos2.y-3 or
|
||||
z == pos1.z+3 or z == pos2.z-3 then
|
||||
local cid = data[area:index(x, y, z)]
|
||||
if cid == c_water_source or cid == c_water_flowing then
|
||||
waterlayer = waterlayer + 1
|
||||
water_layer = water_layer + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if waterlayer >= 25 and
|
||||
steellayer >= 96 and
|
||||
blastlayer >= 216 and
|
||||
concretelayer >= 384 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local explode_reactor = function(pos)
|
||||
print("A reactor exploded at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
|
||||
local function damage_nearby_players(pos)
|
||||
local objs = minetest.get_objects_inside_radius(pos, 4)
|
||||
for _, o in pairs(objs) do
|
||||
if o:is_player() then
|
||||
o:set_hp(math.max(o:get_hp() - 2, 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:hv_nuclear_reactor_core", "technic:hv_nuclear_reactor_core_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local machine_name = S("Nuclear Reactor Core")
|
||||
local burn_time = meta:get_int("burn_time") or 0
|
||||
if steel_layer >= 96 then
|
||||
for z = pos1.z+1, pos2.z-1 do
|
||||
for y = pos1.y+1, pos2.y-1 do
|
||||
for x = pos1.x+1, pos2.x-1 do
|
||||
local vi = area:index(x, y, z)
|
||||
if x == pos1.x+1 or x == pos2.x-1 or
|
||||
y == pos1.y+1 or y == pos2.y-1 or
|
||||
z == pos1.z+1 or z == pos2.z-1 then
|
||||
if data[vi] == c_steel then
|
||||
data[vi] = c_lead
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
lead_layer = steel_layer
|
||||
end
|
||||
|
||||
if burn_time >= burn_ticks or burn_time == 0 then
|
||||
if water_layer > 25 then water_layer = 25 end
|
||||
if lead_layer > 96 then lead_layer = 96 end
|
||||
if blast_layer > 216 then blast_layer = 216 end
|
||||
return (25 - water_layer) + (96 - lead_layer) + (216 - blast_layer)
|
||||
end
|
||||
|
||||
|
||||
local function melt_down_reactor(pos)
|
||||
minetest.log("action", "A reactor melted down at "..minetest.pos_to_string(pos))
|
||||
minetest.set_node(pos, {name = "technic:corium_source"})
|
||||
end
|
||||
|
||||
|
||||
local function start_reactor(pos, meta)
|
||||
if minetest.get_node(pos).name ~= "technic:hv_nuclear_reactor_core" then
|
||||
return false
|
||||
end
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
local srclist = inv:get_list("src")
|
||||
if inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
local src_list = inv:get_list("src")
|
||||
local correct_fuel_count = 0
|
||||
for _, srcstack in pairs(srclist) do
|
||||
if srcstack then
|
||||
if srcstack:get_name() == fuel_type then
|
||||
for _, src_stack in pairs(src_list) do
|
||||
if src_stack and src_stack:get_name() == fuel_type then
|
||||
correct_fuel_count = correct_fuel_count + 1
|
||||
end
|
||||
end
|
||||
-- Check that the reactor is complete and has the correct fuel
|
||||
if correct_fuel_count ~= 6 or reactor_structure_badness(pos) ~= 0 then
|
||||
return false
|
||||
end
|
||||
-- Check that the reactor is complete as well
|
||||
-- as the correct number of correct fuel
|
||||
if correct_fuel_count == 6 and
|
||||
check_reactor_structure(pos) then
|
||||
meta:set_int("burn_time", 1)
|
||||
hacky_swap_node(pos, "technic:hv_nuclear_reactor_core_active")
|
||||
technic.swap_node(pos, "technic:hv_nuclear_reactor_core_active")
|
||||
meta:set_int("HV_EU_supply", power_supply)
|
||||
for idx, srcstack in pairs(srclist) do
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", idx, srcstack)
|
||||
for idx, src_stack in pairs(src_list) do
|
||||
src_stack:take_item()
|
||||
inv:set_stack("src", idx, src_stack)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: reactor melt-down check",
|
||||
nodenames = {"technic:hv_nuclear_reactor_core_active"},
|
||||
interval = 4,
|
||||
chance = 1,
|
||||
action = function (pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local badness = reactor_structure_badness(pos)
|
||||
local accum_badness = meta:get_int("structure_accumulated_badness")
|
||||
if badness == 0 then
|
||||
if accum_badness ~= 0 then
|
||||
meta:set_int("structure_accumulated_badness", math.max(accum_badness - 4, 0))
|
||||
siren_clear(pos, meta)
|
||||
end
|
||||
else
|
||||
siren_danger(pos, meta)
|
||||
accum_badness = accum_badness + badness
|
||||
if accum_badness >= 25 then
|
||||
melt_down_reactor(pos)
|
||||
else
|
||||
meta:set_int("structure_accumulated_badness", accum_badness)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local function run(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local burn_time = meta:get_int("burn_time") or 0
|
||||
if burn_time >= burn_ticks or burn_time == 0 then
|
||||
if digiline_remote_path and meta:get_int("HV_EU_supply") == power_supply then
|
||||
digiline_remote.send_to_node(pos, meta:get_string("remote_channel"),
|
||||
"fuel used", 6, true)
|
||||
end
|
||||
if meta:get_string("autostart") == "true" then
|
||||
if start_reactor(pos, meta) then
|
||||
return
|
||||
end
|
||||
end
|
||||
meta:set_int("HV_EU_supply", 0)
|
||||
meta:set_int("burn_time", 0)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
hacky_swap_node(pos, "technic:hv_nuclear_reactor_core")
|
||||
meta:set_string("infotext", S("%s Idle"):format(reactor_desc))
|
||||
technic.swap_node(pos, "technic:hv_nuclear_reactor_core")
|
||||
meta:set_int("structure_accumulated_badness", 0)
|
||||
siren_clear(pos, meta)
|
||||
elseif burn_time > 0 then
|
||||
damage_nearby_players(pos)
|
||||
if not check_reactor_structure(pos) then
|
||||
explode_reactor(pos)
|
||||
end
|
||||
burn_time = burn_time + 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
local percent = math.floor(burn_time / burn_ticks * 100)
|
||||
meta:set_string("infotext", machine_name.." ("..percent.."%)")
|
||||
meta:set_string("infotext", reactor_desc.." ("..percent.."%)")
|
||||
meta:set_int("HV_EU_supply", power_supply)
|
||||
end
|
||||
end
|
||||
|
||||
local nuclear_reactor_receive_fields = function(pos, formname, fields, sender)
|
||||
local player_name = sender:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) then
|
||||
minetest.chat_send_player(player_name, "You are not allowed to edit this!")
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local update_formspec = false
|
||||
if fields.remote_channel then
|
||||
meta:set_string("remote_channel", fields.remote_channel)
|
||||
end
|
||||
if fields.start then
|
||||
local b = start_reactor(pos, meta)
|
||||
if b then
|
||||
minetest.chat_send_player(player_name, "Start successful")
|
||||
else
|
||||
minetest.chat_send_player(player_name, "Error")
|
||||
end
|
||||
end
|
||||
if fields.autostart then
|
||||
meta:set_string("autostart", fields.autostart)
|
||||
update_formspec = true
|
||||
end
|
||||
if fields.enable_digiline then
|
||||
meta:set_string("enable_digiline", fields.enable_digiline)
|
||||
update_formspec = true
|
||||
end
|
||||
if update_formspec then
|
||||
meta:set_string("formspec", make_reactor_formspec(meta))
|
||||
end
|
||||
end
|
||||
|
||||
local digiline_remote_def = function(pos, channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("enable_digiline") ~= "true" or
|
||||
channel ~= meta:get_string("remote_channel") then
|
||||
return
|
||||
end
|
||||
-- Convert string messages to tables:
|
||||
local msgt = type(msg)
|
||||
if msgt == "string" then
|
||||
local smsg = msg:lower()
|
||||
msg = {}
|
||||
if smsg == "get" then
|
||||
msg.command = "get"
|
||||
elseif smsg:sub(1, 13) == "self_destruct" then
|
||||
msg.command = "self_destruct"
|
||||
msg.timer = tonumber(smsg:sub(15)) or 0
|
||||
elseif smsg == "start" then
|
||||
msg.command = "start"
|
||||
end
|
||||
elseif msgt ~= "table" then
|
||||
return
|
||||
end
|
||||
|
||||
if msg.command == "get" then
|
||||
local inv = meta:get_inventory()
|
||||
local invtable = {}
|
||||
for i = 1, 6 do
|
||||
local stack = inv:get_stack("src", i)
|
||||
if stack:is_empty() then
|
||||
invtable[i] = 0
|
||||
elseif stack:get_name() == fuel_type then
|
||||
invtable[i] = stack:get_count()
|
||||
else
|
||||
invtable[i] = -stack:get_count()
|
||||
end
|
||||
end
|
||||
digiline_remote.send_to_node(pos, channel, {
|
||||
burn_time = meta:get_int("burn_time"),
|
||||
enabled = meta:get_int("HV_EU_supply") == power_supply,
|
||||
siren = meta:get_int("siren") == 1,
|
||||
structure_accumulated_badness = meta:get_int("structure_accumulated_badness"),
|
||||
rods = invtable
|
||||
}, 6, true)
|
||||
elseif digiline_meltdown and msg.command == "self_destruct" and
|
||||
minetest.get_node(pos).name == "technic:hv_nuclear_reactor_core_active" then
|
||||
if msg.timer ~= 0 and type(msg.timer) == "number" then
|
||||
siren_danger(pos, meta)
|
||||
minetest.after(msg.timer, melt_down_reactor, pos)
|
||||
else
|
||||
melt_down_reactor(pos)
|
||||
end
|
||||
elseif msg.command == "start" then
|
||||
local b = start_reactor(pos, meta)
|
||||
if b then
|
||||
digiline_remote.send_to_node(pos, channel, "Start successful", 6, true)
|
||||
else
|
||||
digiline_remote.send_to_node(pos, channel, "Error", 6, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:hv_nuclear_reactor_core", {
|
||||
description = reactor_desc,
|
||||
tiles = {
|
||||
"technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png"..cable_entry
|
||||
},
|
||||
drawtype = "mesh",
|
||||
mesh = "technic_reactor.obj",
|
||||
groups = {cracky = 1, technic_machine = 1, technic_hv = 1, digiline_remote_receive = 1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
stack_max = 1,
|
||||
on_receive_fields = nuclear_reactor_receive_fields,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", reactor_desc)
|
||||
meta:set_string("formspec", make_reactor_formspec(meta))
|
||||
if digiline_remote_path then
|
||||
meta:set_string("remote_channel",
|
||||
"nucelear_reactor"..minetest.pos_to_string(pos))
|
||||
end
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 6)
|
||||
end,
|
||||
_on_digiline_remote_receive = digiline_remote_def,
|
||||
can_dig = technic.machine_can_dig,
|
||||
on_destruct = function(pos) siren_set_state(pos, SS_OFF) end,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
||||
tiles = {
|
||||
"technic_hv_nuclear_reactor_core.png",
|
||||
"technic_hv_nuclear_reactor_core.png"..cable_entry
|
||||
},
|
||||
drawtype = "mesh",
|
||||
mesh = "technic_reactor.obj",
|
||||
groups = {cracky = 1, technic_machine = 1, technic_hv = 1, radioactive = 4,
|
||||
not_in_creative_inventory = 1, digiline_remote_receive = 1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:hv_nuclear_reactor_core",
|
||||
light_source = 14,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
on_receive_fields = nuclear_reactor_receive_fields,
|
||||
_on_digiline_remote_receive = digiline_remote_def,
|
||||
can_dig = technic.machine_can_dig,
|
||||
after_dig_node = melt_down_reactor,
|
||||
on_destruct = function(pos) siren_set_state(pos, SS_OFF) end,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
technic_on_disable = function(pos, node)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1)
|
||||
end,
|
||||
on_timer = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- Connected back?
|
||||
if meta:get_int("HV_EU_timeout") > 0 then return false end
|
||||
|
||||
local burn_time = meta:get_int("burn_time") or 0
|
||||
|
||||
if burn_time >= burn_ticks or burn_time == 0 then
|
||||
meta:set_int("HV_EU_supply", 0)
|
||||
meta:set_int("burn_time", 0)
|
||||
technic.swap_node(pos, "technic:hv_nuclear_reactor_core")
|
||||
meta:set_int("structure_accumulated_badness", 0)
|
||||
siren_clear(pos, meta)
|
||||
return false
|
||||
end
|
||||
|
||||
meta:set_int("burn_time", burn_time + 1)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine("HV", "technic:hv_nuclear_reactor_core", technic.producer)
|
||||
|
@ -1,203 +1,269 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_metallic.png"
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
minetest.register_craft({
|
||||
recipe = {
|
||||
{"default:steelblock", "pipeworks:filter", "default:steelblock"},
|
||||
{"default:steelblock", "technic:motor", "default:steelblock"},
|
||||
{"default:steelblock", "technic:diamond_drill_head", "default:steelblock"}},
|
||||
{"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"},
|
||||
{"technic:motor", "technic:machine_casing", "technic:diamond_drill_head"},
|
||||
{"technic:carbon_steel_block", "technic:hv_cable", "technic:carbon_steel_block"}},
|
||||
output = "technic:quarry",
|
||||
})
|
||||
|
||||
local quarry_dig_above_nodes = 3 -- How far above the quarry we will dig nodes
|
||||
local quarry_max_depth = 100
|
||||
local quarry_demand = 10000
|
||||
local quarry_eject_dir = vector.new(0, 1, 0)
|
||||
|
||||
local function get_quarry_formspec(size)
|
||||
return "size[3,1.5]"..
|
||||
"field[1,0.5;2,1;size;Radius;"..size.."]"..
|
||||
"button[0,1;3,1;toggle;"..S("Enable/Disable").."]"
|
||||
local function set_quarry_formspec(meta)
|
||||
local radius = meta:get_int("size")
|
||||
local formspec = "size[6,4.3]"..
|
||||
"list[context;cache;0,1;4,3;]"..
|
||||
"item_image[4.8,0;1,1;technic:quarry]"..
|
||||
"label[0,0.2;"..S("%s Quarry"):format("HV").."]"..
|
||||
"field[4.3,3.5;2,1;size;"..S("Radius:")..";"..radius.."]"
|
||||
if meta:get_int("enabled") == 0 then
|
||||
formspec = formspec.."button[4,1;2,1;enable;"..S("Disabled").."]"
|
||||
else
|
||||
formspec = formspec.."button[4,1;2,1;disable;"..S("Enabled").."]"
|
||||
end
|
||||
local diameter = radius*2 + 1
|
||||
local nd = meta:get_int("dug")
|
||||
local rel_y = quarry_dig_above_nodes - math.floor(nd / (diameter*diameter))
|
||||
formspec = formspec.."label[0,4;"..minetest.formspec_escape(
|
||||
nd == 0 and S("Digging not started") or
|
||||
(rel_y < -quarry_max_depth and S("Digging finished") or
|
||||
(meta:get_int("purge_on") == 1 and S("Purging cache") or
|
||||
S("Digging %d m "..(rel_y > 0 and "above" or "below").." machine")
|
||||
:format(math.abs(rel_y))))
|
||||
).."]"
|
||||
formspec = formspec.."button[4,2;2,1;restart;"..S("Restart").."]"
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
|
||||
local function set_quarry_demand(meta)
|
||||
local radius = meta:get_int("size")
|
||||
local diameter = radius*2 + 1
|
||||
local machine_name = S("%s Quarry"):format("HV")
|
||||
if meta:get_int("enabled") == 0 or meta:get_int("purge_on") == 1 then
|
||||
meta:set_string("infotext", S(meta:get_int("purge_on") == 1 and "%s purging cache" or "%s Disabled"):format(machine_name))
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
elseif meta:get_int("dug") == diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) then
|
||||
meta:set_string("infotext", S("%s Finished"):format(machine_name))
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
else
|
||||
meta:set_string("infotext", S(meta:get_int("HV_EU_input") >= quarry_demand and "%s Active" or "%s Unpowered"):format(machine_name))
|
||||
meta:set_int("HV_EU_demand", quarry_demand)
|
||||
end
|
||||
end
|
||||
|
||||
local function quarry_receive_fields(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.size and string.find(fields.size, "^[0-9]+$") then
|
||||
local size = tonumber(fields.size)
|
||||
|
||||
if fields.toggle then
|
||||
if meta:get_int("enabled") == 0 then
|
||||
meta:set_int("enabled", 1)
|
||||
else
|
||||
meta:set_int("enabled", 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Smallest size is 2. Anything less is asking for trouble.
|
||||
-- Largest is 8. It is a matter of pratical node handling.
|
||||
size = math.max(size, 2)
|
||||
size = math.min(size, 8)
|
||||
|
||||
if meta:get_int("size") ~= size then
|
||||
if size >= 2 and size <= 8 and size ~= meta:get_int("size") then
|
||||
meta:set_int("size", size)
|
||||
meta:set_string("formspec", get_quarry_formspec(size))
|
||||
meta:set_int("dug", 0)
|
||||
end
|
||||
end
|
||||
if fields.enable then meta:set_int("enabled", 1) end
|
||||
if fields.disable then meta:set_int("enabled", 0) end
|
||||
if fields.restart then
|
||||
meta:set_int("dug", 0)
|
||||
meta:set_int("purge_on", 1)
|
||||
end
|
||||
set_quarry_formspec(meta)
|
||||
set_quarry_demand(meta)
|
||||
end
|
||||
|
||||
local function get_quarry_center(pos, size)
|
||||
local node = minetest.get_node(pos)
|
||||
local back_dir = minetest.facedir_to_dir(node.param2)
|
||||
local relative_center = vector.multiply(back_dir, size + 1)
|
||||
local center = vector.add(pos, relative_center)
|
||||
return center
|
||||
end
|
||||
|
||||
local function gen_next_digpos(center, digpos, size)
|
||||
digpos.x = digpos.x + 1
|
||||
if digpos.x > center.x + size then
|
||||
digpos.x = center.x - size
|
||||
digpos.z = digpos.z + 1
|
||||
end
|
||||
if digpos.z > center.z + size then
|
||||
digpos.x = center.x - size
|
||||
digpos.z = center.z - size
|
||||
digpos.y = digpos.y - 1
|
||||
end
|
||||
end
|
||||
|
||||
local function find_next_digpos(data, area, center, dig_y, size)
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
for y = center.y + quarry_dig_above_nodes, dig_y - 1, -1 do
|
||||
for z = center.z - size, center.z + size do
|
||||
for x = center.x - size, center.x + size do
|
||||
if data[area:index(x, y, z)] ~= c_air then
|
||||
return vector.new(x, y, z)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function quarry_dig(pos, center, size)
|
||||
local function quarry_handle_purge(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local drops = {}
|
||||
local dig_y = meta:get_int("dig_y")
|
||||
local owner = meta:get_int("owner")
|
||||
|
||||
local vm = VoxelManip()
|
||||
local p1 = vector.new(
|
||||
center.x - size,
|
||||
center.y + quarry_dig_above_nodes,
|
||||
center.z - size)
|
||||
local p2 = vector.new(
|
||||
center.x + size,
|
||||
dig_y - 1, -- One node lower in case we have finished the current layer
|
||||
center.z + size)
|
||||
local e1, e2 = vm:read_from_map(p1, p2)
|
||||
local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
|
||||
local data = vm:get_data()
|
||||
|
||||
local digpos = find_next_digpos(data, area, center, dig_y, size)
|
||||
|
||||
if digpos then
|
||||
if digpos.y < pos.y - quarry_max_depth then
|
||||
meta:set_int("dig_y", digpos.y)
|
||||
return drops
|
||||
local inv = meta:get_inventory()
|
||||
local i = 0
|
||||
for _,stack in ipairs(inv:get_list("cache")) do
|
||||
i = i + 1
|
||||
if stack then
|
||||
local item = stack:to_table()
|
||||
if item then
|
||||
technic.tube_inject_item(pos, pos, quarry_eject_dir, item)
|
||||
stack:clear()
|
||||
inv:set_stack("cache", i, stack)
|
||||
break
|
||||
end
|
||||
if minetest.is_protected and minetest.is_protected(digpos, owner) then
|
||||
meta:set_int("enabled", 0)
|
||||
return
|
||||
end
|
||||
dig_y = digpos.y
|
||||
local node = minetest.get_node(digpos)
|
||||
drops = minetest.get_node_drops(node.name, "")
|
||||
minetest.dig_node(digpos)
|
||||
if minetest.get_node(digpos).name == node.name then
|
||||
-- We tried to dig something undigable like a
|
||||
-- filled chest. Notice that we check for a node
|
||||
-- change, not for air. This is so that we get drops
|
||||
-- from things like concrete posts with platforms,
|
||||
-- which turn into regular concrete posts when dug.
|
||||
drops = {}
|
||||
end
|
||||
elseif not (dig_y < pos.y - quarry_max_depth) then
|
||||
dig_y = dig_y - 16
|
||||
if inv:is_empty("cache") then
|
||||
meta:set_int("purge_on", 0)
|
||||
end
|
||||
end
|
||||
|
||||
meta:set_int("dig_y", dig_y)
|
||||
return drops
|
||||
local function quarry_run(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
-- initialize cache for the case we load an older world
|
||||
inv:set_size("cache", 12)
|
||||
-- toss a coin whether we do an automatic purge. Chance 1:200
|
||||
local purge_rand = math.random()
|
||||
if purge_rand <= 0.005 then
|
||||
meta:set_int("purge_on", 1)
|
||||
end
|
||||
|
||||
local function send_items(items, pos, node)
|
||||
for _, item in pairs(items) do
|
||||
local tube_item = tube_item(vector.new(pos), item)
|
||||
tube_item:get_luaentity().start_pos = vector.new(pos)
|
||||
tube_item:setvelocity(vector.new(0, 1, 0))
|
||||
tube_item:setacceleration({x=0, y=0, z=0})
|
||||
if meta:get_int("enabled") and meta:get_int("HV_EU_input") >= quarry_demand and meta:get_int("purge_on") == 0 then
|
||||
local pdir = minetest.facedir_to_dir(node.param2)
|
||||
local qdir = pdir.x == 1 and vector.new(0,0,-1) or
|
||||
(pdir.z == -1 and vector.new(-1,0,0) or
|
||||
(pdir.x == -1 and vector.new(0,0,1) or
|
||||
vector.new(1,0,0)))
|
||||
local radius = meta:get_int("size")
|
||||
local diameter = radius*2 + 1
|
||||
local startpos = vector.add(vector.add(vector.add(pos,
|
||||
vector.new(0, quarry_dig_above_nodes, 0)),
|
||||
pdir),
|
||||
vector.multiply(qdir, -radius))
|
||||
local owner = meta:get_string("owner")
|
||||
local nd = meta:get_int("dug")
|
||||
while nd ~= diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) do
|
||||
local ry = math.floor(nd / (diameter*diameter))
|
||||
local ndl = nd % (diameter*diameter)
|
||||
if ry % 2 == 1 then
|
||||
ndl = diameter*diameter - 1 - ndl
|
||||
end
|
||||
local rq = math.floor(ndl / diameter)
|
||||
local rp = ndl % diameter
|
||||
if rq % 2 == 1 then rp = diameter - 1 - rp end
|
||||
local digpos = vector.add(vector.add(vector.add(startpos,
|
||||
vector.new(0, -ry, 0)),
|
||||
vector.multiply(pdir, rp)),
|
||||
vector.multiply(qdir, rq))
|
||||
local can_dig = true
|
||||
if can_dig and minetest.is_protected and minetest.is_protected(digpos, owner) then
|
||||
can_dig = false
|
||||
end
|
||||
local dignode
|
||||
if can_dig then
|
||||
dignode = technic.get_or_load_node(digpos) or minetest.get_node(digpos)
|
||||
local dignodedef = minetest.registered_nodes[dignode.name] or {diggable=false}
|
||||
-- doors mod among other thing does NOT like a nil digger...
|
||||
local fakedigger = {
|
||||
get_player_name = function()
|
||||
return "!technic_quarry_fake_digger"
|
||||
end,
|
||||
is_player = function() return false end,
|
||||
get_wielded_item = function()
|
||||
return ItemStack("air")
|
||||
end,
|
||||
}
|
||||
if not dignodedef.diggable or (dignodedef.can_dig and not dignodedef.can_dig(digpos, fakedigger)) then
|
||||
can_dig = false
|
||||
end
|
||||
end
|
||||
|
||||
if can_dig then
|
||||
for ay = startpos.y, digpos.y+1, -1 do
|
||||
local checkpos = {x=digpos.x, y=ay, z=digpos.z}
|
||||
local checknode = technic.get_or_load_node(checkpos) or minetest.get_node(checkpos)
|
||||
if checknode.name ~= "air" then
|
||||
can_dig = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
nd = nd + 1
|
||||
if can_dig then
|
||||
minetest.remove_node(digpos)
|
||||
local drops = minetest.get_node_drops(dignode.name, "")
|
||||
for _, dropped_item in ipairs(drops) do
|
||||
local left = inv:add_item("cache", dropped_item)
|
||||
while not left:is_empty() do
|
||||
meta:set_int("purge_on", 1)
|
||||
quarry_handle_purge(pos)
|
||||
left = inv:add_item("cache", left)
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
if nd == diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) then
|
||||
-- if a quarry is finished, we enable purge mode
|
||||
meta:set_int("purge_on", 1)
|
||||
end
|
||||
meta:set_int("dug", nd)
|
||||
else
|
||||
-- if a quarry is disabled or has no power, we enable purge mode
|
||||
meta:set_int("purge_on", 1)
|
||||
end
|
||||
-- if something triggered a purge, we handle it
|
||||
if meta:get_int("purge_on") == 1 then
|
||||
quarry_handle_purge(pos)
|
||||
end
|
||||
set_quarry_formspec(meta)
|
||||
set_quarry_demand(meta)
|
||||
end
|
||||
|
||||
local function send_move_error(player)
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Manually taking/removing from cache by hand is not possible. "..
|
||||
"If you can't wait, restart or disable the quarry to start automatic purge."))
|
||||
return 0
|
||||
end
|
||||
|
||||
minetest.register_node("technic:quarry", {
|
||||
description = S("Quarry"),
|
||||
tiles = {"default_steel_block.png", "default_steel_block.png",
|
||||
"default_steel_block.png", "default_steel_block.png",
|
||||
"default_steel_block.png^default_tool_mesepick.png", "default_steel_block.png"},
|
||||
description = S("%s Quarry"):format("HV"),
|
||||
tiles = {
|
||||
"technic_carbon_steel_block.png"..tube_entry,
|
||||
"technic_carbon_steel_block.png"..cable_entry,
|
||||
"technic_carbon_steel_block.png"..cable_entry,
|
||||
"technic_carbon_steel_block.png"..cable_entry,
|
||||
"technic_carbon_steel_block.png^default_tool_mesepick.png",
|
||||
"technic_carbon_steel_block.png"..cable_entry
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, tubedevice=1},
|
||||
groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1},
|
||||
connect_sides = {"bottom", "front", "left", "right"},
|
||||
tube = {
|
||||
connect_sides = {top = 1},
|
||||
-- lower priority than other tubes, so that quarries will prefer any
|
||||
-- other tube to another quarry, which could lead to server freezes
|
||||
-- in certain quarry placements (2x2 for example would never eject)
|
||||
priority = 10,
|
||||
can_go = function(pos, node, velocity, stack)
|
||||
-- always eject the same, even if items came in another way
|
||||
-- this further mitigates loops and generally avoids random sideway movement
|
||||
-- that can be expected in certain quarry placements
|
||||
return { quarry_eject_dir }
|
||||
end
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local size = 4
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Quarry"))
|
||||
meta:set_string("formspec", get_quarry_formspec(4))
|
||||
meta:set_int("size", size)
|
||||
meta:set_int("dig_y", pos.y)
|
||||
meta:set_string("infotext", S("%s Quarry"):format("HV"))
|
||||
meta:set_int("size", 4)
|
||||
set_quarry_formspec(meta)
|
||||
set_quarry_demand(meta)
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
tube_scanforobjects(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
after_dig_node = tube_scanforobjects,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("cache")
|
||||
end,
|
||||
after_dig_node = pipeworks.scan_for_tube_objects,
|
||||
on_receive_fields = quarry_receive_fields,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:quarry"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local size = meta:get_int("size")
|
||||
local eu_input = meta:get_int("HV_EU_input")
|
||||
local demand = 10000
|
||||
local center = get_quarry_center(pos, size)
|
||||
local dig_y = meta:get_int("dig_y")
|
||||
local machine_name = S("Quarry")
|
||||
|
||||
technic.switching_station_timeout_count(pos, "HV")
|
||||
|
||||
if meta:get_int("enabled") == 0 then
|
||||
meta:set_string("infotext", S("%s Disabled"):format(machine_name))
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < demand then
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= demand then
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
|
||||
local items = quarry_dig(pos, center, size)
|
||||
send_items(items, pos, node)
|
||||
|
||||
if dig_y < pos.y - quarry_max_depth then
|
||||
meta:set_string("infotext", S("%s Finished"):format(machine_name))
|
||||
end
|
||||
end
|
||||
meta:set_int("HV_EU_demand", demand)
|
||||
technic_run = quarry_run,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
return send_move_error(player)
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
return send_move_error(player)
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
return send_move_error(player)
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_machine("HV", "technic:quarry", technic.receiver)
|
||||
|
||||
|
@ -5,8 +5,8 @@ minetest.register_craft({
|
||||
output = 'technic:solar_array_hv 1',
|
||||
recipe = {
|
||||
{'technic:solar_array_mv', 'technic:solar_array_mv', 'technic:solar_array_mv'},
|
||||
{'default:steel_ingot', 'technic:hv_transformer', 'default:steel_ingot'},
|
||||
{'', 'technic:hv_cable0', ''},
|
||||
{'technic:carbon_plate', 'technic:hv_transformer', 'technic:composite_plate'},
|
||||
{'', 'technic:hv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -5,10 +5,10 @@ minetest.register_craft({
|
||||
output = 'technic:lv_alloy_furnace',
|
||||
recipe = {
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
{'default:brick', '', 'default:brick'},
|
||||
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
|
||||
{'default:brick', 'technic:machine_casing', 'default:brick'},
|
||||
{'default:brick', 'technic:lv_cable', 'default:brick'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_alloy_furnace({tier="LV", cook_time=6, demand={300}})
|
||||
technic.register_alloy_furnace({tier = "LV", speed = 1, demand = {300}})
|
||||
|
||||
|
@ -1,43 +1,17 @@
|
||||
-- LV Battery box and some other nodes...
|
||||
|
||||
technic.register_power_tool("technic:battery", 10000)
|
||||
technic.register_power_tool("technic:red_energy_crystal", 100000)
|
||||
technic.register_power_tool("technic:green_energy_crystal", 250000)
|
||||
technic.register_power_tool("technic:blue_energy_crystal", 500000)
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:battery',
|
||||
recipe = {
|
||||
{'group:wood', 'default:copper_ingot', 'group:wood'},
|
||||
{'group:wood', 'moreores:tin_ingot', 'group:wood'},
|
||||
{'group:wood', 'default:copper_ingot', 'group:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_tool("technic:battery", {
|
||||
description = "RE Battery",
|
||||
inventory_image = "technic_battery.png",
|
||||
tool_capabilities = {
|
||||
charge = 0,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
fleshy = {times={}, uses=10000, maxlevel=0}
|
||||
}
|
||||
}
|
||||
})
|
||||
-- LV Battery box
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:lv_battery_box0',
|
||||
recipe = {
|
||||
{'technic:battery', 'group:wood', 'technic:battery'},
|
||||
{'technic:battery', 'default:copper_ingot', 'technic:battery'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'technic:battery', 'technic:machine_casing', 'technic:battery'},
|
||||
{'technic:battery', 'technic:lv_cable', 'technic:battery'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_battery_box({
|
||||
tier = "LV",
|
||||
max_charge = 50000,
|
||||
max_charge = 40000,
|
||||
charge_rate = 1000,
|
||||
discharge_rate = 4000,
|
||||
charge_step = 500,
|
||||
|
@ -1,10 +1,12 @@
|
||||
|
||||
minetest.register_alias("lv_cable", "technic:lv_cable0")
|
||||
minetest.register_alias("lv_cable", "technic:lv_cable")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:lv_cable0 6',
|
||||
output = 'technic:lv_cable 6',
|
||||
recipe = {
|
||||
{'default:paper', 'default:paper', 'default:paper'},
|
||||
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
|
||||
{'default:paper', 'default:paper', 'default:paper'},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -9,6 +9,17 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:cnc',
|
||||
recipe = {
|
||||
{'default:glass', 'technic:diamond_drill_head', 'default:glass'},
|
||||
{'technic:control_logic_unit', 'technic:machine_casing', 'technic:motor'},
|
||||
{'technic:carbon_steel_ingot', 'technic:lv_cable', 'technic:carbon_steel_ingot'},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
local shape = {}
|
||||
local onesize_products = {
|
||||
slope = 2,
|
||||
@ -17,6 +28,7 @@ local onesize_products = {
|
||||
pyramid = 2,
|
||||
spike = 1,
|
||||
cylinder = 2,
|
||||
oblate_spheroid = 1,
|
||||
sphere = 1,
|
||||
stick = 8,
|
||||
slope_upsdown = 2,
|
||||
@ -36,27 +48,28 @@ local twosize_products = {
|
||||
}
|
||||
|
||||
local cnc_formspec =
|
||||
"invsize[9,11;]"..
|
||||
"label[1,0;Choose Milling Program:]"..
|
||||
"size[9,11;]"..
|
||||
"label[1,0;"..S("Choose Milling Program:").."]"..
|
||||
"image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]"..
|
||||
"image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]"..
|
||||
"image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]"..
|
||||
"image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]"..
|
||||
"image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]"..
|
||||
"image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]"..
|
||||
"image_button[7,0.5;1,1;technic_cnc_sphere.png;sphere; ]"..
|
||||
"image_button[7,0.5;1,1;technic_cnc_oblate_spheroid.png;oblate_spheroid; ]"..
|
||||
"image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]"..
|
||||
|
||||
"image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]"..
|
||||
"image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]"..
|
||||
"image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]"..
|
||||
"image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]"..
|
||||
"image_button[5,1.5;1,1;technic_cnc_sphere.png;sphere; ]"..
|
||||
|
||||
"image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]"..
|
||||
"image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]"..
|
||||
"image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]"..
|
||||
|
||||
"label[1,3.5;Slim Elements half / normal height:]"..
|
||||
"label[1,3.5;"..S("Slim Elements half / normal height:").."]"..
|
||||
|
||||
"image_button[1,4;1,0.5;technic_cnc_full.png;full; ]"..
|
||||
"image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]"..
|
||||
@ -66,12 +79,16 @@ local cnc_formspec =
|
||||
"image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
|
||||
"image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
|
||||
|
||||
"label[0, 5.5;In:]"..
|
||||
"label[0, 5.5;"..S("In:").."]"..
|
||||
"list[current_name;src;0.5,5.5;1,1;]"..
|
||||
"label[4, 5.5;Out:]"..
|
||||
"label[4, 5.5;"..S("Out:").."]"..
|
||||
"list[current_name;dst;5,5.5;4,1;]"..
|
||||
|
||||
"list[current_player;main;0,7;8,4;]"
|
||||
"list[current_player;main;0,7;8,4;]"..
|
||||
"listring[current_name;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;src]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
local size = 1;
|
||||
|
||||
@ -125,105 +142,31 @@ local function form_handler(pos, formname, fields, sender)
|
||||
return
|
||||
end
|
||||
|
||||
-- The actual block inactive state
|
||||
minetest.register_node("technic:cnc", {
|
||||
description = S("CNC Machine"),
|
||||
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
||||
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
},
|
||||
},
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("CNC Machine"))
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", cnc_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
on_receive_fields = form_handler,
|
||||
})
|
||||
|
||||
-- Active state block
|
||||
minetest.register_node("technic:cnc_active", {
|
||||
description = S("CNC Machine"),
|
||||
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
||||
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
on_receive_fields = form_handler,
|
||||
})
|
||||
|
||||
-- Action code performing the transformation
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:cnc","technic:cnc_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
local machine_name = S("CNC Machine")
|
||||
local machine_name = S("%s CNC Machine"):format("LV")
|
||||
local machine_node = "technic:cnc"
|
||||
local demand = 450
|
||||
|
||||
-- Setup meta data if it does not exist. state is used as an indicator of this
|
||||
if not eu_input then
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
meta:set_int("LV_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "LV")
|
||||
|
||||
|
||||
local result = meta:get_string("cnc_product")
|
||||
if inv:is_empty("src") or
|
||||
(not minetest.registered_nodes[result]) or
|
||||
(not inv:room_for_item("dst", result)) then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_string("cnc_product", "")
|
||||
meta:set_int("LV_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < demand then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= demand then
|
||||
hacky_swap_node(pos, machine_node.."_active")
|
||||
technic.swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") >= 3 then -- 3 ticks per output
|
||||
@ -236,20 +179,52 @@ minetest.register_abm({
|
||||
end
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
end
|
||||
|
||||
-- The actual block inactive state
|
||||
minetest.register_node("technic:cnc", {
|
||||
description = S("%s CNC Machine"):format("LV"),
|
||||
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
||||
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
|
||||
groups = {cracky=2, technic_machine=1, technic_lv=1},
|
||||
connect_sides = {"bottom", "back", "left", "right"},
|
||||
paramtype2 = "facedir",
|
||||
legacy_facedir_simple = true,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("%s CNC Machine"):format("LV"))
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", cnc_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
on_receive_fields = form_handler,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
-- Active state block
|
||||
minetest.register_node("technic:cnc_active", {
|
||||
description = S("%s CNC Machine"):format("LV"),
|
||||
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
||||
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
|
||||
groups = {cracky=2, technic_machine=1, technic_lv=1, not_in_creative_inventory=1},
|
||||
connect_sides = {"bottom", "back", "left", "right"},
|
||||
paramtype2 = "facedir",
|
||||
drop = "technic:cnc",
|
||||
legacy_facedir_simple = true,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
on_receive_fields = form_handler,
|
||||
technic_run = run,
|
||||
technic_disabled_machine_name = "technic:cnc",
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:cnc", technic.receiver)
|
||||
technic.register_machine("LV", "technic:cnc_active", technic.receiver)
|
||||
|
||||
-------------------------
|
||||
-- CNC Machine Recipe
|
||||
-------------------------
|
||||
minetest.register_craft({
|
||||
output = 'technic:cnc',
|
||||
recipe = {
|
||||
{'default:glass', 'technic:diamond_drill_head', 'default:glass'},
|
||||
{'technic:control_logic_unit', 'technic:motor', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -5,293 +5,305 @@ local S = technic.getter
|
||||
|
||||
technic.cnc = {}
|
||||
|
||||
technic.cnc.detail_level = 16
|
||||
|
||||
-- REGISTER NONCUBIC FORMS, CREATE MODELS AND RECIPES:
|
||||
------------------------------------------------------
|
||||
local function cnc_sphere()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
local sehne
|
||||
for i = 1, detail - 1 do
|
||||
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
|
||||
nodebox[i]={-sehne, (i/detail) - 0.5, -sehne, sehne, (i/detail)+(1/detail)-0.5, sehne}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_cylinder_horizontal()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
local sehne
|
||||
for i = 1, detail - 1 do
|
||||
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
|
||||
nodebox[i]={-0.5, (i/detail)-0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, sehne}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_cylinder()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
local sehne
|
||||
for i = 1, detail - 1 do
|
||||
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
|
||||
nodebox[i]={(i/detail) - 0.5, -0.5, -sehne, (i/detail)+(1/detail)-0.5, 0.5, sehne}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_twocurvededge()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level * 2
|
||||
local sehne
|
||||
for i = (detail / 2) - 1, detail - 1 do
|
||||
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
|
||||
nodebox[i]={-sehne, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_onecurvededge()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level * 2
|
||||
local sehne
|
||||
for i = (detail / 2) - 1, detail - 1 do
|
||||
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
|
||||
nodebox[i]={-0.5, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_spike()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail - 1 do
|
||||
nodebox[i+1] = {(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5,
|
||||
0.5-(i/detail/2), (i/detail)-0.5+(1/detail), 0.5-(i/detail/2)}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_pyramid()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level / 2
|
||||
for i = 0, detail - 1 do
|
||||
nodebox[i+1] = {(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail/2)-0.5+(1/detail), 0.5-(i/detail/2)}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope_inner_edge_upsdown()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {0.5-(i/detail)-(1/detail), (i/detail)-0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
nodebox[i+detail+1] = {-0.5, (i/detail)-0.5, 0.5-(i/detail)-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope_edge_upsdown()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {(-1*(i/detail))+0.5-(1/detail), (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope_inner_edge()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {(i/detail)-0.5, -0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
nodebox[i+detail+1] = {-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope_edge()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {(i/detail)-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope_upsdown()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {-0.5, (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope_lying()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {(i/detail)-0.5, -0.5, (i/detail)-0.5, (i/detail)-0.5+(1/detail), 0.5 , 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
local function cnc_slope()
|
||||
local nodebox = {}
|
||||
local detail = technic.cnc.detail_level
|
||||
for i = 0, detail-1 do
|
||||
nodebox[i+1] = {-0.5, (i/detail)-0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
|
||||
end
|
||||
return nodebox
|
||||
end
|
||||
|
||||
-- Define slope boxes for the various nodes
|
||||
-------------------------------------------
|
||||
technic.cnc.programs = {
|
||||
{ suffix = "technic_cnc_stick",
|
||||
nodebox = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
|
||||
desc = S("Stick")},
|
||||
model = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
|
||||
desc = S("Stick")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_end_double",
|
||||
nodebox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
|
||||
desc = S("Element End Double")},
|
||||
model = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
|
||||
desc = S("Element End Double")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_cross_double",
|
||||
nodebox = {
|
||||
model = {
|
||||
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3},
|
||||
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
|
||||
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
|
||||
desc = S("Element Cross Double")},
|
||||
desc = S("Element Cross Double")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_t_double",
|
||||
nodebox = {
|
||||
model = {
|
||||
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
|
||||
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3},
|
||||
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3}},
|
||||
desc = S("Element T Double")},
|
||||
desc = S("Element T Double")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_edge_double",
|
||||
nodebox = {
|
||||
model = {
|
||||
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
|
||||
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
|
||||
desc = S("Element Edge Double")},
|
||||
desc = S("Element Edge Double")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_straight_double",
|
||||
nodebox = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
|
||||
desc = S("Element Straight Double")},
|
||||
model = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
|
||||
desc = S("Element Straight Double")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_end",
|
||||
nodebox = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
|
||||
desc = S("Element End")},
|
||||
model = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
|
||||
desc = S("Element End")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_cross",
|
||||
nodebox = {
|
||||
model = {
|
||||
{0.3, -0.5, -0.3, 0.5, 0, 0.3},
|
||||
{-0.3, -0.5, -0.5, 0.3, 0, 0.5},
|
||||
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
|
||||
desc = S("Element Cross")},
|
||||
desc = S("Element Cross")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_t",
|
||||
nodebox = {
|
||||
model = {
|
||||
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
|
||||
{-0.5, -0.5, -0.3, -0.3, 0, 0.3},
|
||||
{0.3, -0.5, -0.3, 0.5, 0, 0.3}},
|
||||
desc = S("Element T")},
|
||||
desc = S("Element T")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_edge",
|
||||
nodebox = {
|
||||
model = {
|
||||
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
|
||||
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
|
||||
desc = S("Element Edge")},
|
||||
desc = S("Element Edge")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_element_straight",
|
||||
nodebox = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
|
||||
desc = S("Element Straight")},
|
||||
model = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
|
||||
desc = S("Element Straight")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_oblate_spheroid",
|
||||
model = "technic_oblate_spheroid.obj",
|
||||
desc = S("Oblate spheroid"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -6/16, 4/16, -6/16, 6/16, 8/16, 6/16 },
|
||||
{ -8/16, -4/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
{ -6/16, -8/16, -6/16, 6/16, -4/16, 6/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_sphere",
|
||||
nodebox = cnc_sphere(),
|
||||
desc = S("Sphere")},
|
||||
model = "technic_sphere.obj",
|
||||
desc = S("Sphere")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_cylinder_horizontal",
|
||||
nodebox = cnc_cylinder_horizontal(),
|
||||
desc = S("Horizontal Cylinder")},
|
||||
model = "technic_cylinder_horizontal.obj",
|
||||
desc = S("Horizontal Cylinder")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_cylinder",
|
||||
nodebox = cnc_cylinder(),
|
||||
desc = S("Cylinder")},
|
||||
model = "technic_cylinder.obj",
|
||||
desc = S("Cylinder")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_twocurvededge",
|
||||
nodebox = cnc_twocurvededge(),
|
||||
desc = S("Two Curved Edge Block")},
|
||||
model = "technic_two_curved_edge.obj",
|
||||
desc = S("Two Curved Edge/Corner Block")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_onecurvededge",
|
||||
nodebox = cnc_onecurvededge(),
|
||||
desc = S("One Curved Edge Block")},
|
||||
model = "technic_one_curved_edge.obj",
|
||||
desc = S("One Curved Edge Block")
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_spike",
|
||||
nodebox = cnc_spike(),
|
||||
desc = S("Spike")},
|
||||
model = "technic_pyramid_spike.obj",
|
||||
desc = S("Spike"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -2/16, 4/16, -2/16, 2/16, 8/16, 2/16 },
|
||||
{ -4/16, 0, -4/16, 4/16, 4/16, 4/16 },
|
||||
{ -6/16, -4/16, -6/16, 6/16, 0, 6/16 },
|
||||
{ -8/16, -8/16, -8/16, 8/16, -4/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_pyramid",
|
||||
nodebox = cnc_pyramid(),
|
||||
desc = S("Pyramid")},
|
||||
model = "technic_pyramid.obj",
|
||||
desc = S("Pyramid"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -2/16, -2/16, -2/16, 2/16, 0, 2/16 },
|
||||
{ -4/16, -4/16, -4/16, 4/16, -2/16, 4/16 },
|
||||
{ -6/16, -6/16, -6/16, 6/16, -4/16, 6/16 },
|
||||
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope_inner_edge_upsdown",
|
||||
nodebox = cnc_slope_inner_edge_upsdown(),
|
||||
desc = S("Slope Upside Down Inner Edge")},
|
||||
model = "technic_innercorner_upsdown.obj",
|
||||
desc = S("Slope Upside Down Inner Edge/Corner"),
|
||||
sbox = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
|
||||
},
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ 0.25, -0.25, -0.5, 0.5, -0.5, 0.5 },
|
||||
{ -0.5, -0.25, 0.25, 0.5, -0.5, 0.5 },
|
||||
{ 0, 0, -0.5, 0.5, -0.25, 0.5 },
|
||||
{ -0.5, 0, 0, 0.5, -0.25, 0.5 },
|
||||
{ -0.25, 0.25, -0.5, 0.5, 0, -0.25 },
|
||||
{ -0.5, 0.25, -0.25, 0.5, 0, 0.5 },
|
||||
{ -0.5, 0.5, -0.5, 0.5, 0.25, 0.5 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope_edge_upsdown",
|
||||
nodebox = cnc_slope_edge_upsdown(),
|
||||
desc = S("Slope Upside Down Edge")},
|
||||
model = "technic_outercorner_upsdown.obj",
|
||||
desc = S("Slope Upside Down Outer Edge/Corner"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, 8/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
{ -4/16, 4/16, -4/16, 8/16, 0, 8/16 },
|
||||
{ 0, 0, 0, 8/16, -4/16, 8/16 },
|
||||
{ 4/16, -4/16, 4/16, 8/16, -8/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope_inner_edge",
|
||||
nodebox = cnc_slope_inner_edge(),
|
||||
desc = S("Slope Inner Edge")},
|
||||
model = "technic_innercorner.obj",
|
||||
desc = S("Slope Inner Edge/Corner"),
|
||||
sbox = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
|
||||
},
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 },
|
||||
{ -0.5, -0.25, -0.25, 0.5, 0, 0.5 },
|
||||
{ -0.25, -0.25, -0.5, 0.5, 0, -0.25 },
|
||||
{ -0.5, 0, 0, 0.5, 0.25, 0.5 },
|
||||
{ 0, 0, -0.5, 0.5, 0.25, 0.5 },
|
||||
{ -0.5, 0.25, 0.25, 0.5, 0.5, 0.5 },
|
||||
{ 0.25, 0.25, -0.5, 0.5, 0.5, 0.5 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope_edge",
|
||||
nodebox = cnc_slope_edge(),
|
||||
desc = S("Slope Edge")},
|
||||
model = "technic_outercorner.obj",
|
||||
desc = S("Slope Outer Edge/Corner"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ 4/16, 4/16, 4/16, 8/16, 8/16, 8/16 },
|
||||
{ 0, 0, 0, 8/16, 4/16, 8/16 },
|
||||
{ -4/16, -4/16, -4/16, 8/16, 0, 8/16 },
|
||||
{ -8/16, -8/16, -8/16, 8/16, -4/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope_upsdown",
|
||||
nodebox = cnc_slope_upsdown(),
|
||||
desc = S("Slope Upside Down")},
|
||||
model = "technic_slope_upsdown.obj",
|
||||
desc = S("Slope Upside Down"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, 8/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
{ -8/16, 4/16, -4/16, 8/16, 0, 8/16 },
|
||||
{ -8/16, 0, 0, 8/16, -4/16, 8/16 },
|
||||
{ -8/16, -4/16, 4/16, 8/16, -8/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope_lying",
|
||||
nodebox = cnc_slope_lying(),
|
||||
desc = S("Slope Lying")},
|
||||
model = "technic_slope_horizontal.obj",
|
||||
desc = S("Slope Lying"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ 4/16, -8/16, 4/16, 8/16, 8/16, 8/16 },
|
||||
{ 0, -8/16, 0, 4/16, 8/16, 8/16 },
|
||||
{ -4/16, -8/16, -4/16, 0, 8/16, 8/16 },
|
||||
{ -8/16, -8/16, -8/16, -4/16, 8/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{ suffix = "technic_cnc_slope",
|
||||
nodebox = cnc_slope(),
|
||||
desc = S("Slope")},
|
||||
model = "technic_slope.obj",
|
||||
desc = S("Slope"),
|
||||
cbox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, 4/16, 4/16, 8/16, 8/16, 8/16 },
|
||||
{ -8/16, 0, 0, 8/16, 4/16, 8/16 },
|
||||
{ -8/16, -4/16, -4/16, 8/16, 0, 8/16 },
|
||||
{ -8/16, -8/16, -8/16, 8/16, -4/16, 8/16 }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
-- Allow disabling certain programs for some node. Default is allowing all types for all nodes
|
||||
technic.cnc.programs_disable = {
|
||||
-- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick
|
||||
-- ...
|
||||
["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown", "technic_cnc_edge",
|
||||
["default:dirt"] = {"technic_cnc_oblate_spheroid", "technic_cnc_slope_upsdown", "technic_cnc_edge",
|
||||
"technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown",
|
||||
"technic_cnc_slope_inner_edge_upsdown", "technic_cnc_stick",
|
||||
"technic_cnc_cylinder_horizontal"}
|
||||
}
|
||||
|
||||
-- Generic function for registering all the different node types
|
||||
function technic.cnc.register_program(recipeitem, suffix, nodebox, groups, images, description)
|
||||
function technic.cnc.register_program(recipeitem, suffix, model, groups, images, description, cbox, sbox)
|
||||
|
||||
local dtype
|
||||
local nodeboxdef
|
||||
local meshdef
|
||||
|
||||
if type(model) ~= "string" then -- assume a nodebox if it's a table or function call
|
||||
dtype = "nodebox"
|
||||
nodeboxdef = {
|
||||
type = "fixed",
|
||||
fixed = model
|
||||
}
|
||||
else
|
||||
dtype = "mesh"
|
||||
meshdef = model
|
||||
end
|
||||
|
||||
if cbox and not sbox then sbox = cbox end
|
||||
|
||||
minetest.register_node(":"..recipeitem.."_"..suffix, {
|
||||
description = description,
|
||||
drawtype = "nodebox",
|
||||
drawtype = dtype,
|
||||
node_box = nodeboxdef,
|
||||
mesh = meshdef,
|
||||
tiles = images,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
groups = groups,
|
||||
selection_box = sbox,
|
||||
collision_box = cbox
|
||||
})
|
||||
end
|
||||
|
||||
@ -309,7 +321,8 @@ function technic.cnc.register_all(recipeitem, groups, images, description)
|
||||
end
|
||||
-- Create the node if it passes the test
|
||||
if do_register then
|
||||
technic.cnc.register_program(recipeitem, data.suffix, data.nodebox, groups, images, description.." "..data.desc)
|
||||
technic.cnc.register_program(recipeitem, data.suffix, data.model,
|
||||
groups, images, description.." "..data.desc, data.cbox, data.sbox)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -317,7 +330,7 @@ end
|
||||
|
||||
-- REGISTER NEW TECHNIC_CNC_API's PART 2: technic.cnc..register_element_end(subname, recipeitem, groups, images, desc_element_xyz)
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
function technic.cnc.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_sphere, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
|
||||
function technic.cnc.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_spheroid, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
|
||||
|
||||
technic.cnc.register_slope(recipeitem, groups, images, desc_slope)
|
||||
technic.cnc.register_slope_lying(recipeitem, groups, images, desc_slope_lying)
|
||||
@ -332,7 +345,7 @@ function technic.cnc.register_slope_edge_etc(recipeitem, groups, images, desc_sl
|
||||
technic.cnc.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge)
|
||||
technic.cnc.register_cylinder(recipeitem, groups, images, desc_cylinder)
|
||||
technic.cnc.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal)
|
||||
technic.cnc.register_sphere(recipeitem, groups, images, desc_sphere)
|
||||
technic.cnc.register_spheroid(recipeitem, groups, images, desc_spheroid)
|
||||
technic.cnc.register_element_straight(recipeitem, groups, images, desc_element_straight)
|
||||
technic.cnc.register_element_edge(recipeitem, groups, images, desc_element_edge)
|
||||
technic.cnc.register_element_t(recipeitem, groups, images, desc_element_t)
|
||||
|
@ -9,18 +9,6 @@ technic.cnc.register_all("default:dirt",
|
||||
{snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
|
||||
{"default_grass.png", "default_dirt.png", "default_grass.png"},
|
||||
S("Dirt"))
|
||||
technic.cnc.programs_disable["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown",
|
||||
"technic_cnc_edge", "technic_cnc_inner_edge",
|
||||
"technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
|
||||
"technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
|
||||
|
||||
-- TREE
|
||||
-------
|
||||
technic.cnc.register_all("default:tree",
|
||||
{snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||
{"default_tree.png"},
|
||||
S("Wooden"))
|
||||
|
||||
-- WOOD
|
||||
-------
|
||||
technic.cnc.register_all("default:wood",
|
||||
@ -49,7 +37,7 @@ technic.cnc.register_all("default:brick",
|
||||
-- SANDSTONE
|
||||
------------
|
||||
technic.cnc.register_all("default:sandstone",
|
||||
{crumbly=2, cracky=2, not_in_creative_inventory=1},
|
||||
{crumbly=2, cracky=3, not_in_creative_inventory=1},
|
||||
{"default_sandstone.png"},
|
||||
S("Sandstone"))
|
||||
|
||||
@ -65,10 +53,39 @@ technic.cnc.register_all("default:tree",
|
||||
{snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, wood=1, not_in_creative_inventory=1},
|
||||
{"default_tree.png"},
|
||||
S("Tree"))
|
||||
-- STEEL
|
||||
--------
|
||||
technic.cnc.register_all("default:steel",
|
||||
{snappy=1, bendy=2, cracky=1, melty=2, level=2, not_in_creative_inventory=1},
|
||||
{"default_steel_block.png"},
|
||||
S("Steel"))
|
||||
|
||||
-- WROUGHT IRON
|
||||
---------------
|
||||
technic.cnc.register_all("default:steelblock",
|
||||
{cracky=1, level=2, not_in_creative_inventory=1},
|
||||
{"technic_wrought_iron_block.png"},
|
||||
S("Wrought Iron"))
|
||||
|
||||
-- Bronze
|
||||
--------
|
||||
technic.cnc.register_all("default:bronzeblock",
|
||||
{cracky=1, level=2, not_in_creative_inventory=1},
|
||||
{"default_bronze_block.png"},
|
||||
S("Bronze"))
|
||||
|
||||
-- Stainless Steel
|
||||
--------
|
||||
technic.cnc.register_all("technic:stainless_steel_block",
|
||||
{cracky=1, level=2, not_in_creative_inventory=1},
|
||||
{"technic_stainless_steel_block.png"},
|
||||
S("Stainless Steel"))
|
||||
|
||||
-- Marble
|
||||
------------
|
||||
technic.cnc.register_all("technic:marble",
|
||||
{cracky=3, not_in_creative_inventory=1},
|
||||
{"technic_marble.png"},
|
||||
S("Marble"))
|
||||
|
||||
-- Granite
|
||||
------------
|
||||
technic.cnc.register_all("technic:granite",
|
||||
{cracky=1, not_in_creative_inventory=1},
|
||||
{"technic_granite.png"},
|
||||
S("Granite"))
|
||||
|
||||
|
@ -1,183 +0,0 @@
|
||||
|
||||
-- Coal driven alloy furnace. This uses no EUs:
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:coal_alloy_furnace',
|
||||
recipe = {
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
{'default:brick', '', 'default:brick'},
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("technic:coal_alloy_furnace", {
|
||||
description = S("Coal Alloy Furnace"),
|
||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", coal_alloy_furnace_formspec)
|
||||
meta:set_string("infotext", S("Coal Alloy Furnace"))
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("src2", 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("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:coal_alloy_furnace_active", {
|
||||
description = "Alloy Furnace",
|
||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "technic:coal_alloy_furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not (inv:is_empty("fuel") or inv:is_empty("dst") or
|
||||
inv:is_empty("src") or inv:is_empty("src2")) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:coal_alloy_furnace", "technic:coal_alloy_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local recipe = nil
|
||||
local machine_name = S("Coal Alloy Furnace")
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"label[0,0;"..machine_name.."]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;1,1;]"..
|
||||
"list[current_name;src2;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
for i, name in pairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"}) do
|
||||
if not meta:get_float(name) then
|
||||
meta:set_float(name, 0.0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Get what to cook if anything
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src2stack = inv:get_stack("src2", 1)
|
||||
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
||||
if srcstack:get_name() > src2stack:get_name() then
|
||||
local temp = srcstack
|
||||
srcstack = src2stack
|
||||
src2stack = temp
|
||||
end
|
||||
|
||||
local was_active = false
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
was_active = true
|
||||
meta:set_int("fuel_time", meta:get_int("fuel_time") + 1)
|
||||
if recipe then
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") == 6 then
|
||||
-- check if there's room for output in "dst" list
|
||||
local dst_stack = ItemStack(recipe.output)
|
||||
if inv:room_for_item("dst", dst_stack) then
|
||||
srcstack:take_item(recipe.input[1].count)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
src2stack:take_item(recipe.input[2].count)
|
||||
inv:set_stack("src2", 1, src2stack)
|
||||
inv:add_item("dst", dst_stack)
|
||||
end
|
||||
meta:set_int("src_time", 0)
|
||||
end
|
||||
else
|
||||
meta:set_int("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
local percent = math.floor(meta:get_float("fuel_time") /
|
||||
meta:get_float("fuel_totaltime") * 100)
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
||||
hacky_swap_node(pos, "technic:coal_alloy_furnace_active")
|
||||
meta:set_string("formspec",
|
||||
"size[8,9]"..
|
||||
"label[0,0;"..machine_name.."]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(100 - percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;1,1;]"..
|
||||
"list[current_name;src2;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
return
|
||||
end
|
||||
|
||||
-- FIXME: Make this look more like the electrical version.
|
||||
-- This code refetches the recipe to see if it can be done again after the iteration
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack = inv:get_stack("src2", 1)
|
||||
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
||||
|
||||
if recipe then
|
||||
if was_active then
|
||||
meta:set_string("infotext", "Furnace is empty")
|
||||
hacky_swap_node(pos, "technic:coal_alloy_furnace")
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- Next take a hard look at the fuel situation
|
||||
local fuel = nil
|
||||
local fuellist = inv:get_list("fuel")
|
||||
|
||||
if fuellist then
|
||||
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
end
|
||||
|
||||
if fuel.time <= 0 then
|
||||
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
||||
hacky_swap_node(pos, "technic:coal_alloy_furnace")
|
||||
meta:set_string("formspec", formspec)
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", fuel.time)
|
||||
meta:set_string("fuel_time", 0)
|
||||
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
end,
|
||||
})
|
||||
|
@ -1,170 +1,13 @@
|
||||
|
||||
technic.compressor_recipes = {}
|
||||
minetest.register_alias("compressor", "technic:lv_compressor")
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_compressor_recipe = function(src, src_count, dst, dst_count)
|
||||
technic.compressor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "compressing",
|
||||
output = dst.." "..dst_count,
|
||||
items = {src.." "..src_count},
|
||||
width = 0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
technic.get_compressor_recipe = function(item)
|
||||
if technic.compressor_recipes[item.name] and
|
||||
item.count >= technic.compressor_recipes[item.name].src_count then
|
||||
return technic.compressor_recipes[item.name]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
technic.register_compressor_recipe("default:snowblock", 1, "default:ice", 1)
|
||||
technic.register_compressor_recipe("default:sand", 1, "default:sandstone", 1)
|
||||
technic.register_compressor_recipe("default:desert_sand", 1, "default:desert_stone", 1)
|
||||
technic.register_compressor_recipe("technic:mixed_metal_ingot", 1, "technic:composite_plate", 1)
|
||||
technic.register_compressor_recipe("default:copper_ingot", 5, "technic:copper_plate", 1)
|
||||
technic.register_compressor_recipe("technic:coal_dust", 4, "technic:graphite", 1)
|
||||
technic.register_compressor_recipe("technic:carbon_cloth", 1, "technic:carbon_plate", 1)
|
||||
technic.register_compressor_recipe("technic:enriched_uranium", 4, "technic:uranium_fuel", 1)
|
||||
|
||||
|
||||
minetest.register_alias("compressor", "technic:compressor")
|
||||
minetest.register_craft({
|
||||
output = 'technic:compressor',
|
||||
output = 'technic:lv_compressor',
|
||||
recipe = {
|
||||
{'default:stone', 'default:stone', 'default:stone'},
|
||||
{'mesecons:piston', 'technic:motor', 'mesecons:piston'},
|
||||
{'default:stone', 'technic:lv_cable0', 'default:stone'},
|
||||
{'default:stone', 'technic:motor', 'default:stone'},
|
||||
{'mesecons:piston', 'technic:machine_casing', 'mesecons:piston'},
|
||||
{'technic:fine_silver_wire', 'technic:lv_cable', 'technic:fine_silver_wire'},
|
||||
}
|
||||
})
|
||||
|
||||
local compressor_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;"..S("Compressor").."]"..
|
||||
"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:compressor", {
|
||||
description = S("Compressor"),
|
||||
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png",
|
||||
"technic_compressor_side.png", "technic_compressor_side.png",
|
||||
"technic_compressor_back.png", "technic_compressor_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Compressor"))
|
||||
meta:set_string("formspec", compressor_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:compressor_active", {
|
||||
description = S("Compressor"),
|
||||
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png",
|
||||
"technic_compressor_side.png", "technic_compressor_side.png",
|
||||
"technic_compressor_back.png", "technic_compressor_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:compressor","technic:compressor_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
local machine_name = S("Compressor")
|
||||
local machine_node = "technic:compressor"
|
||||
local demand = 300
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
meta:set_int("LV_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "LV")
|
||||
local inv = meta:get_inventory()
|
||||
local empty = inv:is_empty("src")
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src_item, recipe, result = nil, nil, nil
|
||||
|
||||
if srcstack then
|
||||
src_item = srcstack:to_table()
|
||||
end
|
||||
if src_item then
|
||||
recipe = technic.get_compressor_recipe(src_item)
|
||||
end
|
||||
if recipe then
|
||||
result = {name=recipe.dst_name, count=recipe.dst_count}
|
||||
end
|
||||
if empty or (not result) or
|
||||
(not inv:room_for_item("dst", result)) then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int("LV_EU_demand", 0)
|
||||
meta:set_int("src_time", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < demand then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= demand then
|
||||
hacky_swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") >= 4 then
|
||||
meta:set_int("src_time", 0)
|
||||
srcstack:take_item(recipe.src_count)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
inv:add_item("dst", result)
|
||||
end
|
||||
end
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:compressor", technic.receiver)
|
||||
technic.register_machine("LV", "technic:compressor_active", technic.receiver)
|
||||
|
||||
technic.register_compressor({tier = "LV", demand = {300}, speed = 1})
|
||||
|
@ -6,8 +6,8 @@ minetest.register_craft({
|
||||
output = 'technic:electric_furnace',
|
||||
recipe = {
|
||||
{'default:cobble', 'default:cobble', 'default:cobble'},
|
||||
{'default:cobble', '', 'default:cobble'},
|
||||
{'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'},
|
||||
{'default:cobble', 'technic:machine_casing', 'default:cobble'},
|
||||
{'default:cobble', 'technic:lv_cable', 'default:cobble'},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1,178 +1,13 @@
|
||||
|
||||
technic.extractor_recipes ={}
|
||||
minetest.register_alias("extractor", "technic:lv_extractor")
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_extractor_recipe = function(src, src_count, dst, dst_count)
|
||||
technic.extractor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "extracting",
|
||||
output = dst.." "..dst_count,
|
||||
items = {src.." "..src_count},
|
||||
width = 0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Receive an ItemStack of result by an ItemStack input
|
||||
technic.get_extractor_recipe = function(item)
|
||||
if technic.extractor_recipes[item.name] and
|
||||
item.count >= technic.extractor_recipes[item.name].src_count then
|
||||
return technic.extractor_recipes[item.name]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
technic.register_extractor_recipe("technic:coal_dust", 1, "dye:black", 2)
|
||||
technic.register_extractor_recipe("default:cactus", 1, "dye:green", 2)
|
||||
technic.register_extractor_recipe("default:dry_shrub", 1, "dye:brown", 2)
|
||||
technic.register_extractor_recipe("flowers:geranium", 1, "dye:blue", 2)
|
||||
technic.register_extractor_recipe("flowers:dandelion_white", 1, "dye:white", 2)
|
||||
technic.register_extractor_recipe("flowers:dandelion_yellow", 1, "dye:yellow", 2)
|
||||
technic.register_extractor_recipe("flowers:tulip", 1, "dye:orange", 2)
|
||||
technic.register_extractor_recipe("flowers:rose", 1, "dye:red", 2)
|
||||
technic.register_extractor_recipe("flowers:viola", 1, "dye:violet", 2)
|
||||
technic.register_extractor_recipe("technic:raw_latex", 1, "technic:rubber", 3)
|
||||
technic.register_extractor_recipe("moretrees:rubber_tree_trunk_empty", 1, "technic:rubber", 1)
|
||||
technic.register_extractor_recipe("moretrees:rubber_tree_trunk", 1, "technic:rubber", 1)
|
||||
technic.register_extractor_recipe("technic:uranium", 5, "technic:enriched_uranium", 1)
|
||||
|
||||
minetest.register_alias("extractor", "technic:extractor")
|
||||
minetest.register_craft({
|
||||
output = 'technic:extractor',
|
||||
output = 'technic:lv_extractor',
|
||||
recipe = {
|
||||
{'technic:treetap', 'technic:motor', 'technic:treetap'},
|
||||
{'technic:treetap', 'technic:lv_cable0', 'technic:treetap'},
|
||||
{'', '', ''},
|
||||
{'technic:treetap', 'technic:machine_casing', 'technic:treetap'},
|
||||
{'', 'technic:lv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
local extractor_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;"..S("Extractor").."]"..
|
||||
"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:extractor", {
|
||||
description = S("Extractor"),
|
||||
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
|
||||
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Extractor"))
|
||||
meta:set_string("formspec", extractor_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:extractor_active", {
|
||||
description = S("Extractor"),
|
||||
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png",
|
||||
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png",
|
||||
"technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:extractor", "technic:extractor_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
-- The machine will automatically shut down if disconnected from power in some fashion.
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
|
||||
-- Machine information
|
||||
local machine_name = S("Extractor")
|
||||
local machine_node = "technic:extractor"
|
||||
local demand = 300
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
meta:set_int("LV_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "LV")
|
||||
|
||||
if srcstack then
|
||||
src_item = srcstack:to_table()
|
||||
end
|
||||
if src_item then
|
||||
recipe = technic.get_extractor_recipe(src_item)
|
||||
end
|
||||
if recipe then
|
||||
result = {name=recipe.dst_name, count=recipe.dst_count}
|
||||
end
|
||||
if inv:is_empty("src") or (not recipe) or (not result) or
|
||||
(not inv:room_for_item("dst", result)) then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int("LV_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < demand then
|
||||
-- unpowered - go idle
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= demand then
|
||||
-- Powered
|
||||
hacky_swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") >= 4 then -- 4 ticks per output
|
||||
meta:set_int("src_time", 0)
|
||||
srcstack:take_item(recipe.src_count)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
inv:add_item("dst", result)
|
||||
end
|
||||
end
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:extractor", technic.receiver)
|
||||
technic.register_machine("LV", "technic:extractor_active", technic.receiver)
|
||||
|
||||
technic.register_extractor({tier = "LV", demand = {300}, speed = 1})
|
||||
|
@ -8,9 +8,9 @@ minetest.register_alias("lv_generator", "technic:lv_generator")
|
||||
minetest.register_craft({
|
||||
output = 'technic:lv_generator',
|
||||
recipe = {
|
||||
{'default:stone', 'default:stone', 'default:stone'},
|
||||
{'default:stone', '', 'default:stone'},
|
||||
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
||||
{'default:stone', 'default:furnace', 'default:stone'},
|
||||
{'default:stone', 'technic:machine_casing', 'default:stone'},
|
||||
{'default:stone', 'technic:lv_cable', 'default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -10,47 +10,14 @@ local S = technic.getter
|
||||
minetest.register_craft({
|
||||
output = 'technic:geothermal',
|
||||
recipe = {
|
||||
{'default:stone', 'default:stone', 'default:stone'},
|
||||
{'default:copper_ingot', 'default:diamond', 'default:copper_ingot'},
|
||||
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
||||
{'technic:granite', 'default:diamond', 'technic:granite'},
|
||||
{'technic:fine_copper_wire', 'technic:machine_casing', 'technic:fine_copper_wire'},
|
||||
{'technic:granite', 'technic:lv_cable', 'technic:granite'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:geothermal", {
|
||||
description = S("Geothermal Generator"),
|
||||
})
|
||||
|
||||
local geothermal_formspec =
|
||||
"invsize[8,4;]"..
|
||||
"label[0,0;"..S("Geothermal Generator").."]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
|
||||
minetest.register_node("technic:geothermal", {
|
||||
description = S("Geothermal Generator"),
|
||||
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.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.get_meta(pos)
|
||||
meta:set_string("infotext", S("Geothermal Generator"))
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
meta:set_string("formspec", geothermal_formspec)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:geothermal_active", {
|
||||
description = S("Geothermal Generator"),
|
||||
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:geothermal",
|
||||
description = S("Geothermal %s Generator"):format("LV"),
|
||||
})
|
||||
|
||||
local check_node_around = function(pos)
|
||||
@ -60,11 +27,7 @@ local check_node_around = function(pos)
|
||||
return 0
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:geothermal","technic:geothermal_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local water_nodes = 0
|
||||
local lava_nodes = 0
|
||||
@ -102,20 +65,47 @@ minetest.register_abm({
|
||||
meta:set_int("LV_EU_supply", eu_supply)
|
||||
end
|
||||
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,4;]"..
|
||||
"label[0,0;"..S("Geothermal Generator").."]"..
|
||||
"label[4,0;"..S("Production at %d%%"):format(production_level).."]")
|
||||
meta:set_string("infotext",
|
||||
S("Geothermal %s Generator"):format("LV").." ("..production_level.."%)")
|
||||
|
||||
if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then
|
||||
hacky_swap_node (pos, "technic:geothermal_active")
|
||||
technic.swap_node (pos, "technic:geothermal_active")
|
||||
return
|
||||
end
|
||||
if production_level == 0 then
|
||||
hacky_swap_node(pos, "technic:geothermal")
|
||||
technic.swap_node(pos, "technic:geothermal")
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:geothermal", {
|
||||
description = S("Geothermal %s Generator"):format("LV"),
|
||||
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_lv=1},
|
||||
paramtype2 = "facedir",
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Geothermal %s Generator"):format("LV"))
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
end,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:geothermal_active", {
|
||||
description = S("Geothermal %s Generator"):format("LV"),
|
||||
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_lv=1, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:geothermal",
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:geothermal", technic.producer)
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
minetest.register_alias("grinder", "technic:grinder")
|
||||
minetest.register_alias("grinder", "technic:lv_grinder")
|
||||
minetest.register_craft({
|
||||
output = 'technic:grinder',
|
||||
output = 'technic:lv_grinder',
|
||||
recipe = {
|
||||
{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
|
||||
{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
|
||||
{'default:stone', 'moreores:copper_ingot', 'default:stone'},
|
||||
{'default:desert_stone', 'technic:machine_casing', 'default:desert_stone'},
|
||||
{'technic:granite', 'technic:lv_cable', 'technic:granite'},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -3,20 +3,27 @@ technic.register_tier("LV", "Low Voltage")
|
||||
|
||||
local path = technic.modpath.."/machines/LV"
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/coal_alloy_furnace.lua")
|
||||
|
||||
-- Generators
|
||||
dofile(path.."/solar_panel.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/geothermal.lua")
|
||||
dofile(path.."/water_mill.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/music_player.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
dofile(path.."/music_player.lua")
|
||||
|
||||
dofile(path.."/cnc.lua")
|
||||
dofile(path.."/cnc_api.lua")
|
||||
dofile(path.."/cnc_nodes.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
|
@ -7,100 +7,29 @@ minetest.register_alias("music_player", "technic:music_player")
|
||||
minetest.register_craft({
|
||||
output = 'technic:music_player',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'default:diamond', 'default:diamond', 'default:diamond'},
|
||||
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
||||
{'technic:chromium_ingot', 'default:diamond', 'technic:chromium_ingot'},
|
||||
{'default:diamond', 'technic:machine_casing', 'default:diamond'},
|
||||
{'default:mossycobble', 'technic:lv_cable', 'default:mossycobble'},
|
||||
}
|
||||
})
|
||||
|
||||
local music_player_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;"..S("Music Player").."]"..
|
||||
"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 --]"
|
||||
local music_handles = {}
|
||||
|
||||
minetest.register_node("technic:music_player", {
|
||||
description = S("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(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Music Player"))
|
||||
meta:set_int("active", 0)
|
||||
meta:set_int("current_track", 1)
|
||||
meta:set_string("formspec", music_player_formspec)
|
||||
end,
|
||||
on_receive_fields = function(pos, formanme, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local music_handle = meta:get_int("music_handle")
|
||||
local current_track = meta:get_int("current_track")
|
||||
if fields.track1 then current_track = 1 end
|
||||
if fields.track2 then current_track = 2 end
|
||||
if fields.track3 then current_track = 3 end
|
||||
if fields.track4 then current_track = 4 end
|
||||
if fields.track5 then current_track = 5 end
|
||||
if fields.track6 then current_track = 6 end
|
||||
if fields.track7 then current_track = 7 end
|
||||
if fields.track8 then current_track = 8 end
|
||||
if fields.track9 then current_track = 9 end
|
||||
meta:set_int("current_track", current_track)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;"..S("Music Player").."]"..
|
||||
"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 "
|
||||
..current_track.."]")
|
||||
if fields.play then
|
||||
if music_handle then
|
||||
minetest.sound_stop(music_handle)
|
||||
local function play_track(pos, track)
|
||||
return minetest.sound_play("technic_track"..tostring(track),
|
||||
{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
|
||||
end
|
||||
meta:set_int("active", 1)
|
||||
end
|
||||
if fields.stop then
|
||||
meta:set_int("active", 0)
|
||||
if music_handle then
|
||||
minetest.sound_stop(music_handle)
|
||||
end
|
||||
end
|
||||
meta:set_int("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 run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
local machine_name = S("Music Player")
|
||||
local machine_name = S("%s Music Player"):format("LV")
|
||||
local machine_node = "technic:music_player"
|
||||
local demand = 150
|
||||
|
||||
local music_handle = meta:get_int("music_handle")
|
||||
local current_track = meta:get_int("current_track")
|
||||
local pos_hash = minetest.hash_node_position(pos)
|
||||
local music_handle = music_handles[pos_hash]
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
@ -109,15 +38,9 @@ minetest.register_abm({
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "LV")
|
||||
|
||||
if meta:get_int("active") == 0 then
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int("LV_EU_demand", 0)
|
||||
if music_handle then
|
||||
minetest.sound_stop(music_handle)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@ -125,15 +48,84 @@ minetest.register_abm({
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
if music_handle then
|
||||
minetest.sound_stop(music_handle)
|
||||
music_handle = nil
|
||||
end
|
||||
elseif eu_input >= demand then
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
music_handle = minetest.sound_play("technic_track"..current_track,
|
||||
{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
|
||||
meta:set_int("music_handle", music_handle)
|
||||
if not music_handle then
|
||||
music_handle = play_track(pos, current_track)
|
||||
end
|
||||
end
|
||||
music_handles[pos_hash] = music_handle
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
end
|
||||
|
||||
local function stop_player(pos, node)
|
||||
local pos_hash = minetest.hash_node_position(pos)
|
||||
local music_handle = music_handles[pos_hash]
|
||||
if music_handle then
|
||||
minetest.sound_stop(music_handle)
|
||||
music_handles[pos_hash] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function set_display(meta)
|
||||
meta:set_string("formspec",
|
||||
"size[4,4.5]"..
|
||||
"item_image[0,0;1,1;technic:music_player]"..
|
||||
"label[1,0;"..S("%s Music Player"):format("LV").."]"..
|
||||
"button[0,1;1,1;track1;1]"..
|
||||
"button[1,1;1,1;track2;2]"..
|
||||
"button[2,1;1,1;track3;3]"..
|
||||
"button[0,2;1,1;track4;4]"..
|
||||
"button[1,2;1,1;track5;5]"..
|
||||
"button[2,2;1,1;track6;6]"..
|
||||
"button[0,3;1,1;track7;7]"..
|
||||
"button[1,3;1,1;track8;8]"..
|
||||
"button[2,3;1,1;track9;9]"..
|
||||
"button[3,1;1,1;stop;Stop]"..
|
||||
"label[0,4;"..minetest.formspec_escape(
|
||||
meta:get_int("active") == 0 and
|
||||
S("Stopped") or
|
||||
S("Current track %s"):format(meta:get_int("current_track"))).."]")
|
||||
end
|
||||
|
||||
minetest.register_node("technic:music_player", {
|
||||
description = S("%s Music Player"):format("LV"),
|
||||
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,
|
||||
technic_machine=1, technic_lv=1},
|
||||
connect_sides = {"bottom"},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("%s Music Player"):format("LV"))
|
||||
set_display(meta)
|
||||
end,
|
||||
on_receive_fields = function(pos, formanme, fields, sender)
|
||||
local new_track = nil
|
||||
if fields.stop then new_track = 0 end
|
||||
if fields.track1 then new_track = 1 end
|
||||
if fields.track2 then new_track = 2 end
|
||||
if fields.track3 then new_track = 3 end
|
||||
if fields.track4 then new_track = 4 end
|
||||
if fields.track5 then new_track = 5 end
|
||||
if fields.track6 then new_track = 6 end
|
||||
if fields.track7 then new_track = 7 end
|
||||
if fields.track8 then new_track = 8 end
|
||||
if fields.track9 then new_track = 9 end
|
||||
if new_track then
|
||||
stop_player(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("active", new_track == 0 and 0 or 1)
|
||||
meta:set_int("current_track", new_track)
|
||||
set_display(meta)
|
||||
end
|
||||
end,
|
||||
on_destruct = stop_player,
|
||||
technic_run = run,
|
||||
technic_on_disable = stop_player,
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:music_player", technic.receiver)
|
||||
|
@ -9,8 +9,8 @@ minetest.register_craft({
|
||||
output = 'technic:solar_array_lv 1',
|
||||
recipe = {
|
||||
{'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'},
|
||||
{'default:steel_ingot', 'technic:lv_transformer', 'default:steel_ingot'},
|
||||
{'', 'technic:lv_cable0', ''},
|
||||
{'technic:carbon_steel_ingot', 'technic:lv_transformer', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:lv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -4,51 +4,26 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
minetest.register_node("technic:solar_panel", {
|
||||
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.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 = S("Solar Panel"),
|
||||
active = false,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
meta:set_string("infotext", S("Solar Panel"))
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:solar_panel',
|
||||
recipe = {
|
||||
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
|
||||
{'default:steel_ingot', 'technic:lv_cable0', 'default:steel_ingot'},
|
||||
{'technic:fine_silver_wire', 'technic:lv_cable', 'mesecons_materials:glue'},
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:solar_panel"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local run = function(pos, node)
|
||||
-- The action here is to make the solar panel prodice power
|
||||
-- Power is dependent on the light level and the height above ground
|
||||
-- 130m and above is optimal as it would be above cloud level.
|
||||
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
|
||||
-- There are many ways to cheat by using other light sources like lamps.
|
||||
-- As there is no way to determine if light is sunlight that is just a shame.
|
||||
-- To take care of some of it solar panels do not work outside daylight hours or if
|
||||
-- built below -10m
|
||||
-- built below 0m
|
||||
local pos1 = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
local machine_name = S("Solar Panel")
|
||||
local machine_name = S("Small Solar %s Generator"):format("LV")
|
||||
|
||||
local light = minetest.get_node_light(pos1, nil)
|
||||
local time_of_day = minetest.get_timeofday()
|
||||
@ -60,13 +35,37 @@ minetest.register_abm({
|
||||
local charge_to_give = math.floor((light + pos1.y) * 3)
|
||||
charge_to_give = math.max(charge_to_give, 0)
|
||||
charge_to_give = math.min(charge_to_give, 200)
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..charge_to_give.."EU)")
|
||||
meta:set_string("infotext", S("@1 Active (@2)", machine_name,
|
||||
technic.EU_string(charge_to_give)))
|
||||
meta:set_int("LV_EU_supply", charge_to_give)
|
||||
else
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:solar_panel", {
|
||||
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.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,
|
||||
technic_machine=1, technic_lv=1},
|
||||
connect_sides = {"bottom"},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
description = S("Small Solar %s Generator"):format("LV"),
|
||||
active = false,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
meta:set_string("infotext", S("Small Solar %s Generator"):format("LV"))
|
||||
end,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:solar_panel", technic.producer)
|
||||
|
@ -1,67 +1,37 @@
|
||||
-- A water mill produces LV EUs by exploiting flowing water across it
|
||||
-- It is a LV EU supplyer and fairly low yield (max 120EUs)
|
||||
-- It is a little under half as good as the thermal generator.
|
||||
-- It is a LV EU supplyer and fairly low yield (max 180EUs)
|
||||
-- It is a little over half as good as the thermal generator.
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
minetest.register_alias("water_mill", "technic:water_mill")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:water_mill',
|
||||
recipe = {
|
||||
{'default:stone', 'default:stone', 'default:stone'},
|
||||
{'group:wood', 'default:diamond', 'group:wood'},
|
||||
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
||||
{'technic:marble', 'default:diamond', 'technic:marble'},
|
||||
{'group:wood', 'technic:machine_casing', 'group:wood'},
|
||||
{'technic:marble', 'technic:lv_cable', 'technic:marble'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("technic:water_mill", {
|
||||
description = S("Water Mill"),
|
||||
tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png",
|
||||
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
||||
"technic_water_mill_side.png", "technic_water_mill_side.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.get_meta(pos)
|
||||
meta:set_string("infotext", S("Water Mill"))
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:water_mill_active", {
|
||||
description = S("Water Mill"),
|
||||
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png",
|
||||
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
||||
"technic_water_mill_side.png", "technic_water_mill_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:water_mill",
|
||||
})
|
||||
|
||||
local function check_node_around_mill(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "default:water_flowing" or
|
||||
node.name == "default:water_source" then
|
||||
return true
|
||||
if node.name == "default:water_flowing"
|
||||
or node.name == "default:river_water_flowing" then
|
||||
return node.param2 -- returns approx. water flow, if any
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:water_mill", "technic:water_mill_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local water_nodes = 0
|
||||
local lava_nodes = 0
|
||||
local water_flow = 0
|
||||
local production_level = 0
|
||||
local eu_supply = 0
|
||||
local max_output = 4 * 45 -- keeping it around 180, little more than previous 150 :)
|
||||
|
||||
local positions = {
|
||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||
@ -73,30 +43,65 @@ minetest.register_abm({
|
||||
for _, p in pairs(positions) do
|
||||
local check = check_node_around_mill(p)
|
||||
if check then
|
||||
water_nodes = water_nodes + 1
|
||||
water_flow = water_flow + check
|
||||
end
|
||||
end
|
||||
|
||||
production_level = 25 * water_nodes
|
||||
eu_supply = 30 * water_nodes
|
||||
eu_supply = math.min(4 * water_flow, max_output)
|
||||
production_level = math.floor(100 * eu_supply / max_output)
|
||||
|
||||
if production_level > 0 then
|
||||
meta:set_int("LV_EU_supply", eu_supply)
|
||||
end
|
||||
|
||||
meta:set_string("infotext",
|
||||
S("Water Mill").." ("..production_level.."%)")
|
||||
S("Hydro %s Generator"):format("LV").." ("..production_level.."%)")
|
||||
|
||||
if production_level > 0 and
|
||||
minetest.get_node(pos).name == "technic:water_mill" then
|
||||
hacky_swap_node (pos, "technic:water_mill_active")
|
||||
technic.swap_node (pos, "technic:water_mill_active")
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
return
|
||||
end
|
||||
if production_level == 0 then
|
||||
hacky_swap_node(pos, "technic:water_mill")
|
||||
technic.swap_node(pos, "technic:water_mill")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:water_mill", {
|
||||
description = S("Hydro %s Generator"):format("LV"),
|
||||
tiles = {
|
||||
"technic_water_mill_top.png",
|
||||
"technic_machine_bottom.png"..cable_entry,
|
||||
"technic_water_mill_side.png",
|
||||
"technic_water_mill_side.png",
|
||||
"technic_water_mill_side.png",
|
||||
"technic_water_mill_side.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_lv=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Hydro %s Generator"):format("LV"))
|
||||
meta:set_int("LV_EU_supply", 0)
|
||||
end,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:water_mill_active", {
|
||||
description = S("Hydro %s Generator"):format("LV"),
|
||||
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png",
|
||||
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
||||
"technic_water_mill_side.png", "technic_water_mill_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_lv=1, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:water_mill",
|
||||
technic_run = run,
|
||||
technic_disabled_machine_name = "technic:water_mill",
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:water_mill", technic.producer)
|
||||
|
@ -4,11 +4,11 @@ minetest.register_craft({
|
||||
output = 'technic:mv_alloy_furnace',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
technic.register_alloy_furnace({tier="MV", cook_time=4, upgrade=1, tube=1, demand={3000, 2000, 1000}})
|
||||
technic.register_alloy_furnace({tier = "MV", speed = 1.5, upgrade = 1, tube = 1, demand = {3000, 2000, 1000}})
|
||||
|
||||
|
@ -5,16 +5,18 @@ minetest.register_craft({
|
||||
recipe = {
|
||||
{'technic:lv_battery_box0', 'technic:lv_battery_box0', 'technic:lv_battery_box0'},
|
||||
{'technic:lv_battery_box0', 'technic:mv_transformer', 'technic:lv_battery_box0'},
|
||||
{'', 'technic:mv_cable0', ''},
|
||||
{'', 'technic:mv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_battery_box({
|
||||
tier = "MV",
|
||||
max_charge = 300000,
|
||||
max_charge = 200000,
|
||||
charge_rate = 20000,
|
||||
discharge_rate = 80000,
|
||||
charge_step = 2000,
|
||||
discharge_step = 8000,
|
||||
upgrade = 1,
|
||||
tube = 1,
|
||||
})
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
minetest.register_alias("mv_cable", "technic:mv_cable0")
|
||||
minetest.register_alias("mv_cable", "technic:mv_cable")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_cable0 3',
|
||||
output = 'technic:mv_cable 3',
|
||||
recipe ={
|
||||
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
|
||||
{'technic:lv_cable0', 'technic:lv_cable0', 'technic:lv_cable0'},
|
||||
{'technic:lv_cable', 'technic:lv_cable', 'technic:lv_cable'},
|
||||
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
16
technic/machines/MV/centrifuge.lua
Normal file
16
technic/machines/MV/centrifuge.lua
Normal file
@ -0,0 +1,16 @@
|
||||
minetest.register_craft({
|
||||
output = "technic:mv_centrifuge",
|
||||
recipe = {
|
||||
{"technic:motor", "technic:copper_plate", "technic:diamond_drill_head"},
|
||||
{"technic:copper_plate", "technic:machine_casing", "technic:copper_plate" },
|
||||
{"pipeworks:one_way_tube", "technic:mv_cable", "pipeworks:mese_filter" },
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_centrifuge({
|
||||
tier = "MV",
|
||||
demand = { 8000, 7000, 6000 },
|
||||
speed = 2,
|
||||
upgrade = 1,
|
||||
tube = 1,
|
||||
})
|
12
technic/machines/MV/compressor.lua
Normal file
12
technic/machines/MV/compressor.lua
Normal file
@ -0,0 +1,12 @@
|
||||
-- MV compressor
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_compressor',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_compressor', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_compressor({tier = "MV", demand = {800, 600, 400}, speed = 2, upgrade = 1, tube = 1})
|
@ -9,8 +9,8 @@ minetest.register_craft({
|
||||
output = 'technic:mv_electric_furnace',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_electric_furnace', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
12
technic/machines/MV/extractor.lua
Normal file
12
technic/machines/MV/extractor.lua
Normal file
@ -0,0 +1,12 @@
|
||||
-- MV extractor
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_extractor',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_extractor', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_extractor({tier = "MV", demand = {800, 600, 400}, speed = 2, upgrade = 1, tube = 1})
|
@ -1,14 +1,13 @@
|
||||
|
||||
minetest.register_alias("generator_mv", "technic:generator_mv")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_generator',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_generator', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_generator({tier="MV", supply=600})
|
||||
technic.register_generator({tier="MV", tube=1, supply=600})
|
||||
|
||||
|
@ -4,8 +4,8 @@ minetest.register_craft({
|
||||
output = 'technic:mv_grinder',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_grinder', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
105
technic/machines/MV/hydro_turbine.lua
Normal file
105
technic/machines/MV/hydro_turbine.lua
Normal file
@ -0,0 +1,105 @@
|
||||
-- A Hydro Turbine produces MV EUs by exploiting flowing water across it
|
||||
-- It is a MV EU supplyer and fairly high yield (max 1800EUs)
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
minetest.register_alias("hydro_turbine", "technic:hydro_turbine")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hydro_turbine',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:water_mill', 'technic:stainless_steel_ingot'},
|
||||
{'technic:water_mill', 'technic:mv_transformer', 'technic:water_mill'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
local function get_water_flow(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if minetest.get_item_group(node.name, "water") == 3 then
|
||||
return node.param2 -- returns approx. water flow, if any
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
---
|
||||
-- 10 times better than LV hydro because of 2 extra water mills and 4 stainless steel, a transformer and whatnot ;P.
|
||||
-- Man hydro turbines are tough and long lasting. So, give it some value :)
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local water_flow = 0
|
||||
local production_level = 0
|
||||
local eu_supply = 0
|
||||
local max_output = 40 * 45 -- Generates 1800EU/s
|
||||
|
||||
local positions = {
|
||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||
{x=pos.x, y=pos.y, z=pos.z-1},
|
||||
}
|
||||
|
||||
for _, p in pairs(positions) do
|
||||
water_flow = water_flow + get_water_flow(p)
|
||||
end
|
||||
|
||||
eu_supply = math.min(40 * water_flow, max_output)
|
||||
production_level = math.floor(100 * eu_supply / max_output)
|
||||
|
||||
meta:set_int("MV_EU_supply", eu_supply)
|
||||
|
||||
meta:set_string("infotext",
|
||||
S("Hydro %s Generator"):format("MV").." ("..production_level.."%)")
|
||||
if production_level > 0 and
|
||||
minetest.get_node(pos).name == "technic:hydro_turbine" then
|
||||
technic.swap_node(pos, "technic:hydro_turbine_active")
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
return
|
||||
end
|
||||
if production_level == 0 then
|
||||
technic.swap_node(pos, "technic:hydro_turbine")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:hydro_turbine", {
|
||||
description = S("Hydro %s Generator"):format("MV"),
|
||||
tiles = {
|
||||
"technic_hydro_turbine_top.png",
|
||||
"technic_machine_bottom.png"..cable_entry,
|
||||
"technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_mv=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Hydro %s Generator"):format("MV"))
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
end,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:hydro_turbine_active", {
|
||||
description = S("Hydro %s Generator"):format("MV"),
|
||||
tiles = {"technic_hydro_turbine_top_active.png", "technic_machine_bottom.png",
|
||||
"technic_hydro_turbine_side.png", "technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png", "technic_hydro_turbine_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_mv=1, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:hydro_turbine",
|
||||
technic_run = run,
|
||||
technic_disabled_machine_name = "technic:hydro_turbine",
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:hydro_turbine", technic.producer)
|
||||
technic.register_machine("MV", "technic:hydro_turbine_active", technic.producer)
|
@ -3,20 +3,31 @@ technic.register_tier("MV", "Medium Voltage")
|
||||
|
||||
local path = technic.modpath.."/machines/MV"
|
||||
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
if technic.config:get_bool("enable_wind_mill") then
|
||||
dofile(path.."/wind_mill.lua")
|
||||
end
|
||||
dofile(path.."/generator.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/hydro_turbine.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
dofile(path.."/centrifuge.lua")
|
||||
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
|
||||
-- The power radiator supplies appliances with inductive coupled power:
|
||||
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||
dofile(path.."/power_radiator.lua")
|
||||
dofile(path.."/lighting.lua")
|
||||
-- This is currently useless, slow, and mostly copied
|
||||
--dofile(path.."/power_radiator.lua")
|
||||
--dofile(path.."/lighting.lua")
|
||||
|
||||
|
@ -12,6 +12,16 @@
|
||||
|
||||
local power_radius = 12
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:power_radiator 1',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'},
|
||||
{'technic:copper_coil', 'technic:machine_casing', 'technic:copper_coil'},
|
||||
{'technic:rubber', 'technic:mv_cable', 'technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
||||
------------------------------------------------------------------
|
||||
-- API for inductive powered nodes:
|
||||
-- Use the functions below to set the corresponding callbacks
|
||||
@ -43,7 +53,7 @@ end
|
||||
technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("has_supply") ~= "" then
|
||||
hacky_swap_node(pos, swapnode)
|
||||
technic.swap_node(pos, swapnode)
|
||||
meta:set_int("active", 1)
|
||||
meta:set_int("EU_charge",eu_charge)
|
||||
--print("-----------")
|
||||
@ -56,7 +66,7 @@ end
|
||||
|
||||
technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
|
||||
local meta = minetest.get_meta(pos)
|
||||
hacky_swap_node(pos, swapnode)
|
||||
technic.swap_node(pos, swapnode)
|
||||
meta:set_int("active", 0)
|
||||
meta:set_int("EU_charge",eu_charge)
|
||||
--print("-----------")
|
||||
@ -82,7 +92,7 @@ local shutdown_inductive_appliances = function(pos)
|
||||
local nodename = minetest.get_node(pos1).name
|
||||
-- Swap the node and make sure it is off and unpowered
|
||||
if string.sub(nodename, -7) == "_active" then
|
||||
hacky_swap_node(pos1, string.sub(nodename, 1, -8))
|
||||
technic.swap_node(pos1, string.sub(nodename, 1, -8))
|
||||
meta1:set_int("active", 0)
|
||||
meta1:set_int("EU_charge", 0)
|
||||
end
|
||||
@ -108,7 +118,7 @@ local toggle_on_off_inductive_appliances = function(pos, node, puncher)
|
||||
end
|
||||
|
||||
minetest.register_node("technic:power_radiator", {
|
||||
description = "Power Radiator",
|
||||
description = "MV Power Radiator",
|
||||
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
|
||||
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
||||
@ -124,7 +134,7 @@ minetest.register_node("technic:power_radiator", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("MV_EU_demand",1) -- Demand on the primary side when idle
|
||||
meta:set_int("connected_EU_demand",0) -- Potential demand of connected appliances
|
||||
meta:set_string("infotext", "Power Radiator")
|
||||
meta:set_string("infotext", "MV Power Radiator")
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
shutdown_inductive_appliances(pos)
|
||||
@ -135,21 +145,13 @@ minetest.register_node("technic:power_radiator", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:power_radiator 1',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
|
||||
{'technic:copper_coil', 'technic:mv_transformer', 'technic:copper_coil'},
|
||||
{'technic:rubber', 'technic:mv_cable0', 'technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run power radiator",
|
||||
nodenames = {"technic:power_radiator"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("MV_EU_input")
|
||||
local eu_demand = meta:get_int("MV_EU_demand")
|
||||
|
||||
@ -158,7 +160,7 @@ minetest.register_abm({
|
||||
|
||||
if eu_input == 0 then
|
||||
-- No power
|
||||
meta:set_string("infotext", "Power Radiator is unpowered");
|
||||
meta:set_string("infotext", "MV Power Radiator is unpowered");
|
||||
-- meta:set_int("active", 1) -- used for setting textures someday maybe
|
||||
shutdown_inductive_appliances(pos)
|
||||
meta:set_int("connected_EU_demand", 0)
|
||||
@ -201,7 +203,7 @@ minetest.register_abm({
|
||||
-- The appliance has power from this node. Spend power if it is on.
|
||||
used_charge = used_charge + math.floor(meta1:get_int("EU_charge") / eff_factor)
|
||||
end
|
||||
meta:set_string("infotext", "Power Radiator is powered ("
|
||||
meta:set_string("infotext", "MV Power Radiator is powered ("
|
||||
..math.floor(used_charge / max_charge * 100)
|
||||
.."% of maximum power)");
|
||||
if used_charge == 0 then
|
||||
|
@ -3,10 +3,12 @@ minetest.register_craft({
|
||||
output = 'technic:solar_array_mv 1',
|
||||
recipe = {
|
||||
{'technic:solar_array_lv', 'technic:solar_array_lv', 'technic:solar_array_lv'},
|
||||
{'default:steel_ingot', 'technic:mv_transformer', 'default:steel_ingot'},
|
||||
{'', 'technic:mv_cable0', ''},
|
||||
{'technic:carbon_steel_ingot', 'technic:mv_transformer', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:mv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_solar_array({tier="MV", power=30})
|
||||
|
||||
-- compatibility alias for upgrading from old versions of technic
|
||||
minetest.register_alias("technic:solar_panel_mv", "technic:solar_array_mv")
|
||||
|
@ -5,87 +5,122 @@ minetest.register_alias("tool_workshop", "technic:tool_workshop")
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:tool_workshop',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'group:wood', 'default:diamond', 'group:wood'},
|
||||
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
||||
{'mesecons_pistons:piston_sticky_off', 'technic:machine_casing', 'technic:carbon_cloth'},
|
||||
{'default:obsidian', 'technic:mv_cable', 'default:obsidian'},
|
||||
}
|
||||
})
|
||||
|
||||
local workshop_demand = {5000, 3500, 2000}
|
||||
|
||||
local workshop_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"size[8,9;]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"label[0,0;"..S("Tool Workshop").."]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
|
||||
"list[current_name;upgrade1;1,3;1,1;]"..
|
||||
"list[current_name;upgrade2;2,3;1,1;]"..
|
||||
"label[1,4;"..S("Upgrade Slots").."]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;upgrade1]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;upgrade2]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
minetest.register_node("technic:tool_workshop", {
|
||||
description = S("Tool Workshop"),
|
||||
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
|
||||
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Tool Workshop"))
|
||||
meta:set_string("formspec", workshop_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:tool_workshop"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int("MV_EU_input")
|
||||
local machine_name = S("Tool Workshop")
|
||||
local machine_name = S("%s Tool Workshop"):format("MV")
|
||||
local machine_node = "technic:tool_workshop"
|
||||
local demand = 5000
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int("MV_EU_demand", demand)
|
||||
meta:set_int("MV_EU_demand", workshop_demand[1])
|
||||
meta:set_int("MV_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "MV")
|
||||
local EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
if inv:is_empty("src") or
|
||||
srcstack:get_wear() == 0 or
|
||||
srcstack:get_name() == "technic:water_can" or
|
||||
srcstack:get_name() == "technic:lava_can" then
|
||||
local repairable = false
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
if not srcstack:is_empty() then
|
||||
local itemdef = minetest.registered_items[srcstack:get_name()]
|
||||
if itemdef and
|
||||
(not itemdef.wear_represents or
|
||||
itemdef.wear_represents == "mechanical_wear") and
|
||||
srcstack:get_wear() ~= 0 then
|
||||
repairable = true
|
||||
end
|
||||
end
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade, function (pos, x_velocity, z_velocity)
|
||||
if not repairable then
|
||||
technic.send_items(pos, x_velocity, z_velocity, "src")
|
||||
end
|
||||
end)
|
||||
if not repairable then
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int("MV_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < demand then
|
||||
if eu_input < workshop_demand[EU_upgrade+1] then
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= demand then
|
||||
elseif eu_input >= workshop_demand[EU_upgrade+1] then
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
srcstack:add_wear(-1000)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
end
|
||||
meta:set_int("MV_EU_demand", demand)
|
||||
meta:set_int("MV_EU_demand", workshop_demand[EU_upgrade+1])
|
||||
end
|
||||
|
||||
minetest.register_node("technic:tool_workshop", {
|
||||
description = S("%s Tool Workshop"):format("MV"),
|
||||
paramtype2 = "facedir",
|
||||
tiles = {
|
||||
"technic_workshop_top.png"..tube_entry,
|
||||
"technic_machine_bottom.png"..tube_entry,
|
||||
"technic_workshop_side.png"..tube_entry,
|
||||
"technic_workshop_side.png"..tube_entry,
|
||||
"technic_workshop_side.png"..tube_entry,
|
||||
"technic_workshop_side.png"
|
||||
},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_mv=1, tubedevice=1, tubedevice_receiver=1},
|
||||
connect_sides = {"bottom", "back", "left", "right"},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
|
||||
meta:set_string("formspec", workshop_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
tube = {
|
||||
can_insert = function (pos, node, stack, direction)
|
||||
return minetest.get_meta(pos):get_inventory():room_for_item("src", stack)
|
||||
end,
|
||||
insert_object = function (pos, node, stack, direction)
|
||||
return minetest.get_meta(pos):get_inventory():add_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||
},
|
||||
technic_run = run,
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = technic.machine_after_dig_node
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
||||
|
@ -4,36 +4,74 @@ local S = technic.getter
|
||||
minetest.register_craft({
|
||||
output = 'technic:wind_mill_frame 5',
|
||||
recipe = {
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'', 'default:steel_ingot', ''},
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:carbon_steel_ingot', ''},
|
||||
{'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:wind_mill',
|
||||
recipe = {
|
||||
{'', 'default:steel_ingot', ''},
|
||||
{'default:steel_ingot', 'technic:motor', 'default:steel_ingot'},
|
||||
{'', 'default:steelblock', ''},
|
||||
{'', 'technic:motor', ''},
|
||||
{'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:mv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("technic:wind_mill_frame", {
|
||||
description = S("Wind Mill Frame"),
|
||||
drawtype = "glasslike_framed",
|
||||
tiles = {"default_steel_block.png", "default_glass.png"},
|
||||
tiles = {"technic_carbon_steel_block.png", "default_glass.png"},
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
local function check_wind_mill(pos)
|
||||
if pos.y < 30 then
|
||||
return false
|
||||
end
|
||||
pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
for i = 1, 20 do
|
||||
pos.y = pos.y - 1
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node then
|
||||
-- we reached CONTENT_IGNORE, we can assume, that nothing changed
|
||||
-- as the user will have to load the block to change it
|
||||
return
|
||||
end
|
||||
if node.name ~= "technic:wind_mill_frame" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local machine_name = S("Wind %s Generator"):format("MV")
|
||||
|
||||
local check = check_wind_mill(pos)
|
||||
if check == false then
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
|
||||
elseif check == true then
|
||||
local power = math.min(pos.y * 100, 5000)
|
||||
meta:set_int("MV_EU_supply", power)
|
||||
meta:set_string("infotext", S("@1 (@2)", machine_name,
|
||||
technic.EU_string(power)))
|
||||
end
|
||||
-- check == nil: assume nothing has changed
|
||||
end
|
||||
|
||||
minetest.register_node("technic:wind_mill", {
|
||||
description = S("Wind Mill"),
|
||||
tiles = {"default_steel_block.png"},
|
||||
description = S("Wind %s Generator"):format("MV"),
|
||||
tiles = {"technic_carbon_steel_block.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=1},
|
||||
groups = {cracky=1, technic_machine=1, technic_mv=1},
|
||||
connect_sides = {"top", "bottom", "back", "left", "right"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
@ -48,43 +86,10 @@ minetest.register_node("technic:wind_mill", {
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Wind Mill"))
|
||||
meta:set_string("infotext", S("Wind %s Generator"):format("MV"))
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
end,
|
||||
})
|
||||
|
||||
local function check_wind_mill(pos)
|
||||
if pos.y < 30 then
|
||||
return false
|
||||
end
|
||||
for i = 1, 20 do
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
|
||||
if node.name ~= "technic:wind_mill_frame" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:wind_mill"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local machine_name = S("Wind Mill")
|
||||
local power = math.min(pos.y * 100, 5000)
|
||||
|
||||
if not check_wind_mill(pos) then
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
|
||||
return
|
||||
else
|
||||
meta:set_int("MV_EU_supply", power)
|
||||
end
|
||||
|
||||
meta:set_string("infotext", machine_name.." ("..power.."EU)")
|
||||
end
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:wind_mill", technic.producer)
|
||||
|
@ -8,6 +8,7 @@ dofile(path.."/MV/init.lua")
|
||||
dofile(path.."/HV/init.lua")
|
||||
|
||||
dofile(path.."/switching_station.lua")
|
||||
dofile(path.."/power_monitor.lua")
|
||||
dofile(path.."/supply_converter.lua")
|
||||
|
||||
dofile(path.."/other/init.lua")
|
||||
|
109
technic/machines/other/anchor.lua
Normal file
109
technic/machines/other/anchor.lua
Normal file
@ -0,0 +1,109 @@
|
||||
local S = technic.getter
|
||||
|
||||
local desc = S("Administrative World Anchor")
|
||||
|
||||
local function compute_forceload_positions(pos, meta)
|
||||
local radius = meta:get_int("radius")
|
||||
local minpos = vector.subtract(pos, vector.new(radius, radius, radius))
|
||||
local maxpos = vector.add(pos, vector.new(radius, radius, radius))
|
||||
local minbpos = {}
|
||||
local maxbpos = {}
|
||||
for _, coord in ipairs({"x","y","z"}) do
|
||||
minbpos[coord] = math.floor(minpos[coord] / 16) * 16
|
||||
maxbpos[coord] = math.floor(maxpos[coord] / 16) * 16
|
||||
end
|
||||
local flposes = {}
|
||||
for x = minbpos.x, maxbpos.x, 16 do
|
||||
for y = minbpos.y, maxbpos.y, 16 do
|
||||
for z = minbpos.z, maxbpos.z, 16 do
|
||||
table.insert(flposes, vector.new(x, y, z))
|
||||
end
|
||||
end
|
||||
end
|
||||
return flposes
|
||||
end
|
||||
|
||||
local function currently_forceloaded_positions(meta)
|
||||
local ser = meta:get_string("forceloaded")
|
||||
return ser == "" and {} or minetest.deserialize(ser)
|
||||
end
|
||||
|
||||
local function forceload_off(meta)
|
||||
local flposes = currently_forceloaded_positions(meta)
|
||||
meta:set_string("forceloaded", "")
|
||||
for _, p in ipairs(flposes) do
|
||||
minetest.forceload_free_block(p)
|
||||
end
|
||||
end
|
||||
|
||||
local function forceload_on(pos, meta)
|
||||
local want_flposes = compute_forceload_positions(pos, meta)
|
||||
local have_flposes = {}
|
||||
for _, p in ipairs(want_flposes) do
|
||||
if minetest.forceload_block(p) then
|
||||
table.insert(have_flposes, p)
|
||||
end
|
||||
end
|
||||
meta:set_string("forceloaded", #have_flposes == 0 and "" or minetest.serialize(have_flposes))
|
||||
end
|
||||
|
||||
local function set_display(pos, meta)
|
||||
meta:set_string("infotext", S(meta:get_int("enabled") ~= 0 and "%s Enabled" or "%s Disabled"):format(desc))
|
||||
meta:set_string("formspec",
|
||||
"size[5,3.5]"..
|
||||
"item_image[0,0;1,1;technic:admin_anchor]"..
|
||||
"label[1,0;"..minetest.formspec_escape(desc).."]"..
|
||||
"label[0,1;"..minetest.formspec_escape(S("Owner:").." "..meta:get_string("owner")).."]"..
|
||||
(meta:get_int("locked") == 0 and
|
||||
"button[3,1;2,1;lock;"..minetest.formspec_escape(S("Unlocked")).."]" or
|
||||
"button[3,1;2,1;unlock;"..minetest.formspec_escape(S("Locked")).."]")..
|
||||
"field[0.25,2.3;1,1;radius;"..minetest.formspec_escape(S("Radius:"))..";"..meta:get_int("radius").."]"..
|
||||
(meta:get_int("enabled") == 0 and
|
||||
"button[3,2;2,1;enable;"..minetest.formspec_escape(S("Disabled")).."]" or
|
||||
"button[3,2;2,1;disable;"..minetest.formspec_escape(S("Enabled")).."]")..
|
||||
"label[0,3;"..minetest.formspec_escape(S("Keeping %d/%d map blocks loaded"):format(#currently_forceloaded_positions(meta), #compute_forceload_positions(pos, meta))).."]")
|
||||
end
|
||||
|
||||
minetest.register_node("technic:admin_anchor", {
|
||||
description = desc,
|
||||
drawtype = "normal",
|
||||
tiles = {"technic_admin_anchor.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
after_place_node = function (pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if placer and placer:is_player() then
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
end
|
||||
set_display(pos, meta)
|
||||
end,
|
||||
can_dig = function (pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return meta:get_int("locked") == 0 or (player and player:is_player() and player:get_player_name() == meta:get_string("owner"))
|
||||
end,
|
||||
on_destruct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
forceload_off(meta)
|
||||
end,
|
||||
on_receive_fields = function (pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if (meta:get_int("locked") ~= 0 or fields.lock) and
|
||||
not (sender and sender:is_player() and
|
||||
sender:get_player_name() == meta:get_string("owner")) then
|
||||
return
|
||||
end
|
||||
if fields.unlock then meta:set_int("locked", 0) end
|
||||
if fields.lock then meta:set_int("locked", 1) end
|
||||
if fields.disable or fields.enable or fields.radius then
|
||||
forceload_off(meta)
|
||||
if fields.disable then meta:set_int("enabled", 0) end
|
||||
if fields.enable then meta:set_int("enabled", 1) end
|
||||
if fields.radius and string.find(fields.radius, "^[0-9]+$") and tonumber(fields.radius) < 256 then meta:set_int("radius", fields.radius) end
|
||||
if meta:get_int("enabled") ~= 0 then
|
||||
forceload_on(pos, meta)
|
||||
end
|
||||
end
|
||||
set_display(pos, meta)
|
||||
end,
|
||||
})
|
178
technic/machines/other/coal_alloy_furnace.lua
Normal file
178
technic/machines/other/coal_alloy_furnace.lua
Normal file
@ -0,0 +1,178 @@
|
||||
|
||||
-- Fuel driven alloy furnace. This uses no EUs:
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:coal_alloy_furnace',
|
||||
recipe = {
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
{'default:brick', '', 'default:brick'},
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
}
|
||||
})
|
||||
|
||||
local machine_name = S("Fuel-Fired Alloy Furnace")
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"label[0,0;"..machine_name.."]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;2,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[current_name;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;fuel]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
minetest.register_node("technic:coal_alloy_furnace", {
|
||||
description = machine_name,
|
||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", machine_name)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 2)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:coal_alloy_furnace_active", {
|
||||
description = machine_name,
|
||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "technic:coal_alloy_furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run coal alloy furnace",
|
||||
nodenames = {"technic:coal_alloy_furnace", "technic:coal_alloy_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if inv:get_size("src") == 1 then -- Old furnace -> convert it
|
||||
inv:set_size("src", 2)
|
||||
inv:set_stack("src", 2, inv:get_stack("src2", 1))
|
||||
inv:set_size("src2", 0)
|
||||
end
|
||||
|
||||
local recipe = nil
|
||||
|
||||
for i, name in pairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"}) do
|
||||
if not meta:get_float(name) then
|
||||
meta:set_float(name, 0.0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Get what to cook if anything
|
||||
local result = technic.get_recipe("alloy", inv:get_list("src"))
|
||||
|
||||
local was_active = false
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
was_active = true
|
||||
meta:set_int("fuel_time", meta:get_int("fuel_time") + 1)
|
||||
if result then
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") >= result.time then
|
||||
meta:set_int("src_time", 0)
|
||||
local result_stack = ItemStack(result.output)
|
||||
if inv:room_for_item("dst", result_stack) then
|
||||
inv:set_list("src", result.new_input)
|
||||
inv:add_item("dst", result_stack)
|
||||
end
|
||||
end
|
||||
else
|
||||
meta:set_int("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
local percent = math.floor(meta:get_float("fuel_time") /
|
||||
meta:get_float("fuel_totaltime") * 100)
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
||||
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
||||
meta:set_string("formspec",
|
||||
"size[8,9]"..
|
||||
"label[0,0;"..machine_name.."]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(100 - percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;2,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[current_name;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;fuel]"..
|
||||
"listring[current_player;main]")
|
||||
return
|
||||
end
|
||||
|
||||
local recipe = technic.get_recipe("alloy", inv:get_list("src"))
|
||||
|
||||
if not recipe then
|
||||
if was_active then
|
||||
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- Next take a hard look at the fuel situation
|
||||
local fuel = nil
|
||||
local afterfuel
|
||||
local fuellist = inv:get_list("fuel")
|
||||
|
||||
if fuellist then
|
||||
fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
end
|
||||
|
||||
if fuel.time <= 0 then
|
||||
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||
meta:set_string("formspec", formspec)
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", fuel.time)
|
||||
meta:set_string("fuel_time", 0)
|
||||
|
||||
inv:set_stack("fuel", 1, afterfuel.items[1])
|
||||
end,
|
||||
})
|
||||
|
5
technic/machines/other/coal_furnace.lua
Normal file
5
technic/machines/other/coal_furnace.lua
Normal file
@ -0,0 +1,5 @@
|
||||
local S = technic.getter
|
||||
|
||||
if minetest.registered_nodes["default:furnace"].description == "Furnace" then
|
||||
minetest.override_item("default:furnace", { description = S("Fuel-Fired Furnace") })
|
||||
end
|
@ -1,4 +1,70 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local function deploy_node(inv, slot_name, pos, node, machine_node)
|
||||
if node.param2 > 3 then return end
|
||||
if node.name ~= "air" then
|
||||
if node.name == "ignore" or
|
||||
node.name == "default:lava_source" or
|
||||
node.name == "default:lava_flowing" or
|
||||
node.name == "default:water_source" or
|
||||
node.name == "default:water_flowing" then
|
||||
return
|
||||
end
|
||||
local drops = minetest.get_node_drops(node.name, "")
|
||||
local remove_to = false
|
||||
for i, item in ipairs(drops) do
|
||||
if not inv:room_for_item(slot_name, item) then
|
||||
remove_to = i - 1
|
||||
break
|
||||
end
|
||||
inv:add_item(slot_name, item)
|
||||
end
|
||||
if remove_to then
|
||||
for i = 1, remove_to do
|
||||
inv:remove_item(slot_name, drops[i])
|
||||
end
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not inv:is_empty(slot_name) then
|
||||
local stack = inv:get_list(slot_name)[1]
|
||||
local def = stack:get_definition()
|
||||
if def.type == "node" then
|
||||
minetest.set_node(pos, {
|
||||
name = stack:get_name(),
|
||||
param2 = machine_node.param2
|
||||
})
|
||||
stack:take_item()
|
||||
inv:set_stack(slot_name, 1, stack)
|
||||
elseif def.type == "craft" then
|
||||
if def.on_place then
|
||||
-- Use pcall to avoid nil placer errors.
|
||||
-- TODO: Do without pcall.
|
||||
local ok, stk = pcall(def.on_place, stack, nil, {
|
||||
-- Fake pointed_thing
|
||||
type = "node",
|
||||
above = pos,
|
||||
under = {x=pos.x, y=pos.y-1, z=pos.z},
|
||||
})
|
||||
if ok then
|
||||
inv:set_stack(slot_name, 1, stk or stack)
|
||||
return
|
||||
end
|
||||
end
|
||||
minetest.item_place_object(stack, nil, {
|
||||
-- Fake pointed_thing
|
||||
type = "node",
|
||||
above = pos,
|
||||
under = pos,
|
||||
})
|
||||
inv:set_stack(slot_name, 1, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = 'technic:constructor_mk1_off 1',
|
||||
@ -19,326 +85,108 @@ minetest.register_craft({
|
||||
|
||||
})
|
||||
|
||||
mk1_on = function(pos, node)
|
||||
local function make_on(mark, length)
|
||||
return function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local pos1={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
if node.param2==3 then pos1.x=pos1.x+1 end
|
||||
if node.param2==2 then pos1.z=pos1.z+1 end
|
||||
if node.param2==1 then pos1.x=pos1.x-1 end
|
||||
if node.param2==0 then pos1.z=pos1.z-1 end
|
||||
local dir = vector.new()
|
||||
if node.param2 == 3 then dir.x = 1 end
|
||||
if node.param2 == 2 then dir.z = 1 end
|
||||
if node.param2 == 1 then dir.x = -1 end
|
||||
if node.param2 == 0 then dir.z = -1 end
|
||||
|
||||
if node.name == "technic:constructor_mk1_off" then
|
||||
hacky_swap_node(pos,"technic:constructor_mk1_on")
|
||||
nodeupdate(pos)
|
||||
local node1=minetest.get_node(pos1)
|
||||
deploy_node (inv,"slot1",pos1,node1,node)
|
||||
local place_pos = vector.new(pos)
|
||||
|
||||
if node.name == "technic:constructor_mk"..mark.."_off" then
|
||||
technic.swap_node(pos, "technic:constructor_mk"..mark.."_on")
|
||||
minetest.check_for_falling(pos)
|
||||
for i = 1, length do
|
||||
place_pos = vector.add(place_pos, dir)
|
||||
local place_node = minetest.get_node(place_pos)
|
||||
deploy_node(inv, "slot"..i, place_pos, place_node, node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mk1_off = function(pos, node)
|
||||
if node.name == "technic:constructor_mk1_on" then
|
||||
hacky_swap_node(pos,"technic:constructor_mk1_off")
|
||||
nodeupdate(pos)
|
||||
local function make_off(mark)
|
||||
return function(pos, node)
|
||||
if node.name == "technic:constructor_mk"..mark.."_on" then
|
||||
technic.swap_node(pos,"technic:constructor_mk"..mark.."_off")
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("technic:constructor_mk1_off", {
|
||||
description = "Constructor MK1",
|
||||
tile_images = {"technic_constructor_mk1_top_off.png","technic_constructor_mk1_bottom_off.png","technic_constructor_mk1_side2_off.png","technic_constructor_mk1_side1_off.png",
|
||||
"technic_constructor_back.png","technic_constructor_front_off.png"},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
|
||||
mesecons= {effector={action_on=mk1_on}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Constructor MK1]"..
|
||||
"label[5,0;Slot 1]"..
|
||||
"list[current_name;slot1;6,0;1,1;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Constructor MK1")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("slot1", 1)
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("slot1")
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:constructor_mk1_on", {
|
||||
description = "Constructor MK1",
|
||||
tile_images = {"technic_constructor_mk1_top_on.png","technic_constructor_mk1_bottom_on.png","technic_constructor_mk1_side2_on.png","technic_constructor_mk1_side1_on.png",
|
||||
"technic_constructor_back.png","technic_constructor_front_on.png"},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1},
|
||||
mesecons= {effector={action_off=mk1_off}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
|
||||
--Constructor MK2
|
||||
|
||||
mk2_on = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local pos1={}
|
||||
local pos2={}
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
pos2.x=pos.x
|
||||
pos2.y=pos.y
|
||||
pos2.z=pos.z
|
||||
if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 end
|
||||
if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 end
|
||||
if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 end
|
||||
if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end
|
||||
|
||||
if node.name == "technic:constructor_mk2_off" then
|
||||
hacky_swap_node(pos,"technic:constructor_mk2_on")
|
||||
nodeupdate(pos)
|
||||
local node1=minetest.get_node(pos1)
|
||||
deploy_node (inv,"slot1",pos1,node1,node)
|
||||
local node1=minetest.get_node(pos2)
|
||||
deploy_node (inv,"slot2",pos2,node1,node)
|
||||
end
|
||||
end
|
||||
|
||||
mk2_off = function(pos, node)
|
||||
if node.name == "technic:constructor_mk2_on" then
|
||||
hacky_swap_node(pos,"technic:constructor_mk2_off")
|
||||
nodeupdate(pos)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:constructor_mk2_off", {
|
||||
description = "Constructor MK2",
|
||||
tile_images = {"technic_constructor_mk2_top_off.png","technic_constructor_mk2_bottom_off.png","technic_constructor_mk2_side2_off.png","technic_constructor_mk2_side1_off.png",
|
||||
"technic_constructor_back.png","technic_constructor_front_off.png"},
|
||||
is_ground_content = true,
|
||||
local function make_constructor(mark, length)
|
||||
minetest.register_node("technic:constructor_mk"..mark.."_off", {
|
||||
description = S("Constructor Mk%d"):format(mark),
|
||||
tiles = {"technic_constructor_mk"..mark.."_top_off.png",
|
||||
"technic_constructor_mk"..mark.."_bottom_off.png",
|
||||
"technic_constructor_mk"..mark.."_side2_off.png",
|
||||
"technic_constructor_mk"..mark.."_side1_off.png",
|
||||
"technic_constructor_back.png",
|
||||
"technic_constructor_front_off.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon = 2},
|
||||
mesecons= {effector={action_on=mk2_on}},
|
||||
mesecons = {effector = {action_on = make_on(mark, length)}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Constructor MK2]"..
|
||||
"label[5,0;Slot 1]"..
|
||||
"list[current_name;slot1;6,0;1,1;]"..
|
||||
"label[5,1;Slot 2]"..
|
||||
"list[current_name;slot2;6,1;1,1;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Constructor MK2")
|
||||
local formspec = "size[8,9;]"..
|
||||
"label[0,0;"..S("Constructor Mk%d"):format(mark).."]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
for i = 1, length do
|
||||
formspec = formspec
|
||||
.."label[5,"..(i - 1)..";"..S("Slot %d"):format(i).."]"
|
||||
.."list[current_name;slot"..i
|
||||
..";6,"..(i - 1)..";1,1;]"
|
||||
end
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", S("Constructor Mk%d"):format(mark))
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("slot1", 1)
|
||||
inv:set_size("slot2", 1)
|
||||
for i = 1, length do
|
||||
inv:set_size("slot"..i, 1)
|
||||
end
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
|
||||
for i = 1, length do
|
||||
if not inv:is_empty("slot"..i) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
on_rotate = screwdriver.rotate_simple
|
||||
})
|
||||
|
||||
minetest.register_node("technic:constructor_mk2_on", {
|
||||
description = "Constructor MK2",
|
||||
tile_images = {"technic_constructor_mk2_top_on.png","technic_constructor_mk2_bottom_on.png","technic_constructor_mk2_side2_on.png","technic_constructor_mk2_side1_on.png",
|
||||
"technic_constructor_back.png","technic_constructor_front_on.png"},
|
||||
is_ground_content = true,
|
||||
minetest.register_node("technic:constructor_mk"..mark.."_on", {
|
||||
tiles = {"technic_constructor_mk"..mark.."_top_on.png",
|
||||
"technic_constructor_mk"..mark.."_bottom_on.png",
|
||||
"technic_constructor_mk"..mark.."_side2_on.png",
|
||||
"technic_constructor_mk"..mark.."_side1_on.png",
|
||||
"technic_constructor_back.png",
|
||||
"technic_constructor_front_on.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2, not_in_creative_inventory=1},
|
||||
mesecons= {effector={action_off=mk2_off}},
|
||||
drop = "technic:constructor_mk"..mark.."_off",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
mesecon=2, not_in_creative_inventory=1},
|
||||
mesecons= {effector = {action_off = make_off(mark)}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
on_rotate = false
|
||||
})
|
||||
|
||||
|
||||
-- Constructor MK3
|
||||
mk3_on = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local pos1={}
|
||||
local pos2={}
|
||||
local pos3={}
|
||||
local pos4={}
|
||||
|
||||
pos1.x=pos.x
|
||||
pos1.y=pos.y
|
||||
pos1.z=pos.z
|
||||
|
||||
pos2.x=pos.x
|
||||
pos2.y=pos.y
|
||||
pos2.z=pos.z
|
||||
|
||||
pos3.x=pos.x
|
||||
pos3.y=pos.y
|
||||
pos3.z=pos.z
|
||||
|
||||
pos4.x=pos.x
|
||||
pos4.y=pos.y
|
||||
pos4.z=pos.z
|
||||
|
||||
if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 pos3.x=pos3.x+3 pos4.x=pos4.x+4 end
|
||||
if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 pos3.z=pos3.z+3 pos4.z=pos4.z+4 end
|
||||
if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 pos3.x=pos3.x-3 pos4.x=pos4.x-4 end
|
||||
if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end
|
||||
|
||||
if node.name == "technic:constructor_mk3_off" then
|
||||
hacky_swap_node(pos,"technic:constructor_mk3_on")
|
||||
nodeupdate(pos)
|
||||
local node1=minetest.get_node(pos1)
|
||||
deploy_node (inv,"slot1",pos1,node1,node)
|
||||
local node1=minetest.get_node(pos2)
|
||||
deploy_node (inv,"slot2",pos2,node1,node)
|
||||
local node1=minetest.get_node(pos3)
|
||||
deploy_node (inv,"slot3",pos3,node1,node)
|
||||
local node1=minetest.get_node(pos4)
|
||||
deploy_node (inv,"slot4",pos4,node1,node)
|
||||
end
|
||||
end
|
||||
|
||||
mk3_off = function(pos, node)
|
||||
if node.name == "technic:constructor_mk3_on" then
|
||||
hacky_swap_node(pos,"technic:constructor_mk3_off")
|
||||
nodeupdate(pos)
|
||||
end
|
||||
end
|
||||
make_constructor(1, 1)
|
||||
make_constructor(2, 2)
|
||||
make_constructor(3, 4)
|
||||
|
||||
minetest.register_node("technic:constructor_mk3_off", {
|
||||
description = "Constructor MK3",
|
||||
tile_images = {"technic_constructor_mk3_top_off.png","technic_constructor_mk3_bottom_off.png","technic_constructor_mk3_side2_off.png","technic_constructor_mk3_side1_off.png",
|
||||
"technic_constructor_back.png","technic_constructor_front_off.png"},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
|
||||
mesecons= {effector={action_on=mk3_on}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Constructor MK2]"..
|
||||
"label[5,0;Slot 1]"..
|
||||
"list[current_name;slot1;6,0;1,1;]"..
|
||||
"label[5,1;Slot 2]"..
|
||||
"list[current_name;slot2;6,1;1,1;]"..
|
||||
"label[5,2;Slot 3]"..
|
||||
"list[current_name;slot3;6,2;1,1;]"..
|
||||
"label[5,3;Slot 4]"..
|
||||
"list[current_name;slot4;6,3;1,1;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Constructor MK3")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("slot1", 1)
|
||||
inv:set_size("slot2", 1)
|
||||
inv:set_size("slot3", 1)
|
||||
inv:set_size("slot4", 1)
|
||||
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:constructor_mk3_on", {
|
||||
description = "Constructor MK3",
|
||||
tile_images = {"technic_constructor_mk3_top_on.png","technic_constructor_mk3_bottom_on.png","technic_constructor_mk3_side2_on.png","technic_constructor_mk3_side1_on.png",
|
||||
"technic_constructor_back.png","technic_constructor_front_on.png"},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,not_in_creative_inventory=1},
|
||||
mesecons= {effector={action_off=mk3_off}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
|
||||
deploy_node =function (inv, slot_name, pos1, node1, node)
|
||||
if node1.name == "air" then
|
||||
if not inv:is_empty(slot_name) then
|
||||
stack1=inv:get_list(slot_name)
|
||||
local def = stack1[1]:get_definition()
|
||||
if def.type == "node" then
|
||||
node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
|
||||
minetest.set_node(pos1,node_to_be_placed)
|
||||
stack1[1]:take_item()
|
||||
inv:set_stack(slot_name, 1, stack1[1])
|
||||
elseif def.type == "craft" then
|
||||
if def.on_place then
|
||||
-- print("deploy_node: item has on_place. trying...")
|
||||
local ok, stk = pcall(def.on_place, stack1[1], nil, {
|
||||
-- Fake pointed_thing
|
||||
type = "node",
|
||||
above = pos1,
|
||||
under = { x=pos1.x, y=pos1.y-1, z=pos1.z },
|
||||
})
|
||||
if ok then
|
||||
-- print("deploy_node: on_place succeeded!")
|
||||
inv:set_stack(slot_name, 1, stk or stack1[1])
|
||||
return
|
||||
-- else
|
||||
-- print("deploy_node: WARNING: error while running on_place: "..tostring(stk))
|
||||
end
|
||||
end
|
||||
minetest.item_place_object(stack1[1], nil, {
|
||||
-- Fake pointed_thing
|
||||
type = "node",
|
||||
above = pos1,
|
||||
under = pos1,
|
||||
})
|
||||
inv:set_stack(slot_name, 1, nil)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
if node1.name == "ignore" or
|
||||
node1.name == "default:lava_source" or
|
||||
node1.name == "default:lava_flowing" or
|
||||
node1.name == "default:water_source" or
|
||||
node1.name == "default:water_flowing"
|
||||
then return end
|
||||
if inv:room_for_item(slot_name,node1) then
|
||||
local def = minetest.registered_nodes[node1.name]
|
||||
if not def then return end
|
||||
local drop = def.drop or node1.name
|
||||
if type(drop) == "table" then
|
||||
local pr = PseudoRandom(math.random())
|
||||
local c = 0
|
||||
local loop = 0 -- Prevent infinite loop
|
||||
while (c < (drop.max_items or 1)) and (loop < 1000) do
|
||||
local i = math.floor(pr:next(1, #drop.items))
|
||||
if pr:next(1, drop.items[i].rarity or 1) == 1 then
|
||||
for _,item in ipairs(drop.items[i].items) do
|
||||
inv:add_item(slot_name,item)
|
||||
end
|
||||
c = c + 1
|
||||
end
|
||||
loop = loop + 1
|
||||
end
|
||||
minetest.remove_node(pos1)
|
||||
elseif type(drop) == "string" then
|
||||
inv:add_item(slot_name,drop)
|
||||
minetest.remove_node(pos1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,6 +1,9 @@
|
||||
local S = technic.getter
|
||||
|
||||
frames = {}
|
||||
|
||||
local infinite_stacks = minetest.setting_getbool("creative_mode") and minetest.get_modpath("unified_inventory") == nil
|
||||
local infinite_stacks = minetest.settings:get_bool("creative_mode")
|
||||
and minetest.get_modpath("unified_inventory") == nil
|
||||
|
||||
local frames_pos = {}
|
||||
|
||||
@ -9,45 +12,60 @@ local frames_pos = {}
|
||||
local function get_face(pos, ppos, pvect)
|
||||
-- Raytracer to get which face has been clicked
|
||||
ppos = { x = ppos.x - pos.x, y = ppos.y - pos.y + 1.5, z = ppos.z - pos.z }
|
||||
|
||||
if pvect.x > 0 then
|
||||
local t = (-0.5 - ppos.x) / pvect.x
|
||||
local y_int = ppos.y + t * pvect.y
|
||||
local z_int = ppos.z + t * pvect.z
|
||||
if y_int>-0.45 and y_int<0.45 and z_int>-0.45 and z_int<0.45 then return 1 end
|
||||
if y_int > -0.45 and y_int < 0.45 and z_int > -0.45 and z_int < 0.45 then
|
||||
return 1
|
||||
end
|
||||
elseif pvect.x < 0 then
|
||||
local t = (0.5 - ppos.x) / pvect.x
|
||||
local y_int = ppos.y + t * pvect.y
|
||||
local z_int = ppos.z + t * pvect.z
|
||||
if y_int>-0.45 and y_int<0.45 and z_int>-0.45 and z_int<0.45 then return 2 end
|
||||
if y_int > -0.45 and y_int < 0.45 and z_int > -0.45 and z_int < 0.45 then
|
||||
return 2
|
||||
end
|
||||
end
|
||||
|
||||
if pvect.y > 0 then
|
||||
local t = (-0.5 - ppos.y) / pvect.y
|
||||
local x_int = ppos.x + t * pvect.x
|
||||
local z_int = ppos.z + t * pvect.z
|
||||
if x_int>-0.45 and x_int<0.45 and z_int>-0.45 and z_int<0.45 then return 3 end
|
||||
if x_int > -0.45 and x_int < 0.45 and z_int > -0.45 and z_int < 0.45 then
|
||||
return 3
|
||||
end
|
||||
elseif pvect.y < 0 then
|
||||
local t = (0.5 - ppos.y) / pvect.y
|
||||
local x_int = ppos.x + t * pvect.x
|
||||
local z_int = ppos.z + t * pvect.z
|
||||
if x_int>-0.45 and x_int<0.45 and z_int>-0.45 and z_int<0.45 then return 4 end
|
||||
if x_int > -0.45 and x_int < 0.45 and z_int > -0.45 and z_int < 0.45 then
|
||||
return 4
|
||||
end
|
||||
end
|
||||
|
||||
if pvect.z > 0 then
|
||||
local t = (-0.5 - ppos.z) / pvect.z
|
||||
local x_int = ppos.x + t * pvect.x
|
||||
local y_int = ppos.y + t * pvect.y
|
||||
if x_int>-0.45 and x_int<0.45 and y_int>-0.45 and y_int<0.45 then return 5 end
|
||||
if x_int > -0.45 and x_int < 0.45 and y_int > -0.45 and y_int < 0.45 then
|
||||
return 5
|
||||
end
|
||||
elseif pvect.z < 0 then
|
||||
local t = (0.5 - ppos.z) / pvect.z
|
||||
local x_int = ppos.x + t * pvect.x
|
||||
local y_int = ppos.y + t * pvect.y
|
||||
if x_int>-0.45 and x_int<0.45 and y_int>-0.45 and y_int<0.45 then return 6 end
|
||||
if x_int > -0.45 and x_int < 0.45 and y_int > -0.45 and y_int < 0.45 then
|
||||
return 6
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function lines(str)
|
||||
local function lines(str)
|
||||
local t = {}
|
||||
local function helper(line) table.insert(t, line) return "" end
|
||||
helper((str:gsub("(.-)\r?\n", helper)))
|
||||
helper(str:gsub("(.-)\r?\n", helper))
|
||||
return t
|
||||
end
|
||||
|
||||
@ -65,7 +83,9 @@ end
|
||||
|
||||
local function pos_in_list(l, pos)
|
||||
for _, p in ipairs(l) do
|
||||
if p.x==pos.x and p.y==pos.y and p.z==pos.z then return true end
|
||||
if p.x == pos.x and p.y == pos.y and p.z == pos.z then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -97,39 +117,56 @@ local function move_nodes_vect(poslist,vect,must_not_move,owner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, pos in ipairs(poslist) do
|
||||
local npos = vector.add(pos, vect)
|
||||
local name = minetest.get_node(npos).name
|
||||
if ((name~="air" and minetest.registered_nodes[name].liquidtype=="none") or frames_pos[pos_to_string(npos)]) and not(pos_in_list(poslist,npos)) then
|
||||
if (name ~= "air" and minetest.registered_nodes[name].liquidtype == "none" or
|
||||
frames_pos[pos_to_string(npos)]) and not pos_in_list(poslist, npos) then
|
||||
return
|
||||
end
|
||||
--[[if pos.x==must_not_move.x and pos.y==must_not_move.y and pos.z==must_not_move.z then
|
||||
return
|
||||
end]]
|
||||
end
|
||||
|
||||
local nodelist = {}
|
||||
for _, pos in ipairs(poslist) do
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
nodelist[#(nodelist)+1] = {oldpos = pos, pos = vector.add(pos, vect), node = node, meta = meta}
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
nodelist[#nodelist + 1] = {
|
||||
oldpos = pos,
|
||||
pos = vector.add(pos, vect),
|
||||
node = node,
|
||||
meta = meta,
|
||||
timer = {
|
||||
timeout = timer:get_timeout(),
|
||||
elapsed = timer:get_elapsed()
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local objects = {}
|
||||
for _, pos in ipairs(poslist) do
|
||||
for _, object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
local entity = object:get_luaentity()
|
||||
if not entity or not mesecon:is_mvps_unmov(entity.name) then
|
||||
if not entity or not mesecon.is_mvps_unmov(entity.name) then
|
||||
add_table(objects, object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, obj in ipairs(objects) do
|
||||
obj:setpos(vector.add(obj:getpos(), vect))
|
||||
end
|
||||
|
||||
for _, n in ipairs(nodelist) do
|
||||
local npos = n.pos
|
||||
minetest.set_node(npos, n.node)
|
||||
local meta = minetest.get_meta(npos)
|
||||
meta:from_table(n.meta)
|
||||
local timer = minetest.get_node_timer(npos)
|
||||
if n.timer.timeout ~= 0 or n.timer.elapsed ~= 0 then
|
||||
timer:set(n.timer.timeout, n.timer.elapsed)
|
||||
end
|
||||
for __, pos in ipairs(poslist) do
|
||||
if npos.x == pos.x and npos.y == pos.y and npos.z == pos.z then
|
||||
table.remove(poslist, __)
|
||||
@ -137,19 +174,20 @@ local function move_nodes_vect(poslist,vect,must_not_move,owner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for __, pos in ipairs(poslist) do
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
|
||||
for _, callback in ipairs(mesecon.on_mvps_move) do
|
||||
callback(nodelist)
|
||||
end
|
||||
end
|
||||
|
||||
local function is_supported_node(name)
|
||||
return ((string.find(name, "tube") ~= nil) and (string.find(name, "pipeworks") ~= nil))
|
||||
return string.find(name, "tube") and string.find(name, "pipeworks")
|
||||
end
|
||||
|
||||
|
||||
-- Frames
|
||||
for xm = 0, 1 do
|
||||
for xp = 0, 1 do
|
||||
@ -163,6 +201,7 @@ local b=7/16
|
||||
local nodeboxes = {
|
||||
{ -a, -a, -a, -b, a, -b },
|
||||
{ -a, -a, b, -b, a, a },
|
||||
|
||||
{ b, -a, b, a, a, a },
|
||||
{ b, -a, -a, a, a, -b },
|
||||
|
||||
@ -198,13 +237,13 @@ local nodeboxes= {
|
||||
table.insert(nodeboxes, { -b, -b, -a, b, b, -b })
|
||||
end
|
||||
|
||||
local nameext=tostring(xm)..tostring(xp)..tostring(ym)..tostring(yp)..tostring(zm)..tostring(zp)
|
||||
local nameext = string.format("%d%d%d%d%d%d", xm, xp, ym, yp, zm, zp)
|
||||
local groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2 }
|
||||
if nameext ~= "111111" then groups.not_in_creative_inventory = 1 end
|
||||
|
||||
|
||||
minetest.register_node("technic:frame_"..nameext, {
|
||||
description = "Frame",
|
||||
description = S("Frame"),
|
||||
tiles = { "technic_frame.png" },
|
||||
groups = groups,
|
||||
drawtype = "nodebox",
|
||||
@ -220,33 +259,44 @@ local nodeboxes= {
|
||||
frame = 1,
|
||||
drop = "technic:frame_111111",
|
||||
sunlight_propagates = true,
|
||||
|
||||
frame_connect_all = function(nodename)
|
||||
l2 = {}
|
||||
l1={{x=-1,y=0,z=0},{x=1,y=0,z=0},{x=0,y=-1,z=0},{x=0,y=1,z=0},{x=0,y=0,z=-1},{x=0,y=0,z=1}}
|
||||
l1 = {
|
||||
{ x = -1, y = 0, z = 0 }, { x = 1, y = 0, z = 0 },
|
||||
{ x = 0, y = -1, z = 0 }, { x = 0, y = 1, z = 0 },
|
||||
{ x = 0, y = 0, z = -1 }, { x = 0, y = 0, z = 1 }
|
||||
}
|
||||
for i, dir in ipairs(l1) do
|
||||
if string.sub(nodename, -7 + i, -7 + i) == "1" then
|
||||
l2[#(l2)+1]=dir
|
||||
l2[#l2 + 1] = dir
|
||||
end
|
||||
end
|
||||
return l2
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher)
|
||||
local ppos = puncher:getpos()
|
||||
local pvect = puncher:get_look_dir()
|
||||
local pface = get_face(pos, ppos, pvect)
|
||||
|
||||
if pface == nil then return end
|
||||
|
||||
local nodename = node.name
|
||||
local newstate=tostring(1-tonumber(string.sub(nodename,-7+pface,-7+pface)))
|
||||
local newstate = tostring(1 - tonumber(string.sub(nodename, pface - 7, pface - 7)))
|
||||
if pface <= 5 then
|
||||
nodename=string.sub(nodename,1,-7+pface-1)..newstate..string.sub(nodename,-7+pface+1)
|
||||
nodename = string.sub(nodename, 1, pface - 7 - 1)..newstate..string.sub(nodename, pface - 7 + 1)
|
||||
else
|
||||
nodename = string.sub(nodename, 1, -2)..newstate
|
||||
end
|
||||
|
||||
node.name = nodename
|
||||
minetest.set_node(pos, node)
|
||||
end,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above
|
||||
|
||||
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||
minetest.log("action", placer:get_player_name()
|
||||
.. " tried to place " .. itemstack:get_name()
|
||||
@ -255,7 +305,9 @@ local nodeboxes= {
|
||||
minetest.record_protection_violation(pos, placer:get_player_name())
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if pos == nil then return end
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name ~= "air" then
|
||||
if is_supported_node(node.name) then
|
||||
@ -265,11 +317,13 @@ local nodeboxes= {
|
||||
else
|
||||
minetest.set_node(pos, { name = itemstack:get_name() })
|
||||
end
|
||||
|
||||
if not infinite_stacks then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, placer, itemstack, pointed_thing)
|
||||
if is_supported_node(itemstack:get_name()) then
|
||||
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||
@ -288,7 +342,7 @@ local nodeboxes= {
|
||||
-- Run callback
|
||||
if def.after_place_node then
|
||||
-- Copy place_to because callback can modify it
|
||||
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
|
||||
local pos_copy = vector.new(pos)
|
||||
if def.after_place_node(pos_copy, placer, itemstack) then
|
||||
take_item = false
|
||||
end
|
||||
@ -317,7 +371,7 @@ local nodeboxes= {
|
||||
else
|
||||
--local pointed_thing = { type = "node", under = pos }
|
||||
if pointed_thing then
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
end
|
||||
end
|
||||
end,
|
||||
@ -343,15 +397,17 @@ minetest.register_entity("technic:frame_entity", {
|
||||
|
||||
set_node = function(self, node)
|
||||
self.node = node
|
||||
local pos = self.object:getpos()
|
||||
pos = {x = math.floor(pos.x+0.5), y = math.floor(pos.y+0.5), z = math.floor(pos.z+0.5)}
|
||||
local pos = vector.round(self.object:getpos())
|
||||
frames_pos[pos_to_string(pos)] = node.name
|
||||
|
||||
local stack = ItemStack(node.name)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
@ -376,8 +432,7 @@ minetest.register_entity("technic:frame_entity", {
|
||||
|
||||
dig = function(self)
|
||||
minetest.handle_node_drops(self.object:getpos(), { ItemStack("technic:frame_111111") }, self.last_puncher)
|
||||
local pos = self.object:getpos()
|
||||
pos = {x = math.floor(pos.x+0.5), y = math.floor(pos.y+0.5), z = math.floor(pos.z+0.5)}
|
||||
local pos = vector.round(self.object:getpos())
|
||||
frames_pos[pos_to_string(pos)] = nil
|
||||
self.object:remove()
|
||||
end,
|
||||
@ -393,18 +448,21 @@ minetest.register_entity("technic:frame_entity", {
|
||||
else
|
||||
self.damage_object:get_luaentity().remaining_time = 0.25
|
||||
end
|
||||
|
||||
self.last_puncher = puncher
|
||||
local ppos = puncher:getpos()
|
||||
local pvect = puncher:get_look_dir()
|
||||
local pface = get_face(pos, ppos, pvect)
|
||||
if pface == nil then return end
|
||||
local nodename = self.node.name
|
||||
local newstate = tostring(1-tonumber(string.sub(nodename, -7+pface, -7+pface)))
|
||||
local newstate = tostring(1 - tonumber(string.sub(nodename, pface - 7, pface - 7)))
|
||||
|
||||
if pface <= 5 then
|
||||
nodename = string.sub(nodename, 1, -7+pface-1)..newstate..string.sub(nodename, -7+pface+1)
|
||||
nodename = string.sub(nodename, 1, pface - 7 - 1)..newstate..string.sub(nodename, pface - 7 + 1)
|
||||
else
|
||||
nodename = string.sub(nodename, 1, -2)..newstate
|
||||
end
|
||||
|
||||
self.node.name = nodename
|
||||
self:set_node(self.node)
|
||||
end,
|
||||
@ -414,14 +472,19 @@ minetest.register_entity("technic:frame_entity", {
|
||||
local ppos = clicker:getpos()
|
||||
local pvect = clicker:get_look_dir()
|
||||
local pface = get_face(pos, ppos, pvect)
|
||||
if pface == nil then return end
|
||||
local pos_under = {x = math.floor(pos.x+0.5), y = math.floor(pos.y+0.5), z = math.floor(pos.z+0.5)}
|
||||
|
||||
if pface == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local pos_under = vector.round(pos)
|
||||
local pos_above = { x = pos_under.x, y = pos_under.y, z = pos_under.z }
|
||||
local index = ({ "x", "y", "z" })[math.floor((pface + 1) / 2)]
|
||||
pos_above[index] = pos_above[index] + 2 * ((pface + 1)%2) - 1
|
||||
local pointed_thing = { type = "node", under = pos_under, above = pos_above }
|
||||
local itemstack = clicker:get_wielded_item()
|
||||
local itemdef = minetest.registered_items[itemstack:get_name()]
|
||||
|
||||
if itemdef ~= nil then
|
||||
itemdef.on_place(itemstack, clicker, pointed_thing)
|
||||
end
|
||||
@ -462,13 +525,17 @@ minetest.register_entity("technic:damage_entity", {
|
||||
end,
|
||||
})
|
||||
|
||||
mesecon:register_mvps_unmov("technic:frame_entity")
|
||||
mesecon:register_mvps_unmov("technic:damage_entity")
|
||||
mesecon:register_on_mvps_move(function(moved_nodes)
|
||||
mesecon.register_mvps_unmov("technic:frame_entity")
|
||||
mesecon.register_mvps_unmov("technic:damage_entity")
|
||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||
local to_move = {}
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
if frames_pos[pos_to_string(n.oldpos)] ~= nil then
|
||||
to_move[#to_move+1] = {pos = n.pos, oldpos = n.oldpos, name = frames_pos[pos_to_string(n.oldpos)]}
|
||||
to_move[#to_move + 1] = {
|
||||
pos = n.pos,
|
||||
oldpos = n.oldpos,
|
||||
name = frames_pos[pos_to_string(n.oldpos)]
|
||||
}
|
||||
frames_pos[pos_to_string(n.oldpos)] = nil
|
||||
end
|
||||
end
|
||||
@ -478,7 +545,8 @@ mesecon:register_on_mvps_move(function(moved_nodes)
|
||||
local objects = minetest.get_objects_inside_radius(t.oldpos, 0.1)
|
||||
for _, obj in ipairs(objects) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and (entity.name == "technic:frame_entity" or entity.name == "technic:damage_entity") then
|
||||
if entity and (entity.name == "technic:frame_entity" or
|
||||
entity.name == "technic:damage_entity") then
|
||||
obj:setpos(t.pos)
|
||||
end
|
||||
end
|
||||
@ -508,10 +576,10 @@ local function connected(pos,c,adj)
|
||||
if frames_pos[pos_to_string(pos1)] then
|
||||
nodename = frames_pos[pos_to_string(pos1)]
|
||||
end
|
||||
if not(pos_in_list(c,pos1)) and nodename~="air" and
|
||||
if not pos_in_list(c, pos1) and nodename ~= "air" and
|
||||
(minetest.registered_nodes[nodename].frames_can_connect == nil or
|
||||
minetest.registered_nodes[nodename].frames_can_connect(pos1, vect)) then
|
||||
c[#(c)+1]=pos1
|
||||
c[#c + 1] = pos1
|
||||
if minetest.registered_nodes[nodename].frame == 1 then
|
||||
local adj = minetest.registered_nodes[nodename].frame_connect_all(nodename)
|
||||
connected(pos1, c, adj)
|
||||
@ -531,35 +599,55 @@ local function get_connected_nodes(pos)
|
||||
end
|
||||
|
||||
local function frame_motor_on(pos, node)
|
||||
local dirs = {{x=0,y=1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=-1,z=0}}
|
||||
local dirs = {
|
||||
{ x = 0, y = 1, z = 0 }, { x = 0, y = 0, z = 1 },
|
||||
{ x = 0, y = 0, z = -1 }, { x = 1, y = 0, z = 0 },
|
||||
{ x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }
|
||||
}
|
||||
local nnodepos = vector.add(pos, dirs[math.floor(node.param2 / 4) + 1])
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local nnode = minetest.get_node(nnodepos)
|
||||
|
||||
if frames_pos[pos_to_string(nnodepos)] then
|
||||
nnode.name = frames_pos[pos_to_string(nnodepos)]
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("last_moved") == minetest.get_gametime() then
|
||||
return
|
||||
end
|
||||
|
||||
local owner = meta:get_string("owner")
|
||||
if minetest.registered_nodes[nnode.name].frame == 1 then
|
||||
local connected_nodes = get_connected_nodes(nnodepos)
|
||||
move_nodes_vect(connected_nodes, dir, pos, owner)
|
||||
end
|
||||
|
||||
minetest.get_meta(vector.add(pos, dir)):set_int("last_moved", minetest.get_gametime())
|
||||
end
|
||||
|
||||
minetest.register_node("technic:frame_motor", {
|
||||
description = "Frame motor",
|
||||
tiles = {"pipeworks_filter_top.png^[transformR90", "technic_lv_cable.png", "technic_lv_cable.png",
|
||||
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
|
||||
description = S("Frame Motor"),
|
||||
tiles = {
|
||||
"pipeworks_filter_top.png^[transformR90", "technic_lv_cable.png", "technic_lv_cable.png",
|
||||
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"
|
||||
},
|
||||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2 },
|
||||
paramtype2 = "facedir",
|
||||
mesecons = { effector = { action_on = frame_motor_on } },
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
|
||||
frames_can_connect = function(pos, dir)
|
||||
local node = minetest.get_node(pos)
|
||||
local dir2 = ({{x=0,y=1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=-1,z=0}})[math.floor(node.param2/4)+1]
|
||||
local dir2 = ({
|
||||
{ x= 0 , y = 1, z = 0 }, { x = 0, y = 0, z = 1 },
|
||||
{ x = 0, y = 0, z = -1 }, { x = 1, y = 0, z = 0 },
|
||||
{ x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }
|
||||
})[math.floor(node.param2 / 4) + 1]
|
||||
return dir2.x ~= -dir.x or dir2.y ~= -dir.y or dir2.z ~= -dir.z
|
||||
end
|
||||
})
|
||||
@ -568,13 +656,19 @@ minetest.register_node("technic:frame_motor",{
|
||||
|
||||
-- Templates
|
||||
local function template_connected(pos, c, connectors)
|
||||
for _,vect in ipairs({{x=0,y=1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=-1,z=0}}) do
|
||||
local vects = {
|
||||
{ x = 0, y = 1, z = 0 }, { x = 0, y = 0, z = 1 },
|
||||
{ x = 0, y = 0, z = -1 }, { x = 1, y = 0, z = 0 },
|
||||
{ x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }
|
||||
}
|
||||
for _, vect in ipairs(vects) do
|
||||
local pos1 = vector.add(pos, vect)
|
||||
local nodename = minetest.get_node(pos1).name
|
||||
if not(pos_in_list(c,pos1)) and (nodename=="technic:template" or nodename == "technic:template_connector")then
|
||||
if not pos_in_list(c, pos1) and (nodename == "technic:template" or
|
||||
nodename == "technic:template_connector") then
|
||||
local meta = minetest.get_meta(pos1)
|
||||
if meta:get_string("connected") == "" then
|
||||
c[#(c)+1]=pos1
|
||||
c[#c + 1] = pos1
|
||||
template_connected(pos1, c, connectors)
|
||||
if nodename == "technic:template_connector" then
|
||||
connectors[#connectors + 1] = pos1
|
||||
@ -600,7 +694,7 @@ local function swap_template(pos, new)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local saved_node = meta:get_string("saved_node")
|
||||
meta:set_string("saved_node", "")
|
||||
hacky_swap_node(pos, new)
|
||||
technic.swap_node(pos, new)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("saved_node", saved_node)
|
||||
end
|
||||
@ -617,6 +711,7 @@ local function save_node(pos)
|
||||
meta:set_string("connected", "")
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta0 = meta:to_table()
|
||||
for _, list in pairs(meta0.inventory) do
|
||||
@ -624,6 +719,7 @@ local function save_node(pos)
|
||||
list[key] = stack:to_string()
|
||||
end
|
||||
end
|
||||
|
||||
node.meta = meta0
|
||||
minetest.set_node(pos, { name = "technic:template" })
|
||||
return node
|
||||
@ -643,25 +739,27 @@ end
|
||||
local function expand_template(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local c = meta:get_string("connected")
|
||||
|
||||
if c == "" then return end
|
||||
c = minetest.deserialize(c)
|
||||
|
||||
for _, vect in ipairs(c) do
|
||||
local pos1 = vector.add(pos, vect)
|
||||
local saved_node = save_node(pos1)
|
||||
local meta1 = minetest.get_meta(pos1)
|
||||
if saved_node ~= nil then
|
||||
meta1:set_string("saved_node", minetest.serialize(saved_node))
|
||||
else
|
||||
--meta1:set_string("saved_node", "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function compress_templates(pos)
|
||||
local templates, connectors = get_templates(pos)
|
||||
|
||||
if #connectors == 0 then
|
||||
connectors = { pos }
|
||||
end
|
||||
|
||||
for _, cn in ipairs(connectors) do
|
||||
local meta = minetest.get_meta(cn)
|
||||
local c = {}
|
||||
@ -674,7 +772,7 @@ local function compress_templates(pos)
|
||||
local cc = {}
|
||||
for _, p in ipairs(connectors) do
|
||||
local np = vector.subtract(p, cn)
|
||||
if (np.x ~= 0 or np.y ~= 0 or np.z ~= 0) then
|
||||
if np.x ~= 0 or np.y ~= 0 or np.z ~= 0 then
|
||||
cc[pos_to_string(np)] = true
|
||||
end
|
||||
end
|
||||
@ -694,6 +792,7 @@ local function template_drops(pos, node, oldmeta, digger)
|
||||
local c = oldmeta.fields.connected
|
||||
local cc = oldmeta.fields.connectors_connected
|
||||
local drops
|
||||
|
||||
if c == "" or c == nil then
|
||||
drops = { "technic:template 1" }
|
||||
else
|
||||
@ -715,7 +814,7 @@ local function template_drops(pos, node, oldmeta, digger)
|
||||
end
|
||||
else
|
||||
local stack_max = 99
|
||||
local num = #(minetest.deserialize(c))
|
||||
local num = #minetest.deserialize(c)
|
||||
drops = {}
|
||||
while num > stack_max do
|
||||
drops[#drops + 1] = "technic:template "..stack_max
|
||||
@ -725,6 +824,7 @@ local function template_drops(pos, node, oldmeta, digger)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.handle_node_drops(pos, drops, digger)
|
||||
end
|
||||
|
||||
@ -738,7 +838,7 @@ local function template_on_destruct(pos, node)
|
||||
end
|
||||
|
||||
minetest.register_node("technic:template", {
|
||||
description = "Template",
|
||||
description = S("Template"),
|
||||
tiles = { "technic_mv_cable.png" },
|
||||
drop = "",
|
||||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2 },
|
||||
@ -750,7 +850,7 @@ minetest.register_node("technic:template",{
|
||||
})
|
||||
|
||||
minetest.register_node("technic:template_disabled", {
|
||||
description = "Template",
|
||||
description = S("Template"),
|
||||
tiles = { "technic_hv_cable.png" },
|
||||
drop = "",
|
||||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1 },
|
||||
@ -763,7 +863,7 @@ minetest.register_node("technic:template_disabled",{
|
||||
})
|
||||
|
||||
minetest.register_node("technic:template_connector", {
|
||||
description = "Template",
|
||||
description = S("Template"),
|
||||
tiles = { "technic_lv_cable.png" },
|
||||
drop = "",
|
||||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1 },
|
||||
@ -775,7 +875,7 @@ minetest.register_node("technic:template_connector",{
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:template_replacer", {
|
||||
description = "Template (replacing)",
|
||||
description = S("Template (replacing)"),
|
||||
inventory_image = "technic_template_replacer.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local p = pointed_thing.under
|
||||
@ -795,11 +895,11 @@ minetest.register_craftitem("technic:template_replacer",{
|
||||
})
|
||||
|
||||
minetest.register_tool("technic:template_tool", {
|
||||
description = "Template tool",
|
||||
description = S("Template Tool"),
|
||||
inventory_image = "technic_template_tool.png",
|
||||
on_use = function(itemstack, puncher, pointed_thing)
|
||||
local pos = pointed_thing.under
|
||||
if pos == nil or (minetest.is_protected and minetest.is_protected(pos, placer:get_player_name())) then
|
||||
if pos == nil or minetest.is_protected and minetest.is_protected(pos, puncher:get_player_name()) then
|
||||
return nil
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
@ -828,29 +928,43 @@ local function get_template_nodes(pos)
|
||||
local pos1 = vector.add(pos, vect)
|
||||
local nodename = minetest.get_node(pos1).name
|
||||
if not(pos_in_list(c, pos1)) and nodename ~= "air" then
|
||||
c[#(c)+1]=pos1
|
||||
c[#c + 1] = pos1
|
||||
end
|
||||
end
|
||||
return c
|
||||
end
|
||||
|
||||
local function template_motor_on(pos, node)
|
||||
local dirs = {{x=0,y=1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=-1,z=0}}
|
||||
local dirs = {
|
||||
{ x = 0, y = 1, z = 0 }, { x = 0, y = 0, z = 1 },
|
||||
{ x = 0, y = 0, z = -1 }, { x = 1, y = 0, z = 0 },
|
||||
{ x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }
|
||||
}
|
||||
local nnodepos = vector.add(pos, dirs[math.floor(node.param2 / 4) + 1])
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local nnode = minetest.get_node(nnodepos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("last_moved") == minetest.get_gametime() then
|
||||
return
|
||||
end
|
||||
local owner = meta:get_string("owner")
|
||||
if nnode.name == "technic:template" then
|
||||
local connected_nodes = get_template_nodes(nnodepos)
|
||||
move_nodes_vect(connected_nodes, dir, pos, owner)
|
||||
end
|
||||
minetest.get_meta(vector.add(pos, dir)):set_int("last_moved", minetest.get_gametime())
|
||||
end
|
||||
|
||||
minetest.register_node("technic:template_motor", {
|
||||
description = "Template motor",
|
||||
tiles = {"pipeworks_filter_top.png^[transformR90", "technic_lv_cable.png", "technic_lv_cable.png",
|
||||
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
|
||||
description = S("Template Motor"),
|
||||
tiles = {
|
||||
"pipeworks_filter_top.png^[transformR90",
|
||||
"technic_lv_cable.png",
|
||||
"technic_lv_cable.png",
|
||||
"technic_lv_cable.png",
|
||||
"technic_lv_cable.png",
|
||||
"technic_lv_cable.png"
|
||||
},
|
||||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2 },
|
||||
paramtype2 = "facedir",
|
||||
mesecons = { effector = { action_on = template_motor_on } },
|
||||
@ -874,7 +988,7 @@ minetest.register_craft({
|
||||
output = 'technic:frame_motor',
|
||||
recipe = {
|
||||
{ '', 'technic:frame_111111', '' },
|
||||
{'group:mesecons_conductor_craftable', 'technic:motor', 'group:mesecons_conductor_craftable'},
|
||||
{ 'group:mesecon_conductor_craftable', 'technic:motor', 'group:mesecon_conductor_craftable' },
|
||||
{ '', 'technic:frame_111111', '' },
|
||||
}
|
||||
})
|
||||
@ -902,7 +1016,7 @@ minetest.register_craft({
|
||||
output = 'technic:template_motor',
|
||||
recipe = {
|
||||
{ '', 'technic:template', '' },
|
||||
{'group:mesecons_conductor_craftable', 'technic:motor', 'group:mesecons_conductor_craftable'},
|
||||
{ 'group:mesecon_conductor_craftable', 'technic:motor', 'group:mesecon_conductor_craftable' },
|
||||
{ '', 'technic:template', '' },
|
||||
}
|
||||
})
|
||||
|
@ -3,6 +3,13 @@ local path = technic.modpath.."/machines/other"
|
||||
-- mesecons and tubes related
|
||||
dofile(path.."/injector.lua")
|
||||
dofile(path.."/constructor.lua")
|
||||
if minetest.get_modpath("mesecons_mvps") ~= nil then
|
||||
|
||||
if technic.config:get_bool("enable_frames") and minetest.get_modpath("mesecons_mvps") ~= nil then
|
||||
dofile(path.."/frames.lua")
|
||||
end
|
||||
|
||||
-- Coal-powered machines
|
||||
dofile(path.."/coal_alloy_furnace.lua")
|
||||
dofile(path.."/coal_furnace.lua")
|
||||
|
||||
dofile(path.."/anchor.lua")
|
||||
|
@ -1,79 +1,12 @@
|
||||
minetest.register_craftitem("technic:injector", {
|
||||
description = "Injector",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:injector 1',
|
||||
recipe = {
|
||||
{'', 'technic:control_logic_unit',''},
|
||||
{'', 'default:chest',''},
|
||||
{'', 'pipeworks:tube_000000',''},
|
||||
}
|
||||
})
|
||||
local S = technic.getter
|
||||
|
||||
minetest.register_node("technic:injector", {
|
||||
description = "Injector",
|
||||
tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
|
||||
"technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
|
||||
groups = chest_groups1,
|
||||
tube = tubes_properties,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Injector]"..
|
||||
"button[0,1;.8,.8;mode;]"..
|
||||
"label[.8,1;Mode: single items]"..
|
||||
"list[current_name;main;0,2;8,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Injector")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
meta:set_string("mode","single items")
|
||||
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_receive_fields = function(pos, formanme, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local mode=meta:get_string("mode")
|
||||
if fields.mode then
|
||||
if mode=="single items" then mode="whole stacks"
|
||||
else mode="single items"
|
||||
end
|
||||
local mode=meta:set_string("mode",mode)
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Injector]"..
|
||||
"button[0,1;.8,.8;mode;]"..
|
||||
"label[.8,1;Mode: "..mode.."]"..
|
||||
"list[current_name;main;0,2;8,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
end,
|
||||
})
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:injector"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
local tube_entry = "^pipeworks_tube_connection_metallic.png"
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local pos1={}
|
||||
pos1.x = pos.x
|
||||
pos1.y = pos.y-1
|
||||
pos1.z = pos.z
|
||||
local meta=minetest.env:get_meta(pos1)
|
||||
if meta:get_int("tubelike")==1 then inject_items (pos) end
|
||||
end,
|
||||
})
|
||||
|
||||
function inject_items (pos)
|
||||
local meta=minetest.env:get_meta(pos)
|
||||
local function inject_items (pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local mode=meta:get_string("mode")
|
||||
if mode=="single items" then
|
||||
@ -84,11 +17,8 @@ function inject_items (pos)
|
||||
local item0=stack:to_table()
|
||||
if item0 then
|
||||
item0["count"] = "1"
|
||||
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
|
||||
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
|
||||
item1:setvelocity({x=0, y=-1, z=0})
|
||||
item1:setacceleration({x=0, y=0, z=0})
|
||||
stack:take_item(1);
|
||||
technic.tube_inject_item(pos, pos, vector.new(0, -1, 0), item0)
|
||||
stack:take_item(1)
|
||||
inv:set_stack("main", i, stack)
|
||||
return
|
||||
end
|
||||
@ -102,10 +32,7 @@ function inject_items (pos)
|
||||
if stack then
|
||||
local item0=stack:to_table()
|
||||
if item0 then
|
||||
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
|
||||
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
|
||||
item1:setvelocity({x=0, y=-1, z=0})
|
||||
item1:setacceleration({x=0, y=0, z=0})
|
||||
technic.tube_inject_item(pos, pos, vector.new(0, -1, 0), item0)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
return
|
||||
@ -115,3 +42,110 @@ function inject_items (pos)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:injector 1',
|
||||
recipe = {
|
||||
{'', 'technic:control_logic_unit',''},
|
||||
{'', 'default:chest',''},
|
||||
{'', 'pipeworks:tube_1',''},
|
||||
}
|
||||
})
|
||||
|
||||
local function set_injector_formspec(meta)
|
||||
local is_stack = meta:get_string("mode") == "whole stacks"
|
||||
meta:set_string("formspec",
|
||||
"size[8,9;]"..
|
||||
"item_image[0,0;1,1;technic:injector]"..
|
||||
"label[1,0;"..S("Self-Contained Injector").."]"..
|
||||
(is_stack and
|
||||
"button[0,1;2,1;mode_item;"..S("Stackwise").."]" or
|
||||
"button[0,1;2,1;mode_stack;"..S("Itemwise").."]")..
|
||||
"list[current_name;main;0,2;8,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[]"..
|
||||
fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
)
|
||||
end
|
||||
|
||||
minetest.register_node("technic:injector", {
|
||||
description = S("Self-Contained Injector"),
|
||||
tiles = {
|
||||
"technic_injector_top.png"..tube_entry,
|
||||
"technic_injector_bottom.png",
|
||||
"technic_injector_side.png"..tube_entry,
|
||||
"technic_injector_side.png"..tube_entry,
|
||||
"technic_injector_side.png"..tube_entry,
|
||||
"technic_injector_side.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1},
|
||||
tube = {
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return meta:get_inventory():room_for_item("main", stack)
|
||||
end,
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
return minetest.get_meta(pos):get_inventory():add_item("main", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Self-Contained Injector"))
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*2)
|
||||
meta:set_string("mode","single items")
|
||||
set_injector_formspec(meta)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
on_receive_fields = function(pos, formanme, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.mode_item then meta:set_string("mode", "single items") end
|
||||
if fields.mode_stack then meta:set_string("mode", "whole stacks") end
|
||||
|
||||
if fields["fs_helpers_cycling:0:splitstacks"]
|
||||
or fields["fs_helpers_cycling:1:splitstacks"] then
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
end
|
||||
set_injector_formspec(meta)
|
||||
end,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = pipeworks.after_dig
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run injector",
|
||||
nodenames = {"technic:injector"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local pos1 = vector.add(pos, vector.new(0, -1, 0))
|
||||
local node1 = minetest.get_node(pos1)
|
||||
if minetest.get_item_group(node1.name, "tubedevice") > 0 then
|
||||
inject_items(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
minetest.register_node("technic:tetris_machine_node1", {
|
||||
tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front1.png",
|
||||
"tetris_machine_side1B.png", "tetris_machine_side1P.png", "tetris_machine_side1L.png"},
|
||||
tile_images = {"technic_tetris_machine.png",},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("technic:tetris_machine_node2", {
|
||||
tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front2.png",
|
||||
"tetris_machine_side2B.png", "tetris_machine_side2P.png", "tetris_machine_side2L.png"},
|
||||
tile_images = {"technic_tetris_machine.png",},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
69
technic/machines/power_monitor.lua
Normal file
69
technic/machines/power_monitor.lua
Normal file
@ -0,0 +1,69 @@
|
||||
-- POWER MONITOR
|
||||
-- The power monitor can be used to monitor how much power is available on a network,
|
||||
-- similarly to the old "slave" switching stations.
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
minetest.register_craft({
|
||||
output = "technic:power_monitor",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"", "technic:machine_casing", "default:copper_ingot"},
|
||||
{"technic:lv_cable", "technic:lv_cable", "technic:lv_cable"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("technic:power_monitor",{
|
||||
description = S("Power Monitor"),
|
||||
tiles = {
|
||||
"technic_power_monitor_sides.png",
|
||||
"technic_power_monitor_sides.png"..cable_entry,
|
||||
"technic_power_monitor_sides.png",
|
||||
"technic_power_monitor_sides.png",
|
||||
"technic_power_monitor_sides.png"..cable_entry,
|
||||
"technic_power_monitor_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_all_tiers=1, technic_machine=1},
|
||||
connect_sides = {"bottom", "back"},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Power Monitor"))
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:power_monitor"},
|
||||
label = "Machines: run power monitor",
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local network_hash = technic.cables[minetest.hash_node_position(pos)]
|
||||
local network = network_hash and minetest.get_position_from_hash(network_hash)
|
||||
local sw_pos = network and {x=network.x,y=network.y+1,z=network.z}
|
||||
local timeout = 0
|
||||
for tier in pairs(technic.machines) do
|
||||
timeout = math.max(meta:get_int(tier.."_EU_timeout"),timeout)
|
||||
end
|
||||
if timeout > 0 and sw_pos and minetest.get_node(sw_pos).name == "technic:switching_station" then
|
||||
local sw_meta = minetest.get_meta(sw_pos)
|
||||
local supply = sw_meta:get_int("supply")
|
||||
local demand = sw_meta:get_int("demand")
|
||||
meta:set_string("infotext",
|
||||
S("Power Monitor. Supply: @1 Demand: @2",
|
||||
technic.EU_string(supply), technic.EU_string(demand)))
|
||||
else
|
||||
meta:set_string("infotext",S("Power Monitor Has No Network"))
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
for tier in pairs(technic.machines) do
|
||||
-- RE in order to use the "timeout" functions, although it consumes 0 power
|
||||
technic.register_machine(tier, "technic:power_monitor", "RE")
|
||||
end
|
||||
|
@ -1,287 +1,10 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
-- Register alloy recipes
|
||||
technic.alloy_recipes = {}
|
||||
|
||||
-- Register recipe in a table
|
||||
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
|
||||
in1 = {
|
||||
name = metal1,
|
||||
count = count1,
|
||||
}
|
||||
in2 = {
|
||||
name = metal2,
|
||||
count = count2,
|
||||
}
|
||||
-- Sort the inputs alphebetically
|
||||
if in1.name > in2.name then
|
||||
local temp = in1
|
||||
in1 = in2
|
||||
in2 = temp
|
||||
end
|
||||
technic.alloy_recipes[in1.name.." "..in2.name] = {
|
||||
input = {in1, in2},
|
||||
output = {
|
||||
name = result,
|
||||
count = count3,
|
||||
},
|
||||
}
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "alloy",
|
||||
output = result.." "..count3,
|
||||
items = {metal1.." "..count1, metal2.." "..count2},
|
||||
width = 2,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Retrieve a recipe given the input metals.
|
||||
function technic.get_alloy_recipe(stack1, stack2)
|
||||
-- Sort the stacks alphebetically
|
||||
if stack1:get_name() > stack2:get_name() then
|
||||
local temp = stack1
|
||||
stack1 = stack2
|
||||
stack2 = temp
|
||||
end
|
||||
for _, recipe in pairs(technic.alloy_recipes) do
|
||||
if recipe.input[1].name == stack1:get_name() and
|
||||
recipe.input[2].name == stack2:get_name() and
|
||||
stack1:get_count() >= recipe.input[1].count and
|
||||
stack2:get_count() >= recipe.input[2].count then
|
||||
return recipe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
technic.register_alloy_recipe("technic:copper_dust", 3, "technic:tin_dust", 1, "technic:bronze_dust", 4)
|
||||
technic.register_alloy_recipe("default:copper_ingot", 3, "moreores:tin_ingot", 1, "moreores:bronze_ingot", 4)
|
||||
technic.register_alloy_recipe("technic:iron_dust", 3, "technic:chromium_dust", 1, "technic:stainless_steel_dust", 4)
|
||||
technic.register_alloy_recipe("default:steel_ingot", 3, "technic:chromium_ingot", 1, "technic:stainless_steel_ingot", 4)
|
||||
technic.register_alloy_recipe("technic:copper_dust", 2, "technic:zinc_dust", 1, "technic:brass_dust", 3)
|
||||
technic.register_alloy_recipe("default:copper_ingot", 2, "technic:zinc_ingot", 1, "technic:brass_ingot", 3)
|
||||
technic.register_alloy_recipe("default:sand", 2, "technic:coal_dust", 2, "technic:silicon_wafer", 1)
|
||||
technic.register_alloy_recipe("technic:silicon_wafer", 1, "technic:gold_dust", 1, "technic:doped_silicon_wafer", 1)
|
||||
|
||||
|
||||
function technic.register_alloy_furnace(data)
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
local tube_side_texture = data.tube and "technic_"..ltier.."_alloy_furnace_side_tube.png"
|
||||
or "technic_"..ltier.."_alloy_furnace_side.png"
|
||||
local groups = {cracky=2}
|
||||
local active_groups = {cracky=2, not_in_creative_inventory=1}
|
||||
if data.tube then
|
||||
groups.tubedevice = 1
|
||||
groups.tubedevice_receiver = 1
|
||||
active_groups.tubedevice = 1
|
||||
active_groups.tubedevice_receiver = 1
|
||||
data.typename = "alloy"
|
||||
data.machine_name = "alloy_furnace"
|
||||
data.machine_desc = S("%s Alloy Furnace")
|
||||
technic.register_base_machine(data)
|
||||
end
|
||||
|
||||
local formspec =
|
||||
"invsize[8,10;]"..
|
||||
"label[0,0;"..S("%s Alloy Furnace"):format(tier).."]"..
|
||||
"list[current_name;src;3,1;1,2;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,6;8,4;]"
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[current_name;upgrade1;1,4;1,1;]"..
|
||||
"list[current_name;upgrade2;2,4;1,1;]"..
|
||||
"label[1,5;Upgrade Slots]"
|
||||
end
|
||||
|
||||
data.formspec = formspec
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
}
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_alloy_furnace", {
|
||||
description = S("%s Alloy Furnace"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_alloy_furnace_top.png",
|
||||
"technic_"..ltier.."_alloy_furnace_bottom.png",
|
||||
tube_side_texture,
|
||||
tube_side_texture,
|
||||
"technic_"..ltier.."_alloy_furnace_side.png",
|
||||
"technic_"..ltier.."_alloy_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = groups,
|
||||
tube = tube,
|
||||
technic = data,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
local data = minetest.registered_nodes[name].technic
|
||||
|
||||
|
||||
meta:set_string("infotext", S("%s Alloy Furnace"):format(data.tier))
|
||||
meta:set_string("formspec", data.formspec)
|
||||
meta:set_int("tube_time", 0)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 2)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
||||
not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_alloy_furnace_active",{
|
||||
description = S(tier.." Alloy Furnace"),
|
||||
tiles = {"technic_"..ltier.."_alloy_furnace_top.png",
|
||||
"technic_"..ltier.."_alloy_furnace_bottom.png",
|
||||
tube_side_texture,
|
||||
tube_side_texture,
|
||||
"technic_"..ltier.."_alloy_furnace_side.png",
|
||||
"technic_"..ltier.."_alloy_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "technic:"..ltier.."_alloy_furnace",
|
||||
groups = active_groups,
|
||||
tube = tube,
|
||||
technic = data,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
||||
not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
-- These three makes sure upgrades are not moved in or out while the furnace is active.
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if listname == "src" or listname == "dst" then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0 -- Disallow the move
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if listname == "src" or listname == "dst" then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0 -- Disallow the move
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:"..ltier.."_alloy_furnace", "technic:"..ltier.."_alloy_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local data = minetest.registered_nodes[node.name].technic
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int(data.tier.."_EU_input")
|
||||
|
||||
-- Machine information
|
||||
local machine_name = S("%s Alloy Furnace"):format(data.tier)
|
||||
local machine_node = "technic:"..string.lower(data.tier).."_alloy_furnace"
|
||||
local machine_demand = data.demand
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int(data.tier.."_EU_demand", machine_demand[1])
|
||||
meta:set_int(data.tier.."_EU_input", 0)
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, data.tier)
|
||||
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
if data.tube then
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
end
|
||||
|
||||
-- Get what to cook if anything
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src2stack = inv:get_stack("src", 2)
|
||||
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
||||
local result = recipe and ItemStack(recipe.output) or nil
|
||||
-- Sort the stacks alphabetically
|
||||
if srcstack:get_name() > src2stack:get_name() then
|
||||
local temp = srcstack
|
||||
srcstack = src2stack
|
||||
src2stack = temp
|
||||
end
|
||||
if not result or
|
||||
not inv:room_for_item("dst", result) then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int(data.tier.."_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < machine_demand[EU_upgrade+1] then
|
||||
-- Unpowered - go idle
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= machine_demand[EU_upgrade+1] then
|
||||
-- Powered
|
||||
hacky_swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") == data.cook_time then
|
||||
meta:set_int("src_time", 0)
|
||||
-- check if there's room for output and that we have the materials
|
||||
if inv:room_for_item("dst", result) then
|
||||
srcstack:take_item(recipe.input[1].count)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
src2stack:take_item(recipe.input[2].count)
|
||||
inv:set_stack("src", 2, src2stack)
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", result)
|
||||
else
|
||||
next_state = 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
meta:set_int(data.tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_alloy_furnace", technic.receiver)
|
||||
technic.register_machine(tier, "technic:"..ltier.."_alloy_furnace_active", technic.receiver)
|
||||
|
||||
end -- End registration
|
||||
|
||||
|
35
technic/machines/register/alloy_recipes.lua
Normal file
35
technic/machines/register/alloy_recipes.lua
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_recipe_type("alloy", {
|
||||
description = S("Alloying"),
|
||||
input_size = 2,
|
||||
})
|
||||
|
||||
function technic.register_alloy_recipe(data)
|
||||
data.time = data.time or 6
|
||||
technic.register_recipe("alloy", data)
|
||||
end
|
||||
|
||||
local recipes = {
|
||||
{"technic:copper_dust 3", "technic:tin_dust", "technic:bronze_dust 4"},
|
||||
{"default:copper_ingot 3", "default:tin_ingot", "default:bronze_ingot 4"},
|
||||
{"technic:wrought_iron_dust", "technic:coal_dust", "technic:carbon_steel_dust", 3},
|
||||
{"technic:wrought_iron_ingot", "technic:coal_dust", "technic:carbon_steel_ingot", 3},
|
||||
{"technic:carbon_steel_dust", "technic:coal_dust", "technic:cast_iron_dust", 3},
|
||||
{"technic:carbon_steel_ingot", "technic:coal_dust", "technic:cast_iron_ingot", 3},
|
||||
{"technic:carbon_steel_dust 3", "technic:chromium_dust", "technic:stainless_steel_dust 4"},
|
||||
{"technic:carbon_steel_ingot 3", "technic:chromium_ingot", "technic:stainless_steel_ingot 4"},
|
||||
{"technic:copper_dust 2", "technic:zinc_dust", "technic:brass_dust 3"},
|
||||
{"default:copper_ingot 2", "technic:zinc_ingot", "technic:brass_ingot 3"},
|
||||
{"default:sand 2", "technic:coal_dust 2", "technic:silicon_wafer"},
|
||||
{"technic:silicon_wafer", "technic:gold_dust", "technic:doped_silicon_wafer"},
|
||||
-- from https://en.wikipedia.org/wiki/Carbon_black
|
||||
-- The highest volume use of carbon black is as a reinforcing filler in rubber products, especially tires.
|
||||
-- "[Compounding a] pure gum vulcanizate … with 50% of its weight of carbon black improves its tensile strength and wear resistance …"
|
||||
{"technic:raw_latex 4", "technic:coal_dust 2", "technic:rubber 6", 2},
|
||||
}
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_alloy_recipe({input = {data[1], data[2]}, output = data[3], time = data[4]})
|
||||
end
|
@ -1,88 +1,213 @@
|
||||
|
||||
local digilines_path = minetest.get_modpath("digilines")
|
||||
|
||||
local S = technic.getter
|
||||
local tube_entry = "^pipeworks_tube_connection_metallic.png"
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
technic.register_power_tool("technic:battery", 10000)
|
||||
technic.register_power_tool("technic:red_energy_crystal", 50000)
|
||||
technic.register_power_tool("technic:green_energy_crystal", 150000)
|
||||
technic.register_power_tool("technic:blue_energy_crystal", 450000)
|
||||
|
||||
-- Battery recipes:
|
||||
-- Tin-copper recipe:
|
||||
minetest.register_craft({
|
||||
output = "technic:battery",
|
||||
recipe = {
|
||||
{"group:wood", "default:copper_ingot", "group:wood"},
|
||||
{"group:wood", "default:tin_ingot", "group:wood"},
|
||||
{"group:wood", "default:copper_ingot", "group:wood"},
|
||||
}
|
||||
})
|
||||
-- Sulfur-lead-water recipes:
|
||||
-- With sulfur lumps:
|
||||
-- With water:
|
||||
minetest.register_craft({
|
||||
output = "technic:battery",
|
||||
recipe = {
|
||||
{"group:wood", "technic:sulfur_lump", "group:wood"},
|
||||
{"technic:lead_ingot", "bucket:bucket_water", "technic:lead_ingot"},
|
||||
{"group:wood", "technic:sulfur_lump", "group:wood"},
|
||||
},
|
||||
replacements = {
|
||||
{"bucket:bucket_water", "bucket:bucket_empty"}
|
||||
}
|
||||
})
|
||||
-- With oil extract:
|
||||
minetest.register_craft({
|
||||
output = "technic:battery",
|
||||
recipe = {
|
||||
{"group:wood", "technic:sulfur_lump", "group:wood"},
|
||||
{"technic:lead_ingot", "homedecor:oil_extract", "technic:lead_ingot"},
|
||||
{"group:wood", "technic:sulfur_lump", "group:wood"},
|
||||
}
|
||||
})
|
||||
-- With sulfur dust:
|
||||
-- With water:
|
||||
minetest.register_craft({
|
||||
output = "technic:battery",
|
||||
recipe = {
|
||||
{"group:wood", "technic:sulfur_dust", "group:wood"},
|
||||
{"technic:lead_ingot", "bucket:bucket_water", "technic:lead_ingot"},
|
||||
{"group:wood", "technic:sulfur_dust", "group:wood"},
|
||||
},
|
||||
replacements = {
|
||||
{"bucket:bucket_water", "bucket:bucket_empty"}
|
||||
}
|
||||
})
|
||||
-- With oil extract:
|
||||
minetest.register_craft({
|
||||
output = "technic:battery",
|
||||
recipe = {
|
||||
{"group:wood", "technic:sulfur_dust", "group:wood"},
|
||||
{"technic:lead_ingot", "homedecor:oil_extract", "technic:lead_ingot"},
|
||||
{"group:wood", "technic:sulfur_dust", "group:wood"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_tool("technic:battery", {
|
||||
description = S("RE Battery"),
|
||||
inventory_image = "technic_battery.png",
|
||||
wear_represents = "technic_RE_charge",
|
||||
on_refill = technic.refill_RE_charge,
|
||||
tool_capabilities = {
|
||||
charge = 0,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
fleshy = {times={}, uses=10000, maxlevel=0}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- x+2 + (z+2)*2
|
||||
local dirtab = {
|
||||
[4] = 2,
|
||||
[5] = 3,
|
||||
[7] = 1,
|
||||
[8] = 0
|
||||
}
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
print(minetest.pos_to_string(direction), dirtab[direction.x+2+(direction.z+2)*2], node.param2)
|
||||
if direction.y == 1
|
||||
or (direction.y == 0 and dirtab[direction.x+2+(direction.z+2)*2] == node.param2) then
|
||||
return stack
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 0 then
|
||||
return inv:add_item("src", stack)
|
||||
else
|
||||
return inv:add_item("dst", stack)
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
print(minetest.pos_to_string(direction), dirtab[direction.x+2+(direction.z+2)*2], node.param2)
|
||||
if direction.y == 1
|
||||
or (direction.y == 0 and dirtab[direction.x+2+(direction.z+2)*2] == node.param2) then
|
||||
return false
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 0 then
|
||||
if meta:get_int("split_src_stacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("src", stack)
|
||||
else
|
||||
if meta:get_int("split_dst_stacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("dst", stack)
|
||||
end
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1},
|
||||
}
|
||||
|
||||
local function add_on_off_buttons(meta, ltier, charge_percent)
|
||||
local formspec = ""
|
||||
if ltier == "mv" or ltier == "hv" then
|
||||
formspec = "image[1,1;1,2;technic_power_meter_bg.png"
|
||||
.."^[lowpart:"..charge_percent
|
||||
..":technic_power_meter_fg.png]"..
|
||||
fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[3,2.0;1,0.6",
|
||||
"split_src_stacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
).."label[3.9,2.01;Allow splitting incoming 'charge' stacks from tubes]"..
|
||||
fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[3,2.5;1,0.6",
|
||||
"split_dst_stacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
).."label[3.9,2.51;Allow splitting incoming 'discharge' stacks]"
|
||||
end
|
||||
return formspec
|
||||
end
|
||||
|
||||
function technic.register_battery_box(data)
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
data.formspec =
|
||||
"invsize[8,9;]"..
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[context;src;3,1;1,1;]"..
|
||||
"image[4,1;1,1;technic_battery_reload.png]"..
|
||||
"list[current_name;dst;5,1;1,1;]"..
|
||||
"list[context;dst;5,1;1,1;]"..
|
||||
"label[0,0;"..S("%s Battery Box"):format(tier).."]"..
|
||||
"label[3,0;"..S("Charge").."]"..
|
||||
"label[5,0;"..S("Discharge").."]"..
|
||||
"label[1,3;"..S("Power level").."]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
for i = 0, 8 do
|
||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
|
||||
if i ~= 0 then
|
||||
groups.not_in_creative_inventory = 1
|
||||
if digilines_path then
|
||||
formspec = formspec.."button[0.6,3.7;2,1;edit_channel;edit Channel]"
|
||||
end
|
||||
minetest.register_node("technic:"..ltier.."_battery_box"..i, {
|
||||
description = S("%s Battery Box"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_battery_box_top.png",
|
||||
"technic_"..ltier.."_battery_box_bottom.png",
|
||||
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
|
||||
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
|
||||
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
|
||||
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"},
|
||||
groups = groups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:"..ltier.."_battery_box0",
|
||||
technic = data,
|
||||
on_construct = function(pos)
|
||||
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[context;upgrade1;3.5,3;1,1;]"..
|
||||
"list[context;upgrade2;4.5,3;1,1;]"..
|
||||
"label[3.5,4;"..S("Upgrade Slots").."]"..
|
||||
"listring[context;upgrade1]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;upgrade2]"..
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
|
||||
local run = function(pos, node)
|
||||
local below = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local node = minetest.get_node(pos)
|
||||
local data = minetest.registered_nodes[node.name].technic
|
||||
|
||||
meta:set_string("infotext", S("%s Battery Box"):format(data.tier))
|
||||
meta:set_string("formspec", data.formspec)
|
||||
meta:set_int(data.tier.."_EU_demand", 0)
|
||||
meta:set_int(data.tier.."_EU_supply", 0)
|
||||
meta:set_int(data.tier.."_EU_input", 0)
|
||||
meta:set_float("internal_EU_charge", 0)
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 1)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
if not technic.is_tier_cable(below.name, tier) then
|
||||
meta:set_string("infotext", S("%s Battery Box Has No Network"):format(tier))
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:"..ltier.."_battery_box0", "technic:"..ltier.."_battery_box1",
|
||||
"technic:"..ltier.."_battery_box2", "technic:"..ltier.."_battery_box3",
|
||||
"technic:"..ltier.."_battery_box4", "technic:"..ltier.."_battery_box5",
|
||||
"technic:"..ltier.."_battery_box6", "technic:"..ltier.."_battery_box7",
|
||||
"technic:"..ltier.."_battery_box8"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local data = minetest.registered_nodes[node.name].technic
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int(data.tier.."_EU_input")
|
||||
local eu_input = meta:get_int(tier.."_EU_input")
|
||||
local current_charge = meta:get_int("internal_EU_charge")
|
||||
local max_charge = data.max_charge
|
||||
local charge_rate = data.charge_rate
|
||||
local discharge_rate = data.discharge_rate
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, data.tier)
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
local max_charge = data.max_charge * (1 + EU_upgrade / 10)
|
||||
|
||||
-- Charge/discharge the battery with the input EUs
|
||||
if eu_input >= 0 then
|
||||
@ -92,17 +217,30 @@ function technic.register_battery_box(data)
|
||||
end
|
||||
|
||||
-- Charging/discharging tools here
|
||||
current_charge = technic.charge_tools(meta,
|
||||
local tool_full, tool_empty
|
||||
current_charge, tool_full = technic.charge_tools(meta,
|
||||
current_charge, data.charge_step)
|
||||
current_charge = technic.discharge_tools(meta,
|
||||
current_charge, data.discharge_step, max_charge)
|
||||
current_charge, tool_empty = technic.discharge_tools(meta,
|
||||
current_charge, data.discharge_step,
|
||||
max_charge)
|
||||
|
||||
if data.tube then
|
||||
local inv = meta:get_inventory()
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade,
|
||||
function(pos, x_velocity, z_velocity)
|
||||
if tool_full and not inv:is_empty("src") then
|
||||
technic.send_items(pos, x_velocity, z_velocity, "src")
|
||||
elseif tool_empty and not inv:is_empty("dst") then
|
||||
technic.send_items(pos, x_velocity, z_velocity, "dst")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- We allow batteries to charge on less than the demand
|
||||
meta:set_int(data.tier.."_EU_demand",
|
||||
math.min(charge_rate, max_charge - current_charge))
|
||||
meta:set_int(data.tier.."_EU_supply",
|
||||
math.min(discharge_rate, current_charge))
|
||||
|
||||
meta:set_int(tier.."_EU_demand",
|
||||
math.min(data.charge_rate, max_charge - current_charge))
|
||||
meta:set_int(tier.."_EU_supply",
|
||||
math.min(data.discharge_rate, current_charge))
|
||||
meta:set_int("internal_EU_charge", current_charge)
|
||||
|
||||
-- Select node textures
|
||||
@ -111,24 +249,142 @@ function technic.register_battery_box(data)
|
||||
charge_count = math.max(charge_count, 0)
|
||||
local last_count = meta:get_float("last_side_shown")
|
||||
if charge_count ~= last_count then
|
||||
hacky_swap_node(pos,"technic:"..string.lower(data.tier).."_battery_box"..charge_count)
|
||||
technic.swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count)
|
||||
meta:set_float("last_side_shown", charge_count)
|
||||
end
|
||||
|
||||
local charge_percent = math.floor(current_charge / max_charge * 100)
|
||||
meta:set_string("formspec",
|
||||
data.formspec..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png"
|
||||
.."^[lowpart:"..charge_percent
|
||||
..":technic_power_meter_fg.png]")
|
||||
|
||||
local infotext = S("%s Battery Box: %d/%d"):format(data.tier, current_charge, max_charge)
|
||||
meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, charge_percent))
|
||||
local infotext = S("@1 Battery Box: @2 / @3", tier,
|
||||
technic.EU_string(current_charge),
|
||||
technic.EU_string(max_charge))
|
||||
if eu_input == 0 then
|
||||
infotext = S("%s Idle"):format(infotext)
|
||||
end
|
||||
meta:set_string("infotext", infotext)
|
||||
end
|
||||
|
||||
for i = 0, 8 do
|
||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, ["technic_"..ltier]=1}
|
||||
if i ~= 0 then
|
||||
groups.not_in_creative_inventory = 1
|
||||
end
|
||||
|
||||
if data.tube then
|
||||
groups.tubedevice = 1
|
||||
groups.tubedevice_receiver = 1
|
||||
end
|
||||
|
||||
local top_tex = "technic_"..ltier.."_battery_box_top.png"..tube_entry
|
||||
local front_tex = "technic_"..ltier.."_battery_box_front.png^technic_power_meter"..i..".png"
|
||||
local side_tex = "technic_"..ltier.."_battery_box_side.png"..tube_entry
|
||||
local bottom_tex = "technic_"..ltier.."_battery_box_bottom.png"..cable_entry
|
||||
|
||||
if ltier == "lv" then
|
||||
top_tex = "technic_"..ltier.."_battery_box_top.png"
|
||||
front_tex = "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"
|
||||
side_tex = "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"
|
||||
end
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_battery_box"..i, {
|
||||
description = S("%s Battery Box"):format(tier),
|
||||
tiles = {
|
||||
top_tex,
|
||||
bottom_tex,
|
||||
side_tex,
|
||||
side_tex,
|
||||
side_tex,
|
||||
front_tex},
|
||||
groups = groups,
|
||||
connect_sides = {"bottom"},
|
||||
tube = data.tube and tube or nil,
|
||||
paramtype2 = "facedir",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:"..ltier.."_battery_box0",
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
local max_charge = data.max_charge * (1 + EU_upgrade / 10)
|
||||
local charge = meta:get_int("internal_EU_charge")
|
||||
local cpercent = math.floor(charge / max_charge * 100)
|
||||
local inv = meta:get_inventory()
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_string("infotext", S("%s Battery Box"):format(tier))
|
||||
meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, cpercent))
|
||||
meta:set_string("channel", ltier.."_battery_box"..minetest.pos_to_string(pos))
|
||||
meta:set_int(tier.."_EU_demand", 0)
|
||||
meta:set_int(tier.."_EU_supply", 0)
|
||||
meta:set_int(tier.."_EU_input", 0)
|
||||
meta:set_float("internal_EU_charge", 0)
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 1)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
after_place_node = data.tube and pipeworks.after_place,
|
||||
after_dig_node = technic.machine_after_dig_node,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nodename = minetest.get_node(pos).name
|
||||
if fields.edit_channel then
|
||||
minetest.show_formspec(sender:get_player_name(),
|
||||
"technic:battery_box_edit_channel"..minetest.pos_to_string(pos),
|
||||
"field[channel;Digiline Channel;"..meta:get_string("channel").."]")
|
||||
elseif fields["fs_helpers_cycling:0:split_src_stacks"]
|
||||
or fields["fs_helpers_cycling:0:split_dst_stacks"]
|
||||
or fields["fs_helpers_cycling:1:split_src_stacks"]
|
||||
or fields["fs_helpers_cycling:1:split_dst_stacks"] then
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
local max_charge = data.max_charge * (1 + EU_upgrade / 10)
|
||||
local charge = meta:get_int("internal_EU_charge")
|
||||
local cpercent = math.floor(charge / max_charge * 100)
|
||||
meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, cpercent))
|
||||
end
|
||||
end,
|
||||
digiline = {
|
||||
receptor = {action = function() end},
|
||||
effector = {
|
||||
action = function(pos, node, channel, msg)
|
||||
if msg ~= "GET" and msg ~= "get" then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
if channel ~= meta:get_string("channel") then
|
||||
return
|
||||
end
|
||||
local inv = meta:get_inventory()
|
||||
digilines.receptor_send(pos, digilines.rules.default, channel, {
|
||||
demand = meta:get_int(tier.."_EU_demand"),
|
||||
supply = meta:get_int(tier.."_EU_supply"),
|
||||
input = meta:get_int(tier.."_EU_input"),
|
||||
charge = meta:get_int("internal_EU_charge"),
|
||||
max_charge = data.max_charge * (1 + technic.handle_machine_upgrades(meta) / 10),
|
||||
src = inv:get_stack("src", 1):to_table(),
|
||||
dst = inv:get_stack("dst", 1):to_table(),
|
||||
upgrade1 = inv:get_stack("upgrade1", 1):to_table(),
|
||||
upgrade2 = inv:get_stack("upgrade2", 1):to_table()
|
||||
})
|
||||
end
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- Register as a battery type
|
||||
-- Battery type machines function as power reservoirs and can both receive and give back power
|
||||
@ -138,55 +394,71 @@ function technic.register_battery_box(data)
|
||||
|
||||
end -- End registration
|
||||
|
||||
minetest.register_on_player_receive_fields(
|
||||
function(player, formname, fields)
|
||||
if formname:sub(1, 32) ~= "technic:battery_box_edit_channel" or
|
||||
not fields.channel then
|
||||
return
|
||||
end
|
||||
local pos = minetest.string_to_pos(formname:sub(33))
|
||||
local plname = player:get_player_name()
|
||||
if minetest.is_protected(pos, plname) then
|
||||
minetest.record_protection_violation(pos, plname)
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("channel", fields.channel)
|
||||
end
|
||||
)
|
||||
|
||||
function technic.charge_tools(meta, batt_charge, charge_step)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("src") then
|
||||
return batt_charge
|
||||
return batt_charge, false
|
||||
end
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src_meta = get_item_meta(srcstack:get_metadata())
|
||||
local src_stack = inv:get_stack("src", 1)
|
||||
|
||||
local toolname = srcstack:get_name()
|
||||
if not technic.power_tools[toolname] then
|
||||
return batt_charge
|
||||
local tool_name = src_stack:get_name()
|
||||
if not technic.power_tools[tool_name] then
|
||||
return batt_charge, false
|
||||
end
|
||||
-- Set meta data for the tool if it didn't do it itself
|
||||
src_meta = get_item_meta(srcstack:get_metadata())
|
||||
src_meta = src_meta or {}
|
||||
local src_meta = minetest.deserialize(src_stack:get_metadata()) or {}
|
||||
if not src_meta.charge then
|
||||
src_meta.charge = 0
|
||||
end
|
||||
-- Do the charging
|
||||
local item_max_charge = technic.power_tools[toolname]
|
||||
local item_max_charge = technic.power_tools[tool_name]
|
||||
local tool_charge = src_meta.charge
|
||||
if tool_charge >= item_max_charge or batt_charge <= 0 then
|
||||
return batt_charge
|
||||
if tool_charge >= item_max_charge then
|
||||
return batt_charge, true
|
||||
elseif batt_charge <= 0 then
|
||||
return batt_charge, false
|
||||
end
|
||||
charge_step = math.min(charge_step, batt_charge)
|
||||
charge_step = math.min(charge_step, item_max_charge - tool_charge)
|
||||
tool_charge = tool_charge + charge_step
|
||||
batt_charge = batt_charge - charge_step
|
||||
technic.set_RE_wear(srcstack, tool_charge, item_max_charge)
|
||||
technic.set_RE_wear(src_stack, tool_charge, item_max_charge)
|
||||
src_meta.charge = tool_charge
|
||||
srcstack:set_metadata(set_item_meta(src_meta))
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
return batt_charge
|
||||
src_stack:set_metadata(minetest.serialize(src_meta))
|
||||
inv:set_stack("src", 1, src_stack)
|
||||
return batt_charge, (tool_charge == item_max_charge)
|
||||
end
|
||||
|
||||
|
||||
function technic.discharge_tools(meta, batt_charge, charge_step, max_charge)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") then
|
||||
return batt_charge
|
||||
return batt_charge, false
|
||||
end
|
||||
srcstack = inv:get_stack("dst", 1)
|
||||
local toolname = srcstack:get_name()
|
||||
if technic.power_tools[toolname] == nil then
|
||||
return batt_charge
|
||||
return batt_charge, false
|
||||
end
|
||||
-- Set meta data for the tool if it didn't do it itself :-(
|
||||
local src_meta = get_item_meta(srcstack:get_metadata())
|
||||
local src_meta = minetest.deserialize(srcstack:get_metadata())
|
||||
src_meta = src_meta or {}
|
||||
if not src_meta.charge then
|
||||
src_meta.charge = 0
|
||||
@ -195,8 +467,10 @@ function technic.discharge_tools(meta, batt_charge, charge_step, max_charge)
|
||||
-- Do the discharging
|
||||
local item_max_charge = technic.power_tools[toolname]
|
||||
local tool_charge = src_meta.charge
|
||||
if tool_charge <= 0 or batt_charge >= max_charge then
|
||||
return batt_charge
|
||||
if tool_charge <= 0 then
|
||||
return batt_charge, true
|
||||
elseif batt_charge >= max_charge then
|
||||
return batt_charge, false
|
||||
end
|
||||
charge_step = math.min(charge_step, max_charge - batt_charge)
|
||||
charge_step = math.min(charge_step, tool_charge)
|
||||
@ -204,8 +478,8 @@ function technic.discharge_tools(meta, batt_charge, charge_step, max_charge)
|
||||
batt_charge = batt_charge + charge_step
|
||||
technic.set_RE_wear(srcstack, tool_charge, item_max_charge)
|
||||
src_meta.charge = tool_charge
|
||||
srcstack:set_metadata(set_item_meta(src_meta))
|
||||
srcstack:set_metadata(minetest.serialize(src_meta))
|
||||
inv:set_stack("dst", 1, srcstack)
|
||||
return batt_charge
|
||||
return batt_charge, (tool_charge == 0)
|
||||
end
|
||||
|
||||
|
@ -1,181 +1,286 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.cables = {}
|
||||
local cable_tier = {}
|
||||
|
||||
function technic.register_cable(tier, size)
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
for x1 = 0, 1 do
|
||||
for x2 = 0, 1 do
|
||||
for y1 = 0, 1 do
|
||||
for y2 = 0, 1 do
|
||||
for z1 = 0, 1 do
|
||||
for z2 = 0, 1 do
|
||||
local id = technic.get_cable_id({x1, x2, y1, y2, z1, z2})
|
||||
|
||||
technic.cables["technic:"..ltier.."_cable"..id] = tier
|
||||
|
||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
|
||||
if id ~= 0 then
|
||||
groups.not_in_creative_inventory = 1
|
||||
function technic.is_tier_cable(name, tier)
|
||||
return cable_tier[name] == tier
|
||||
end
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_cable"..id, {
|
||||
description = S("%s Cable"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_cable.png"},
|
||||
inventory_image = "technic_"..ltier.."_cable_wield.png",
|
||||
wield_image = "technic_"..ltier.."_cable_wield.png",
|
||||
groups = groups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:"..ltier.."_cable0",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = technic.gen_cable_nodebox(x1, y1, z1, x2, y2, z2, size)
|
||||
},
|
||||
on_construct = function()
|
||||
technic.networks = {}
|
||||
end,
|
||||
on_destruct = function()
|
||||
technic.networks = {}
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
technic.update_cables(pos, technic.get_cable_tier(node.name))
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode)
|
||||
local tier = technic.get_cable_tier(oldnode.name)
|
||||
technic.update_cables(pos, tier, true)
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function technic.get_cable_tier(name)
|
||||
return cable_tier[name]
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_placenode(function(pos, node)
|
||||
for tier, machine_list in pairs(technic.machines) do
|
||||
for machine_name, _ in pairs(machine_list) do
|
||||
if node.name == machine_name then
|
||||
technic.update_cables(pos, tier, true)
|
||||
technic.networks = {}
|
||||
return
|
||||
local function check_connections(pos)
|
||||
-- Build a table of all machines
|
||||
local machines = {}
|
||||
for tier,list in pairs(technic.machines) do
|
||||
for k,v in pairs(list) do
|
||||
machines[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
minetest.register_on_dignode(function(pos, node)
|
||||
for tier, machine_list in pairs(technic.machines) do
|
||||
for machine_name, _ in pairs(machine_list) do
|
||||
if node.name == machine_name then
|
||||
technic.update_cables(pos, tier, true)
|
||||
technic.networks = {}
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
function technic.get_cable_id(links)
|
||||
return (links[6] * 1) + (links[5] * 2)
|
||||
+ (links[4] * 4) + (links[3] * 8)
|
||||
+ (links[2] * 16) + (links[1] * 32)
|
||||
end
|
||||
|
||||
function technic.update_cables(pos, tier, no_set, secondrun)
|
||||
local link_positions = {
|
||||
local connections = {}
|
||||
local positions = {
|
||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
||||
{x=pos.x, y=pos.y+1, z=pos.z},
|
||||
{x=pos.x, y=pos.y-1, z=pos.z},
|
||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||
{x=pos.x, y=pos.y, z=pos.z-1}}
|
||||
|
||||
local links = {0, 0, 0, 0, 0, 0}
|
||||
|
||||
for i, link_pos in pairs(link_positions) do
|
||||
local connect_type = technic.cables_should_connect(pos, link_pos, tier)
|
||||
if connect_type then
|
||||
links[i] = 1
|
||||
-- Have cables next to us update theirselves,
|
||||
-- but only once. (We don't want to update the entire
|
||||
-- network or start an infinite loop of updates)
|
||||
if not secondrun and connect_type == "cable" then
|
||||
technic.update_cables(link_pos, tier, false, true)
|
||||
for _,connected_pos in pairs(positions) do
|
||||
local name = minetest.get_node(connected_pos).name
|
||||
if machines[name] or technic.get_cable_tier(name) then
|
||||
table.insert(connections,connected_pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- We don't want to set ourselves if we have been removed or we are
|
||||
-- updating a machine
|
||||
if not no_set then
|
||||
minetest.set_node(pos, {name="technic:"..string.lower(tier)
|
||||
.."_cable"..technic.get_cable_id(links)})
|
||||
|
||||
end
|
||||
return connections
|
||||
end
|
||||
|
||||
|
||||
function technic.is_tier_cable(name, tier)
|
||||
return technic.cables[name] and technic.cables[name] == tier
|
||||
local function clear_networks(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local placed = node.name ~= "air"
|
||||
local positions = check_connections(pos)
|
||||
if #positions < 1 then return end
|
||||
local dead_end = #positions == 1
|
||||
for _,connected_pos in pairs(positions) do
|
||||
local net = technic.cables[minetest.hash_node_position(connected_pos)]
|
||||
if net and technic.networks[net] then
|
||||
if dead_end and placed then
|
||||
-- Dead end placed, add it to the network
|
||||
-- Get the network
|
||||
local network_id = technic.cables[minetest.hash_node_position(positions[1])]
|
||||
if not network_id then
|
||||
-- We're evidently not on a network, nothing to add ourselves to
|
||||
return
|
||||
end
|
||||
local sw_pos = minetest.get_position_from_hash(network_id)
|
||||
sw_pos.y = sw_pos.y + 1
|
||||
local network = technic.networks[network_id]
|
||||
local tier = network.tier
|
||||
|
||||
|
||||
function technic.get_cable_tier(name)
|
||||
return technic.cables[name]
|
||||
end
|
||||
|
||||
|
||||
function technic.cables_should_connect(pos1, pos2, tier)
|
||||
local name = minetest.get_node(pos2).name
|
||||
|
||||
-- Actually add it to the (cached) network
|
||||
-- This is similar to check_node_subp
|
||||
technic.cables[minetest.hash_node_position(pos)] = network_id
|
||||
pos.visited = 1
|
||||
if technic.is_tier_cable(name, tier) then
|
||||
return "cable"
|
||||
elseif technic.machines[tier][name] then
|
||||
return "machine"
|
||||
table.insert(network.all_nodes,pos)
|
||||
elseif technic.machines[tier][node.name] then
|
||||
meta:set_string(tier.."_network",minetest.pos_to_string(sw_pos))
|
||||
if technic.machines[tier][node.name] == technic.producer then
|
||||
table.insert(network.PR_nodes,pos)
|
||||
elseif technic.machines[tier][node.name] == technic.receiver then
|
||||
table.insert(network.RE_nodes,pos)
|
||||
elseif technic.machines[tier][node.name] == technic.producer_receiver then
|
||||
table.insert(network.PR_nodes,pos)
|
||||
table.insert(network.RE_nodes,pos)
|
||||
elseif technic.machines[tier][node.name] == "SPECIAL" and
|
||||
(pos.x ~= sw_pos.x or pos.y ~= sw_pos.y or pos.z ~= sw_pos.z) and
|
||||
from_below then
|
||||
table.insert(network.SP_nodes,pos)
|
||||
elseif technic.machines[tier][node.name] == technic.battery then
|
||||
table.insert(network.BA_nodes,pos)
|
||||
end
|
||||
return false
|
||||
end
|
||||
elseif dead_end and not placed then
|
||||
-- Dead end removed, remove it from the network
|
||||
-- Get the network
|
||||
local network_id = technic.cables[minetest.hash_node_position(positions[1])]
|
||||
if not network_id then
|
||||
-- We're evidently not on a network, nothing to add ourselves to
|
||||
return
|
||||
end
|
||||
local network = technic.networks[network_id]
|
||||
|
||||
-- Search for and remove machine
|
||||
technic.cables[minetest.hash_node_position(pos)] = nil
|
||||
for tblname,table in pairs(network) do
|
||||
if tblname ~= "tier" then
|
||||
for machinenum,machine in pairs(table) do
|
||||
if machine.x == pos.x
|
||||
and machine.y == pos.y
|
||||
and machine.z == pos.z then
|
||||
table[machinenum] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Not a dead end, so the whole network needs to be recalculated
|
||||
for _,v in pairs(technic.networks[net].all_nodes) do
|
||||
local pos1 = minetest.hash_node_position(v)
|
||||
technic.cables[pos1] = nil
|
||||
end
|
||||
technic.networks[net] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function technic.register_cable(tier, size)
|
||||
local ltier = string.lower(tier)
|
||||
cable_tier["technic:"..ltier.."_cable"] = tier
|
||||
|
||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
["technic_"..ltier.."_cable"] = 1}
|
||||
|
||||
local node_box = {
|
||||
type = "connected",
|
||||
fixed = {-size, -size, -size, size, size, size},
|
||||
connect_top = {-size, -size, -size, size, 0.5, size}, -- y+
|
||||
connect_bottom = {-size, -0.5, -size, size, size, size}, -- y-
|
||||
connect_front = {-size, -size, -0.5, size, size, size}, -- z-
|
||||
connect_back = {-size, -size, size, size, size, 0.5 }, -- z+
|
||||
connect_left = {-0.5, -size, -size, size, size, size}, -- x-
|
||||
connect_right = {-size, -size, -size, 0.5, size, size}, -- x+
|
||||
}
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_cable", {
|
||||
description = S("%s Cable"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_cable.png"},
|
||||
inventory_image = "technic_"..ltier.."_cable_wield.png",
|
||||
wield_image = "technic_"..ltier.."_cable_wield.png",
|
||||
groups = groups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:"..ltier.."_cable",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
node_box = node_box,
|
||||
connects_to = {"group:technic_"..ltier.."_cable",
|
||||
"group:technic_"..ltier, "group:technic_all_tiers"},
|
||||
on_construct = clear_networks,
|
||||
on_destruct = clear_networks,
|
||||
})
|
||||
|
||||
local xyz = {
|
||||
["-x"] = 1,
|
||||
["-y"] = 2,
|
||||
["-z"] = 3,
|
||||
["x"] = 4,
|
||||
["y"] = 5,
|
||||
["z"] = 6,
|
||||
}
|
||||
local notconnects = {
|
||||
[1] = "left",
|
||||
[2] = "bottom",
|
||||
[3] = "front",
|
||||
[4] = "right",
|
||||
[5] = "top",
|
||||
[6] = "back",
|
||||
}
|
||||
local function s(p)
|
||||
if p:find("-") then
|
||||
return p:sub(2)
|
||||
else
|
||||
return "-"..p
|
||||
end
|
||||
end
|
||||
for p, i in pairs(xyz) do
|
||||
local def = {
|
||||
description = S("%s Cable Plate"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_cable.png"},
|
||||
groups = table.copy(groups),
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:"..ltier.."_cable_plate_1",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
node_box = table.copy(node_box),
|
||||
connects_to = {"group:technic_"..ltier.."_cable",
|
||||
"group:technic_"..ltier, "group:technic_all_tiers"},
|
||||
on_construct = clear_networks,
|
||||
on_destruct = clear_networks,
|
||||
}
|
||||
def.node_box.fixed = {
|
||||
{-size, -size, -size, size, size, size},
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
}
|
||||
def.node_box.fixed[1][xyz[p]] = 7/16 * (i-3.5)/math.abs(i-3.5)
|
||||
def.node_box.fixed[2][xyz[s(p)]] = 3/8 * (i-3.5)/math.abs(i-3.5)
|
||||
def.node_box["connect_"..notconnects[i]] = nil
|
||||
if i == 1 then
|
||||
def.on_place = function(itemstack, placer, pointed_thing)
|
||||
local pointed_thing_diff = vector.subtract(pointed_thing.above, pointed_thing.under)
|
||||
local num
|
||||
local changed
|
||||
for k, v in pairs(pointed_thing_diff) do
|
||||
if v ~= 0 then
|
||||
changed = k
|
||||
num = xyz[s(tostring(v):sub(-2, -2)..k)]
|
||||
break
|
||||
end
|
||||
end
|
||||
local crtl = placer:get_player_control()
|
||||
if (crtl.aux1 or crtl.sneak) and not (crtl.aux1 and crtl.sneak) then
|
||||
local fine_pointed = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
|
||||
fine_pointed = vector.subtract(fine_pointed, pointed_thing.above)
|
||||
fine_pointed[changed] = nil
|
||||
local ps = {}
|
||||
for p, _ in pairs(fine_pointed) do
|
||||
ps[#ps+1] = p
|
||||
end
|
||||
local bigger = (math.abs(fine_pointed[ps[1]]) > math.abs(fine_pointed[ps[2]]) and ps[1]) or ps[2]
|
||||
if math.abs(fine_pointed[bigger]) < 0.3 then
|
||||
num = num + 3
|
||||
num = (num <= 6 and num) or num - 6
|
||||
else
|
||||
num = xyz[((fine_pointed[bigger] < 0 and "-") or "") .. bigger]
|
||||
end
|
||||
end
|
||||
minetest.set_node(pointed_thing.above, {name = "technic:"..ltier.."_cable_plate_"..num})
|
||||
if not (creative and creative.is_enabled_for(placer)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
else
|
||||
def.groups.not_in_creative_inventory = 1
|
||||
end
|
||||
def.on_rotate = function(pos, node, user, mode, new_param2)
|
||||
local dir = 0
|
||||
if mode == screwdriver.ROTATE_FACE then -- left-click
|
||||
dir = 1
|
||||
elseif mode == screwdriver.ROTATE_AXIS then -- right-click
|
||||
dir = -1
|
||||
end
|
||||
local num = tonumber(node.name:sub(-1))
|
||||
num = num + dir
|
||||
num = (num >= 1 and num) or num + 6
|
||||
num = (num <= 6 and num) or num - 6
|
||||
minetest.swap_node(pos, {name = "technic:"..ltier.."_cable_plate_"..num})
|
||||
end
|
||||
minetest.register_node("technic:"..ltier.."_cable_plate_"..i, def)
|
||||
cable_tier["technic:"..ltier.."_cable_plate_"..i] = tier
|
||||
end
|
||||
|
||||
local c = "technic:"..ltier.."_cable"
|
||||
minetest.register_craft({
|
||||
output = "technic:"..ltier.."_cable_plate_1 5",
|
||||
recipe = {
|
||||
{"", "", c},
|
||||
{c , c , c},
|
||||
{"", "", c},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = c,
|
||||
recipe = {
|
||||
{"technic:"..ltier.."_cable_plate_1"},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
function technic.gen_cable_nodebox(x1, y1, z1, x2, y2, z2, size)
|
||||
-- Nodeboxes
|
||||
local box_center = {-size, -size, -size, size, size, size}
|
||||
local box_y1 = {-size, -size, -size, size, 0.5, size} -- y+
|
||||
local box_x1 = {-size, -size, -size, 0.5, size, size} -- x+
|
||||
local box_z1 = {-size, -size, size, size, size, 0.5} -- z+
|
||||
local box_z2 = {-size, -size, -0.5, size, size, size} -- z-
|
||||
local box_y2 = {-size, -0.5, -size, size, size, size} -- y-
|
||||
local box_x2 = {-0.5, -size, -size, size, size, size} -- x-
|
||||
|
||||
local box = {box_center}
|
||||
if x1 == 1 then
|
||||
table.insert(box, box_x1)
|
||||
local function clear_nets_if_machine(pos, node)
|
||||
for tier, machine_list in pairs(technic.machines) do
|
||||
if machine_list[node.name] ~= nil then
|
||||
return clear_networks(pos)
|
||||
end
|
||||
if y1 == 1 then
|
||||
table.insert(box, box_y1)
|
||||
end
|
||||
if z1 == 1 then
|
||||
table.insert(box, box_z1)
|
||||
end
|
||||
if x2 == 1 then
|
||||
table.insert(box, box_x2)
|
||||
end
|
||||
if y2 == 1 then
|
||||
table.insert(box, box_y2)
|
||||
end
|
||||
if z2 == 1 then
|
||||
table.insert(box, box_z2)
|
||||
end
|
||||
return box
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(clear_nets_if_machine)
|
||||
minetest.register_on_dignode(clear_nets_if_machine)
|
||||
|
||||
|
8
technic/machines/register/centrifuge.lua
Normal file
8
technic/machines/register/centrifuge.lua
Normal file
@ -0,0 +1,8 @@
|
||||
local S = technic.getter
|
||||
|
||||
function technic.register_centrifuge(data)
|
||||
data.typename = "separating"
|
||||
data.machine_name = "centrifuge"
|
||||
data.machine_desc = S("%s Centrifuge")
|
||||
technic.register_base_machine(data)
|
||||
end
|
40
technic/machines/register/centrifuge_recipes.lua
Normal file
40
technic/machines/register/centrifuge_recipes.lua
Normal file
@ -0,0 +1,40 @@
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_recipe_type("separating", {
|
||||
description = S("Separating"),
|
||||
output_size = 2,
|
||||
})
|
||||
|
||||
function technic.register_separating_recipe(data)
|
||||
data.time = data.time or 10
|
||||
technic.register_recipe("separating", data)
|
||||
end
|
||||
|
||||
local recipes = {
|
||||
{ "technic:bronze_dust 4", "technic:copper_dust 3", "technic:tin_dust" },
|
||||
{ "technic:stainless_steel_dust 4", "technic:wrought_iron_dust 3", "technic:chromium_dust" },
|
||||
{ "technic:brass_dust 3", "technic:copper_dust 2", "technic:zinc_dust" },
|
||||
{ "technic:chernobylite_dust", "default:sand", "technic:uranium3_dust" },
|
||||
{ "default:dirt 4", "default:sand", "default:gravel", "default:clay_lump 2" },
|
||||
}
|
||||
|
||||
local function uranium_dust(p)
|
||||
return "technic:uranium"..(p == 7 and "" or p).."_dust"
|
||||
end
|
||||
for p = 1, 34 do
|
||||
table.insert(recipes, { uranium_dust(p).." 2", uranium_dust(p-1), uranium_dust(p+1) })
|
||||
end
|
||||
|
||||
if minetest.get_modpath("bushes_classic") then
|
||||
for _, berry in ipairs({ "blackberry", "blueberry", "gooseberry", "raspberry", "strawberry" }) do
|
||||
table.insert(recipes, { "bushes:"..berry.."_bush", "default:stick 20", "bushes:"..berry.." 4" })
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("farming") then
|
||||
table.insert(recipes, { "farming:wheat 4", "farming:seed_wheat 3", "default:dry_shrub 1" })
|
||||
end
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_separating_recipe({ input = { data[1] }, output = { data[2], data[3], data[4] } })
|
||||
end
|
@ -1,57 +1,83 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
-- handles the machine upgrades every tick
|
||||
function technic.handle_machine_upgrades(meta)
|
||||
-- Get the names of the upgrades
|
||||
local inv = meta:get_inventory()
|
||||
local upg_item1
|
||||
local upg_item2
|
||||
|
||||
local srcstack = inv:get_stack("upgrade1", 1)
|
||||
if srcstack then
|
||||
upg_item1 = srcstack:to_table()
|
||||
end
|
||||
local upg_item1 = srcstack and srcstack:get_name()
|
||||
|
||||
srcstack = inv:get_stack("upgrade2", 1)
|
||||
if srcstack then
|
||||
upg_item2 = srcstack:to_table()
|
||||
end
|
||||
local upg_item2 = srcstack and srcstack:get_name()
|
||||
|
||||
-- Save some power by installing battery upgrades.
|
||||
-- Tube loading speed can be upgraded using control logic units.
|
||||
local EU_upgrade = 0
|
||||
local tube_upgrade = 0
|
||||
if upg_item1 then
|
||||
if upg_item1.name == "technic:battery" then
|
||||
EU_upgrade = EU_upgrade + 1
|
||||
elseif upg_item1.name == "technic:control_logic_unit" then
|
||||
|
||||
if upg_item1 == "technic:control_logic_unit" then
|
||||
tube_upgrade = tube_upgrade + 1
|
||||
end
|
||||
end
|
||||
if upg_item2 then
|
||||
if upg_item2.name == "technic:battery" then
|
||||
elseif upg_item1 == "technic:battery" then
|
||||
EU_upgrade = EU_upgrade + 1
|
||||
elseif upg_item2.name == "technic:control_logic_unit" then
|
||||
end
|
||||
|
||||
if upg_item2 == "technic:control_logic_unit" then
|
||||
tube_upgrade = tube_upgrade + 1
|
||||
elseif upg_item2 == "technic:battery" then
|
||||
EU_upgrade = EU_upgrade + 1
|
||||
end
|
||||
end
|
||||
|
||||
return EU_upgrade, tube_upgrade
|
||||
end
|
||||
|
||||
-- handles the machine upgrades when set or removed
|
||||
local function on_machine_upgrade(meta, stack)
|
||||
local stack_name = stack:get_name()
|
||||
if stack_name == "default:chest" then
|
||||
meta:set_int("public", 1)
|
||||
return 1
|
||||
elseif stack_name ~= "technic:control_logic_unit"
|
||||
and stack_name ~= "technic:battery" then
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function technic.send_items(pos, x_velocity, z_velocity)
|
||||
-- something is about to be removed
|
||||
local function on_machine_downgrade(meta, stack, list)
|
||||
if stack:get_name() == "default:chest" then
|
||||
local inv = meta:get_inventory()
|
||||
local upg1, upg2 = inv:get_stack("upgrade1", 1), inv:get_stack("upgrade2", 1)
|
||||
|
||||
-- only set 0 if theres not a nother chest in the other list too
|
||||
if (not upg1 or not upg2 or upg1:get_name() ~= upg2:get_name()) then
|
||||
meta:set_int("public", 0)
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
function technic.send_items(pos, x_velocity, z_velocity, output_name)
|
||||
-- Send items on their way in the pipe system.
|
||||
if output_name == nil then
|
||||
output_name = "dst"
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local i = 0
|
||||
for _, stack in ipairs(inv:get_list("dst")) do
|
||||
for _, stack in ipairs(inv:get_list(output_name)) do
|
||||
i = i + 1
|
||||
if stack then
|
||||
local item0 = stack:to_table()
|
||||
if item0 then
|
||||
item0["count"] = "1"
|
||||
local item1 = tube_item({x=pos.x, y=pos.y, z=pos.z}, item0)
|
||||
item1:get_luaentity().start_pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
|
||||
item1:setacceleration({x=0, y=0, z=0})
|
||||
technic.tube_inject_item(pos, pos, vector.new(x_velocity, 0, z_velocity), item0)
|
||||
stack:take_item(1)
|
||||
inv:set_stack("dst", i, stack)
|
||||
inv:set_stack(output_name, i, stack)
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -65,21 +91,25 @@ function technic.smelt_item(meta, result, speed)
|
||||
if meta:get_int("cook_time") < result.time / speed then
|
||||
return
|
||||
end
|
||||
local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
|
||||
local result
|
||||
local afterfuel
|
||||
result, afterfuel = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
|
||||
|
||||
if result and result.item then
|
||||
meta:set_int("cook_time", 0)
|
||||
-- check if there's room for output in "dst" list
|
||||
if inv:room_for_item("dst", result.item) then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
inv:set_stack("src", 1, afterfuel.items[1])
|
||||
inv:add_item("dst", result.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
function technic.handle_machine_pipeworks(pos, tube_upgrade, send_function)
|
||||
if send_function == nil then
|
||||
send_function = technic.send_items
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
@ -94,18 +124,91 @@ function technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
if node.param2 == 0 then pos1.x = pos1.x + 1 x_velocity = 1 end
|
||||
|
||||
local output_tube_connected = false
|
||||
local meta1 = minetest.get_meta(pos1)
|
||||
if meta1:get_int("tubelike") == 1 then
|
||||
local node1 = minetest.get_node(pos1)
|
||||
if minetest.get_item_group(node1.name, "tubedevice") > 0 then
|
||||
output_tube_connected = true
|
||||
end
|
||||
tube_time = meta:get_int("tube_time")
|
||||
tube_time = tube_time + tube_upgrade
|
||||
if tube_time > 3 then
|
||||
local tube_time = meta:get_int("tube_time") + tube_upgrade
|
||||
if tube_time >= 2 then
|
||||
tube_time = 0
|
||||
if output_tube_connected then
|
||||
technic.send_items(pos, x_velocity, z_velocity)
|
||||
send_function(pos, x_velocity, z_velocity)
|
||||
end
|
||||
end
|
||||
meta:set_int("tube_time", tube_time)
|
||||
end
|
||||
|
||||
function technic.machine_can_dig(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
||||
if player then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
|
||||
if oldmetadata.inventory then
|
||||
if oldmetadata.inventory.upgrade1 and oldmetadata.inventory.upgrade1[1] then
|
||||
local stack = ItemStack(oldmetadata.inventory.upgrade1[1])
|
||||
if not stack:is_empty() then
|
||||
minetest.add_item(pos, stack)
|
||||
end
|
||||
end
|
||||
if oldmetadata.inventory.upgrade2 and oldmetadata.inventory.upgrade2[1] then
|
||||
local stack = ItemStack(oldmetadata.inventory.upgrade2[1])
|
||||
if not stack:is_empty() then
|
||||
minetest.add_item(pos, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.registered_nodes[oldnode.name].tube then
|
||||
pipeworks.after_dig(pos, oldnode, oldmetadata, player)
|
||||
end
|
||||
end
|
||||
|
||||
local function inv_change(pos, player, count, from_list, to_list, stack)
|
||||
local playername = player:get_player_name()
|
||||
local meta = minetest.get_meta(pos);
|
||||
local public = (meta:get_int("public") == 1)
|
||||
local to_upgrade = to_list == "upgrade1" or to_list == "upgrade2"
|
||||
local from_upgrade = from_list == "upgrade1" or from_list == "upgrade2"
|
||||
|
||||
if (not public or to_upgrade or from_upgrade) and minetest.is_protected(pos, playername) then
|
||||
minetest.chat_send_player(playername, S("Inventory move disallowed due to protection"))
|
||||
return 0
|
||||
end
|
||||
if to_upgrade then
|
||||
-- only place a single item into it, if it's empty
|
||||
local empty = meta:get_inventory():is_empty(to_list)
|
||||
if empty then
|
||||
return on_machine_upgrade(meta, stack)
|
||||
end
|
||||
return 0
|
||||
elseif from_upgrade then
|
||||
-- only called on take (not move)
|
||||
on_machine_downgrade(meta, stack, from_list)
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
function technic.machine_inventory_put(pos, listname, index, stack, player)
|
||||
return inv_change(pos, player, stack:get_count(), nil, listname, stack)
|
||||
end
|
||||
|
||||
function technic.machine_inventory_take(pos, listname, index, stack, player)
|
||||
return inv_change(pos, player, stack:get_count(), listname, nil, stack)
|
||||
end
|
||||
|
||||
function technic.machine_inventory_move(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
local stack = minetest.get_meta(pos):get_inventory():get_stack(from_list, from_index)
|
||||
return inv_change(pos, player, count, from_list, to_list, stack)
|
||||
end
|
||||
|
||||
|
9
technic/machines/register/compressor.lua
Normal file
9
technic/machines/register/compressor.lua
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
function technic.register_compressor(data)
|
||||
data.typename = "compressing"
|
||||
data.machine_name = "compressor"
|
||||
data.machine_desc = S("%s Compressor")
|
||||
technic.register_base_machine(data)
|
||||
end
|
34
technic/machines/register/compressor_recipes.lua
Normal file
34
technic/machines/register/compressor_recipes.lua
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_recipe_type("compressing", { description = S("Compressing") })
|
||||
|
||||
function technic.register_compressor_recipe(data)
|
||||
data.time = data.time or 4
|
||||
technic.register_recipe("compressing", data)
|
||||
end
|
||||
|
||||
local recipes = {
|
||||
{"default:snowblock", "default:ice"},
|
||||
{"default:sand 2", "default:sandstone"},
|
||||
{"default:desert_sand", "default:desert_stone"},
|
||||
{"technic:mixed_metal_ingot", "technic:composite_plate"},
|
||||
{"default:copper_ingot 5", "technic:copper_plate"},
|
||||
{"technic:coal_dust 4", "technic:graphite"},
|
||||
{"technic:carbon_cloth", "technic:carbon_plate"},
|
||||
{"technic:uranium35_ingot 5", "technic:uranium_fuel"},
|
||||
}
|
||||
|
||||
-- defuse the default sandstone recipe, since we have the compressor to take over in a more realistic manner
|
||||
minetest.clear_craft({
|
||||
output = "default:sandstone",
|
||||
recipe = {
|
||||
{'group:sand', 'group:sand'},
|
||||
{'group:sand', 'group:sand'}
|
||||
},
|
||||
})
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_compressor_recipe({input = {data[1]}, output = data[2]})
|
||||
end
|
||||
|
@ -2,199 +2,8 @@
|
||||
local S = technic.getter
|
||||
|
||||
function technic.register_electric_furnace(data)
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
local tube_side_texture = data.tube and "technic_"..ltier.."_electric_furnace_side_tube.png"
|
||||
or "technic_"..ltier.."_electric_furnace_side.png"
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src",stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
}
|
||||
|
||||
local formspec =
|
||||
"invsize[8,10;]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,6;8,4;]"..
|
||||
"label[0,0;"..S("%s Electric Furnace"):format(tier).."]"
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[current_name;upgrade1;1,4;1,1;]"..
|
||||
"list[current_name;upgrade2;2,4;1,1;]"..
|
||||
"label[1,5;Upgrade Slots]"
|
||||
data.typename = "cooking"
|
||||
data.machine_name = "electric_furnace"
|
||||
data.machine_desc = S("%s Furnace")
|
||||
technic.register_base_machine(data)
|
||||
end
|
||||
|
||||
data.formspec = formspec
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_electric_furnace", {
|
||||
description = S("%s Electric furnace"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_electric_furnace_top.png",
|
||||
"technic_"..ltier.."_electric_furnace_bottom.png",
|
||||
tube_side_texture,
|
||||
tube_side_texture,
|
||||
"technic_"..ltier.."_electric_furnace_side.png",
|
||||
"technic_"..ltier.."_electric_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, tubedevice=1, tubedevice_receiver=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
tube = tube,
|
||||
technic = data,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
local data = minetest.registered_nodes[name].technic
|
||||
meta:set_string("infotext", S("%s Electric furnace"):format(data.tier))
|
||||
meta:set_int("tube_time", 0)
|
||||
meta:set_string("formspec", data.formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
||||
not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_electric_furnace_active", {
|
||||
description = tier.." Electric furnace",
|
||||
tiles = {"technic_"..ltier.."_electric_furnace_top.png",
|
||||
"technic_"..ltier.."_electric_furnace_bottom.png",
|
||||
tube_side_texture,
|
||||
tube_side_texture,
|
||||
"technic_"..ltier.."_electric_furnace_side.png",
|
||||
"technic_"..ltier.."_electric_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, tubedevice=1, tubedevice_receiver=1, not_in_creative_inventory=1},
|
||||
light_source = 8,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
tube = tube,
|
||||
technic = data,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
local data = minetest.registered_nodes[name].technic
|
||||
meta:set_string("infotext", S("%s Electric furnace", data.tier))
|
||||
meta:set_int("tube_time", 0)
|
||||
meta:set_string("formspec", data.formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
||||
not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
-- These three makes sure upgrades are not moved in or out while the furnace is active.
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if listname == "src" or listname == "dst" then
|
||||
return stack:get_stack_max()
|
||||
else
|
||||
return 0 -- Disallow the move
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if listname == "src" or listname == "dst" then
|
||||
return stack:get_stack_max()
|
||||
else
|
||||
return 0 -- Disallow the move
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:"..ltier.."_electric_furnace",
|
||||
"technic:"..ltier.."_electric_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local data = minetest.registered_nodes[node.name].technic
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int(data.tier.."_EU_input")
|
||||
|
||||
-- Machine information
|
||||
local machine_name = S("%s Electric Furnace"):format(data.tier)
|
||||
local machine_node = "technic:"..string.lower(data.tier).."_electric_furnace"
|
||||
local machine_demand = data.demand
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, data.tier)
|
||||
|
||||
-- Check upgrade slots
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
if data.tube then
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
end
|
||||
|
||||
local result = minetest.get_craft_result({
|
||||
method = "cooking",
|
||||
width = 1,
|
||||
items = inv:get_list("src")})
|
||||
if not result or result.time == 0 or
|
||||
not inv:room_for_item("dst", result.item) then
|
||||
meta:set_int(data.tier.."_EU_demand", 0)
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < machine_demand[EU_upgrade+1] then
|
||||
-- Unpowered - go idle
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= machine_demand[EU_upgrade+1] then
|
||||
-- Powered
|
||||
hacky_swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
technic.smelt_item(meta, result, data.speed)
|
||||
|
||||
end
|
||||
meta:set_int(data.tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_electric_furnace", technic.receiver)
|
||||
technic.register_machine(tier, "technic:"..ltier.."_electric_furnace_active", technic.receiver)
|
||||
|
||||
end -- End registration
|
||||
|
||||
|
9
technic/machines/register/extractor.lua
Normal file
9
technic/machines/register/extractor.lua
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
function technic.register_extractor(data)
|
||||
data.typename = "extracting"
|
||||
data.machine_name = "extractor"
|
||||
data.machine_desc = S("%s Extractor")
|
||||
technic.register_base_machine(data)
|
||||
end
|
59
technic/machines/register/extractor_recipes.lua
Normal file
59
technic/machines/register/extractor_recipes.lua
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_recipe_type("extracting", { description = S("Extracting") })
|
||||
|
||||
function technic.register_extractor_recipe(data)
|
||||
data.time = data.time or 4
|
||||
technic.register_recipe("extracting", data)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("dye") then
|
||||
-- check if we are using dye or unifieddyes
|
||||
local unifieddyes = minetest.get_modpath("unifieddyes")
|
||||
|
||||
-- register recipes with the same crafting ratios as `dye` provides
|
||||
local dye_recipes = {
|
||||
{"technic:coal_dust", "dye:black 2"},
|
||||
{"default:grass_1", "dye:green 1"},
|
||||
{"default:dry_shrub", "dye:brown 1"},
|
||||
{"default:junglegrass", "dye:green 2"},
|
||||
{"default:cactus", "dye:green 4"},
|
||||
{"flowers:geranium", "dye:blue 4"},
|
||||
{"flowers:dandelion_white", "dye:white 4"},
|
||||
{"flowers:dandelion_yellow", "dye:yellow 4"},
|
||||
{"flowers:tulip", "dye:orange 4"},
|
||||
{"flowers:rose", "dye:red 4"},
|
||||
{"flowers:viola", "dye:violet 4"},
|
||||
{"bushes:blackberry", unifieddyes and "unifieddyes:magenta_s50 4" or "dye:violet 4"},
|
||||
{"bushes:blueberry", unifieddyes and "unifieddyes:magenta_s50 4" or "dye:magenta 4"},
|
||||
}
|
||||
|
||||
for _, data in ipairs(dye_recipes) do
|
||||
technic.register_extractor_recipe({input = {data[1]}, output = data[2]})
|
||||
end
|
||||
|
||||
-- overwrite the existing crafting recipes
|
||||
local dyes = {"white", "red", "yellow", "blue", "violet", "orange"}
|
||||
for _, color in ipairs(dyes) do
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "dye:"..color.." 1",
|
||||
recipe = {"group:flower,color_"..color},
|
||||
})
|
||||
|
||||
end
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "dye:black 1",
|
||||
recipe = {"group:coal"},
|
||||
})
|
||||
|
||||
if unifieddyes then
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "dye:green 1",
|
||||
recipe = {"default:cactus"},
|
||||
})
|
||||
end
|
||||
end
|
@ -1,82 +1,56 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
local tube_entry = "^pipeworks_tube_connection_metallic.png"
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
}
|
||||
|
||||
function technic.register_generator(data)
|
||||
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, ["technic_"..ltier]=1}
|
||||
if data.tube then
|
||||
groups.tubedevice = 1
|
||||
groups.tubedevice_receiver = 1
|
||||
end
|
||||
local active_groups = {not_in_creative_inventory = 1}
|
||||
for k, v in pairs(groups) do active_groups[k] = v end
|
||||
|
||||
local generator_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;"..S("%s Generator"):format(tier).."]"..
|
||||
"size[8,9;]"..
|
||||
"label[0,0;"..S("Fuel-Fired %s Generator"):format(tier).."]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"image[4,1;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[]"
|
||||
|
||||
local desc = S("%s Generator"):format(tier)
|
||||
minetest.register_node("technic:"..ltier.."_generator", {
|
||||
description = desc,
|
||||
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_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.get_meta(pos)
|
||||
meta:set_string("infotext", desc)
|
||||
meta:set_int(data.tier.."_EU_supply", 0)
|
||||
meta:set_int("burn_time", 0)
|
||||
meta:set_string("formspec", generator_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||
description = desc,
|
||||
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:"..ltier.."_generator",
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:"..ltier.."_generator", "technic:"..ltier.."_generator_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local desc = S("Fuel-Fired %s Generator"):format(tier)
|
||||
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local burn_time = meta:get_int("burn_time")
|
||||
local burn_totaltime = meta:get_int("burn_totaltime")
|
||||
-- If more to burn and the energy produced was used: produce some more
|
||||
if burn_time > 0 then
|
||||
meta:set_int(data.tier.."_EU_supply", data.supply)
|
||||
meta:set_int(tier.."_EU_supply", data.supply)
|
||||
burn_time = burn_time - 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
end
|
||||
@ -85,37 +59,235 @@ function technic.register_generator(data)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
local fuellist = inv:get_list("src")
|
||||
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
local fuel
|
||||
local afterfuel
|
||||
fuel, afterfuel = minetest.get_craft_result(
|
||||
{method = "fuel", width = 1,
|
||||
items = fuellist})
|
||||
if not fuel or fuel.time == 0 then
|
||||
meta:set_string("infotext", S("%s Out Of Fuel"):format(desc))
|
||||
hacky_swap_node(pos, "technic:"..ltier.."_generator")
|
||||
technic.swap_node(pos, "technic:"..ltier.."_generator")
|
||||
meta:set_int(tier.."_EU_supply", 0)
|
||||
return
|
||||
end
|
||||
meta:set_int("burn_time", fuel.time)
|
||||
meta:set_int("burn_totaltime", fuel.time)
|
||||
local stack = inv:get_stack("src", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("src", 1, stack)
|
||||
hacky_swap_node(pos, "technic:"..ltier.."_generator_active")
|
||||
meta:set_int(data.tier.."_EU_supply", data.supply)
|
||||
inv:set_stack("src", 1, afterfuel.items[1])
|
||||
technic.swap_node(pos, "technic:"..ltier.."_generator_active")
|
||||
meta:set_int(tier.."_EU_supply", data.supply)
|
||||
else
|
||||
hacky_swap_node(pos, "technic:"..ltier.."_generator")
|
||||
meta:set_int(data.tier.."_EU_supply", 0)
|
||||
technic.swap_node(pos, "technic:"..ltier.."_generator")
|
||||
meta:set_int(tier.."_EU_supply", 0)
|
||||
end
|
||||
end
|
||||
if burn_totaltime == 0 then burn_totaltime = 1 end
|
||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||
meta:set_string("infotext", desc.." ("..percent.."%)")
|
||||
|
||||
local form_buttons = ""
|
||||
if ltier ~= "lv" then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;Generator]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
"list[current_name;src;3, 1;1, 1;]"..
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]")
|
||||
end
|
||||
})
|
||||
technic.register_machine(data.tier, "technic:"..ltier.."_generator", technic.producer)
|
||||
technic.register_machine(data.tier, "technic:"..ltier.."_generator", technic.producer)
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]"..
|
||||
form_buttons
|
||||
)
|
||||
end
|
||||
|
||||
local tentry = tube_entry
|
||||
if ltier == "lv" then tentry = "" end
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_generator", {
|
||||
description = desc,
|
||||
tiles = {
|
||||
"technic_"..ltier.."_generator_top.png"..tentry,
|
||||
"technic_machine_bottom.png"..tentry,
|
||||
"technic_"..ltier.."_generator_side.png"..tentry,
|
||||
"technic_"..ltier.."_generator_side.png"..tentry,
|
||||
"technic_"..ltier.."_generator_side.png"..tentry,
|
||||
"technic_"..ltier.."_generator_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = groups,
|
||||
connect_sides = {"bottom", "back", "left", "right"},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
tube = data.tube and tube or nil,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_string("infotext", desc)
|
||||
meta:set_int(data.tier.."_EU_supply", 0)
|
||||
meta:set_int("burn_time", 0)
|
||||
meta:set_int("tube_time", 0)
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
meta:set_string("formspec", generator_formspec..form_buttons)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
after_place_node = data.tube and pipeworks.after_place,
|
||||
after_dig_node = technic.machine_after_dig_node,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local form = generator_formspec
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
meta:set_string("formspec", generator_formspec..form_buttons)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||
description = desc,
|
||||
tiles = {
|
||||
"technic_"..ltier.."_generator_top.png"..tube_entry,
|
||||
"technic_machine_bottom.png"..tube_entry,
|
||||
"technic_"..ltier.."_generator_side.png"..tube_entry,
|
||||
"technic_"..ltier.."_generator_side.png"..tube_entry,
|
||||
"technic_"..ltier.."_generator_side.png"..tube_entry,
|
||||
"technic_"..ltier.."_generator_front_active.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = active_groups,
|
||||
connect_sides = {"bottom"},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
tube = data.tube and tube or nil,
|
||||
drop = "technic:"..ltier.."_generator",
|
||||
can_dig = technic.machine_can_dig,
|
||||
after_dig_node = technic.machine_after_dig_node,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
technic_on_disable = function(pos, node)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1)
|
||||
end,
|
||||
on_timer = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
-- Connected back?
|
||||
if meta:get_int(tier.."_EU_timeout") > 0 then return false end
|
||||
|
||||
local burn_time = meta:get_int("burn_time") or 0
|
||||
|
||||
if burn_time <= 0 then
|
||||
meta:set_int(tier.."_EU_supply", 0)
|
||||
meta:set_int("burn_time", 0)
|
||||
technic.swap_node(pos, "technic:"..ltier.."_generator")
|
||||
return false
|
||||
end
|
||||
|
||||
local burn_totaltime = meta:get_int("burn_totaltime") or 0
|
||||
if burn_totaltime == 0 then burn_totaltime = 1 end
|
||||
burn_time = burn_time - 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
local percent = math.floor(burn_time / burn_totaltime * 100)
|
||||
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
"list[current_name;src;3, 1;1, 1;]"..
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]"..
|
||||
form_buttons
|
||||
)
|
||||
return true
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
|
||||
local burn_totaltime = meta:get_int("burn_totaltime") or 0
|
||||
local burn_time = meta:get_int("burn_time")
|
||||
local percent = math.floor(burn_time / burn_totaltime * 100)
|
||||
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
"list[current_name;src;3, 1;1, 1;]"..
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]"..
|
||||
form_buttons
|
||||
)
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer)
|
||||
technic.register_machine(tier, "technic:"..ltier.."_generator_active", technic.producer)
|
||||
end
|
||||
|
||||
|
@ -2,185 +2,8 @@
|
||||
local S = technic.getter
|
||||
|
||||
function technic.register_grinder(data)
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
}
|
||||
|
||||
local formspec =
|
||||
"invsize[8,10;]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,6;8,4;]"..
|
||||
"label[0,0;"..tier.." Grinder]"
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[current_name;upgrade1;1,4;1,1;]"..
|
||||
"list[current_name;upgrade2;2,4;1,1;]"..
|
||||
"label[1,5;Upgrade Slots]"
|
||||
data.typename = "grinding"
|
||||
data.machine_name = "grinder"
|
||||
data.machine_desc = S("%s Grinder")
|
||||
technic.register_base_machine(data)
|
||||
end
|
||||
data.formspec = formspec
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_grinder", {
|
||||
description = S("%s Grinder"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_grinder_top.png", "technic_"..ltier.."_grinder_bottom.png",
|
||||
"technic_"..ltier.."_grinder_side.png", "technic_"..ltier.."_grinder_side.png",
|
||||
"technic_"..ltier.."_grinder_side.png", "technic_"..ltier.."_grinder_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, tubedevice=1, tubedevice_receiver=1},
|
||||
technic = data,
|
||||
tube = tube,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local data = minetest.registered_nodes[node.name].technic
|
||||
meta:set_string("infotext", S("%s Grinder"):format(data.tier))
|
||||
meta:set_int("tube_time", 0)
|
||||
meta:set_string("formspec", data.formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
||||
not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_grinder_active",{
|
||||
description = S("%s Grinder"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_grinder_top.png", "technic_"..ltier.."_grinder_bottom.png",
|
||||
"technic_"..ltier.."_grinder_side.png", "technic_"..ltier.."_grinder_side.png",
|
||||
"technic_"..ltier.."_grinder_side.png", "technic_"..ltier.."_grinder_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, tubedevice=1, tubedevice_receiver=1, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
technic = data,
|
||||
tube = tube,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
||||
not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
S("Machine cannot be removed because it is not empty"))
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end,
|
||||
-- These three makes sure upgrades are not moved in or out while the grinder is active.
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if listname == "src" or listname == "dst" then
|
||||
return stack:get_stack_max()
|
||||
else
|
||||
return 0 -- Disallow the move
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if listname == "src" or listname == "dst" then
|
||||
return stack:get_stack_max()
|
||||
else
|
||||
return 0 -- Disallow the move
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:"..ltier.."_grinder","technic:"..ltier.."_grinder_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local data = minetest.registered_nodes[node.name].technic
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int(data.tier.."_EU_input")
|
||||
|
||||
local machine_name = S("%s Grinder"):format(data.tier)
|
||||
local machine_node = "technic:"..string.lower(data.tier).."_grinder"
|
||||
local machine_demand = data.demand
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int(data.tier.."_EU_demand", machine_demand[1])
|
||||
meta:set_int(data.tier.."_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, data.tier)
|
||||
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
if data.tube then
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
end
|
||||
|
||||
local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
|
||||
|
||||
if not result then
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int(data.tier.."_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < machine_demand[EU_upgrade+1] then
|
||||
-- Unpowered - go idle
|
||||
hacky_swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= machine_demand[EU_upgrade+1] then
|
||||
-- Powered
|
||||
hacky_swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") >= result.time / data.speed then
|
||||
meta:set_int("src_time", 0)
|
||||
local result_stack = ItemStack(result.output)
|
||||
if inv:room_for_item("dst", result_stack) then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
inv:add_item("dst", result_stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
meta:set_int(data.tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_grinder", technic.receiver)
|
||||
technic.register_machine(tier, "technic:"..ltier.."_grinder_active", technic.receiver)
|
||||
|
||||
end -- End registration
|
||||
|
||||
|
@ -1,73 +1,74 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
technic.grinder_recipes = {}
|
||||
technic.register_recipe_type("grinding", { description = S("Grinding") })
|
||||
|
||||
function technic.register_grinder_recipe(data)
|
||||
data.time = data.time or 3
|
||||
technic.grinder_recipes[data.input] = data
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "grinding",
|
||||
output = data.output,
|
||||
items = {data.input},
|
||||
width = 0,
|
||||
})
|
||||
end
|
||||
technic.register_recipe("grinding", data)
|
||||
end
|
||||
|
||||
-- Receive an ItemStack of result by an ItemStack input
|
||||
function technic.get_grinder_recipe(itemstack)
|
||||
return technic.grinder_recipes[itemstack:get_name()]
|
||||
end
|
||||
|
||||
-- Sorted alphebeticaly
|
||||
local recipes = {
|
||||
{"default:bronze_ingot", "technic:bronze_dust 1"},
|
||||
-- Dusts
|
||||
{"default:coal_lump", "technic:coal_dust 2"},
|
||||
{"default:cobble", "default:gravel"},
|
||||
{"default:copper_ingot", "technic:copper_dust 1"},
|
||||
{"default:copper_lump", "technic:copper_dust 2"},
|
||||
{"default:desert_stone", "default:desert_sand"},
|
||||
{"default:gold_ingot", "technic:gold_dust 1"},
|
||||
{"default:gold_lump", "technic:gold_dust 2"},
|
||||
{"default:gravel", "default:dirt"},
|
||||
{"default:iron_lump", "technic:iron_dust 2"},
|
||||
{"default:steel_ingot", "technic:iron_dust 1"},
|
||||
{"default:stone", "default:sand"},
|
||||
{"gloopores:alatro_lump", "technic:alatro_dust 2"},
|
||||
{"gloopores:kalite_lump", "technic:kalite_dust 2"},
|
||||
{"gloopores:arol_lump", "technic:arol_dust 2"},
|
||||
{"gloopores:talinite_lump", "technic:talinite_dust 2"},
|
||||
{"gloopores:akalin_lump", "technic:akalin_dust 2"},
|
||||
{"moreores:mithril_ingot", "technic:mithril_dust 1"},
|
||||
{"moreores:mithril_lump", "technic:mithril_dust 2"},
|
||||
{"moreores:silver_ingot", "technic:silver_dust 1"},
|
||||
{"moreores:silver_lump", "technic:silver_dust 2"},
|
||||
{"moreores:tin_ingot", "technic:tin_dust 1"},
|
||||
{"moreores:tin_lump", "technic:tin_dust 2"},
|
||||
{"technic:chromium_ingot", "technic:chromium_dust 1"},
|
||||
{"default:iron_lump", "technic:wrought_iron_dust 2"},
|
||||
{"default:tin_lump", "technic:tin_dust 2"},
|
||||
{"technic:chromium_lump", "technic:chromium_dust 2"},
|
||||
{"technic:zinc_ingot", "technic:zinc_dust 1"},
|
||||
{"technic:uranium_lump", "technic:uranium_dust 2"},
|
||||
{"technic:zinc_lump", "technic:zinc_dust 2"},
|
||||
{"technic:brass_ingot", "technic:brass_dust 1"},
|
||||
{"technic:lead_lump", "technic:lead_dust 2"},
|
||||
{"technic:sulfur_lump", "technic:sulfur_dust 2"},
|
||||
{"default:stone", "technic:stone_dust"},
|
||||
{"default:sand", "technic:stone_dust"},
|
||||
|
||||
-- Other
|
||||
{"default:cobble", "default:gravel"},
|
||||
{"default:gravel", "default:sand"},
|
||||
{"default:sandstone", "default:sand 2"}, -- reverse recipe can be found in the compressor
|
||||
}
|
||||
|
||||
-- defuse the sandstone -> 4 sand recipe to avoid infinite sand bugs (also consult the inverse compressor recipe)
|
||||
minetest.clear_craft({
|
||||
recipe = {
|
||||
{'default:sandstone'}
|
||||
},
|
||||
})
|
||||
|
||||
if minetest.get_modpath("farming") then
|
||||
table.insert(recipes, {"farming:seed_wheat", "farming:flour 1"})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("moreores") then
|
||||
table.insert(recipes, {"moreores:mithril_lump", "technic:mithril_dust 2"})
|
||||
table.insert(recipes, {"moreores:silver_lump", "technic:silver_dust 2"})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then
|
||||
table.insert(recipes, {"gloopores:alatro_lump", "technic:alatro_dust 2"})
|
||||
table.insert(recipes, {"gloopores:kalite_lump", "technic:kalite_dust 2"})
|
||||
table.insert(recipes, {"gloopores:arol_lump", "technic:arol_dust 2"})
|
||||
table.insert(recipes, {"gloopores:talinite_lump", "technic:talinite_dust 2"})
|
||||
table.insert(recipes, {"gloopores:akalin_lump", "technic:akalin_dust 2"})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("homedecor") then
|
||||
table.insert(recipes, {"home_decor:brass_ingot", "technic:brass_dust 1"})
|
||||
end
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_grinder_recipe({input=data[1], output=data[2]})
|
||||
technic.register_grinder_recipe({input = {data[1]}, output = data[2]})
|
||||
end
|
||||
|
||||
-- dusts
|
||||
local function register_dust(name, ingot)
|
||||
local lname = string.lower(name)
|
||||
lname = string.gsub(lname, ' ', '_')
|
||||
minetest.register_craftitem("technic:"..lname.."_dust", {
|
||||
description = S("%s Dust"):format(S(name)),
|
||||
inventory_image = "technic_"..lname.."_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
if ingot then
|
||||
minetest.register_craft({
|
||||
@ -75,26 +76,71 @@ local function register_dust(name, ingot)
|
||||
recipe = "technic:"..lname.."_dust",
|
||||
output = ingot,
|
||||
})
|
||||
technic.register_grinder_recipe({ input = {ingot}, output = "technic:"..lname.."_dust 1" })
|
||||
end
|
||||
end
|
||||
|
||||
-- Sorted alphibeticaly
|
||||
register_dust("Akalin", "glooptest:akalin_ingot")
|
||||
register_dust("Alatro", "glooptest:alatro_ingot")
|
||||
register_dust("Arol", "glooptest:arol_ingot")
|
||||
register_dust("Brass", "technic:brass_ingot")
|
||||
register_dust("Bronze", "default:bronze_ingot")
|
||||
register_dust("Carbon Steel", "technic:carbon_steel_ingot")
|
||||
register_dust("Cast Iron", "technic:cast_iron_ingot")
|
||||
register_dust("Chernobylite", "technic:chernobylite_block")
|
||||
register_dust("Chromium", "technic:chromium_ingot")
|
||||
register_dust("Coal", nil)
|
||||
register_dust("Copper", "default:copper_ingot")
|
||||
register_dust("Lead", "technic:lead_ingot")
|
||||
register_dust("Gold", "default:gold_ingot")
|
||||
register_dust("Iron", "default:steel_ingot")
|
||||
register_dust("Mithril", "moreores:mithril_ingot")
|
||||
register_dust("Silver", "moreores:silver_ingot")
|
||||
register_dust("Stainless Steel", "technic:stainless_steel_ingot")
|
||||
register_dust("Talinite", "glooptest:talinite_ingot")
|
||||
register_dust("Tin", "moreores:tin_ingot")
|
||||
register_dust("Stone", "default:stone")
|
||||
register_dust("Sulfur", nil)
|
||||
register_dust("Tin", "default:tin_ingot")
|
||||
register_dust("Wrought Iron", "technic:wrought_iron_ingot")
|
||||
register_dust("Zinc", "technic:zinc_ingot")
|
||||
if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then
|
||||
register_dust("Akalin", "glooptest:akalin_ingot")
|
||||
register_dust("Alatro", "glooptest:alatro_ingot")
|
||||
register_dust("Arol", "glooptest:arol_ingot")
|
||||
register_dust("Kalite", nil)
|
||||
register_dust("Talinite", "glooptest:talinite_ingot")
|
||||
end
|
||||
|
||||
for p = 0, 35 do
|
||||
local nici = (p ~= 0 and p ~= 7 and p ~= 35) and 1 or nil
|
||||
local psuffix = p == 7 and "" or p
|
||||
local ingot = "technic:uranium"..psuffix.."_ingot"
|
||||
local dust = "technic:uranium"..psuffix.."_dust"
|
||||
minetest.register_craftitem(dust, {
|
||||
description = S("%s Dust"):format(string.format(S("%.1f%%-Fissile Uranium"), p/10)),
|
||||
inventory_image = "technic_uranium_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
groups = {uranium_dust=1, not_in_creative_inventory=nici},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
recipe = dust,
|
||||
output = ingot,
|
||||
})
|
||||
technic.register_grinder_recipe({ input = {ingot}, output = dust })
|
||||
end
|
||||
|
||||
local function uranium_dust(p)
|
||||
return "technic:uranium"..(p == 7 and "" or p).."_dust"
|
||||
end
|
||||
for pa = 0, 34 do
|
||||
for pb = pa+1, 35 do
|
||||
local pc = (pa+pb)/2
|
||||
if pc == math.floor(pc) then
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
recipe = { uranium_dust(pa), uranium_dust(pb) },
|
||||
output = uranium_dust(pc).." 2",
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
@ -102,3 +148,10 @@ minetest.register_craft({
|
||||
burntime = 50,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "technic:kalite_dust",
|
||||
burntime = 37.5,
|
||||
})
|
||||
end
|
||||
|
62
technic/machines/register/grindings.lua
Normal file
62
technic/machines/register/grindings.lua
Normal file
@ -0,0 +1,62 @@
|
||||
local S = technic.getter
|
||||
local moretrees = minetest.get_modpath("moretrees")
|
||||
local mesecons_materials = minetest.get_modpath("mesecons_materials")
|
||||
local dye = minetest.get_modpath("dye")
|
||||
|
||||
-- sawdust, the finest wood/tree grinding
|
||||
local sawdust = "technic:sawdust"
|
||||
minetest.register_craftitem(sawdust, {
|
||||
description = S("Sawdust"),
|
||||
inventory_image = "technic_sawdust.png",
|
||||
})
|
||||
minetest.register_craft({ type = "fuel", recipe = sawdust, burntime = 6 })
|
||||
technic.register_compressor_recipe({ input = {sawdust .. " 4"}, output = "default:wood" })
|
||||
|
||||
-- tree/wood grindings
|
||||
local function register_tree_grinding(name, tree, wood, extract, grinding_color)
|
||||
local lname = string.lower(name)
|
||||
lname = string.gsub(lname, ' ', '_')
|
||||
local grindings_name = "technic:"..lname.."_grindings"
|
||||
local inventory_image = "technic_"..lname.."_grindings.png"
|
||||
if grinding_color then
|
||||
inventory_image = inventory_image .. "^[colorize:" .. grinding_color
|
||||
end
|
||||
minetest.register_craftitem(grindings_name, {
|
||||
description = S("%s Grinding"):format(S(name)),
|
||||
inventory_image = inventory_image,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = grindings_name,
|
||||
burntime = 8,
|
||||
})
|
||||
technic.register_grinder_recipe({ input = { tree }, output = grindings_name .. " 4" })
|
||||
technic.register_grinder_recipe({ input = { grindings_name }, output = sawdust .. " 4" })
|
||||
if wood then
|
||||
technic.register_grinder_recipe({ input = { wood }, output = grindings_name })
|
||||
end
|
||||
if extract then
|
||||
technic.register_extractor_recipe({ input = { grindings_name .. " 4" }, output = extract})
|
||||
technic.register_separating_recipe({
|
||||
input = { grindings_name .. " 4" },
|
||||
output = { sawdust .. " 4", extract }
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local rubber_tree_planks = moretrees and "moretrees:rubber_tree_planks"
|
||||
local default_extract = dye and "dye:brown 2"
|
||||
|
||||
local grinding_recipes = {
|
||||
{"Common Tree", "group:tree", "group:wood", default_extract },
|
||||
{"Rubber Tree", "moretrees:rubber_tree_trunk", rubber_tree_planks, "technic:raw_latex"}
|
||||
}
|
||||
|
||||
for _, data in pairs(grinding_recipes) do
|
||||
register_tree_grinding(unpack(data))
|
||||
end
|
||||
|
||||
if moretrees and dye then
|
||||
-- https://en.wikipedia.org/wiki/Catechu ancient brown dye from the wood of acacia trees
|
||||
register_tree_grinding("Acacia", "moretrees:acacia_trunk", "moretrees:acacia_planks", "dye:brown 8")
|
||||
end
|
@ -1,12 +1,33 @@
|
||||
local path = technic.modpath.."/machines/register"
|
||||
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/common.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/grinder_recipes.lua")
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
|
||||
-- API for machines
|
||||
dofile(path.."/recipes.lua")
|
||||
dofile(path.."/machine_base.lua")
|
||||
|
||||
-- Recipes
|
||||
dofile(path.."/alloy_recipes.lua")
|
||||
dofile(path.."/grinder_recipes.lua")
|
||||
dofile(path.."/extractor_recipes.lua")
|
||||
dofile(path.."/compressor_recipes.lua")
|
||||
dofile(path.."/centrifuge_recipes.lua")
|
||||
|
||||
-- Multi-Machine Recipes
|
||||
dofile(path.."/grindings.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
dofile(path.."/centrifuge.lua")
|
||||
|
265
technic/machines/register/machine_base.lua
Normal file
265
technic/machines/register/machine_base.lua
Normal file
@ -0,0 +1,265 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
local tube_entry = "^pipeworks_tube_connection_metallic.png"
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||
}
|
||||
|
||||
local connect_default = {"bottom", "back", "left", "right"}
|
||||
|
||||
local function round(v)
|
||||
return math.floor(v + 0.5)
|
||||
end
|
||||
|
||||
function technic.register_base_machine(data)
|
||||
local typename = data.typename
|
||||
local input_size = technic.recipes[typename].input_size
|
||||
local machine_name = data.machine_name
|
||||
local machine_desc = data.machine_desc
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
local groups = {cracky = 2, technic_machine = 1, ["technic_"..ltier] = 1}
|
||||
if data.tube then
|
||||
groups.tubedevice = 1
|
||||
groups.tubedevice_receiver = 1
|
||||
end
|
||||
local active_groups = {not_in_creative_inventory = 1}
|
||||
for k, v in pairs(groups) do active_groups[k] = v end
|
||||
|
||||
local formspec =
|
||||
"size[8,9;]"..
|
||||
"list[current_name;src;"..(4-input_size)..",1;"..input_size..",1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"label[0,0;"..machine_desc:format(tier).."]"..
|
||||
"listring[current_name;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;src]"..
|
||||
"listring[current_player;main]"
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[current_name;upgrade1;1,3;1,1;]"..
|
||||
"list[current_name;upgrade2;2,3;1,1;]"..
|
||||
"label[1,4;"..S("Upgrade Slots").."]"..
|
||||
"listring[current_name;upgrade1]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_name;upgrade2]"..
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int(tier.."_EU_input")
|
||||
|
||||
local machine_desc_tier = machine_desc:format(tier)
|
||||
local machine_node = "technic:"..ltier.."_"..machine_name
|
||||
local machine_demand = data.demand
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int(tier.."_EU_demand", machine_demand[1])
|
||||
meta:set_int(tier.."_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
if data.tube then
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
end
|
||||
|
||||
local powered = eu_input >= machine_demand[EU_upgrade+1]
|
||||
if powered then
|
||||
meta:set_int("src_time", meta:get_int("src_time") + round(data.speed*10))
|
||||
end
|
||||
while true do
|
||||
local result = technic.get_recipe(typename, inv:get_list("src"))
|
||||
if not result then
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_desc_tier))
|
||||
meta:set_int(tier.."_EU_demand", 0)
|
||||
meta:set_int("src_time", 0)
|
||||
return
|
||||
end
|
||||
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||
technic.swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_desc_tier))
|
||||
if meta:get_int("src_time") < round(result.time*10) then
|
||||
if not powered then
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_desc_tier))
|
||||
end
|
||||
return
|
||||
end
|
||||
local output = result.output
|
||||
if type(output) ~= "table" then output = { output } end
|
||||
local output_stacks = {}
|
||||
for _, o in ipairs(output) do
|
||||
table.insert(output_stacks, ItemStack(o))
|
||||
end
|
||||
local room_for_output = true
|
||||
inv:set_size("dst_tmp", inv:get_size("dst"))
|
||||
inv:set_list("dst_tmp", inv:get_list("dst"))
|
||||
for _, o in ipairs(output_stacks) do
|
||||
if not inv:room_for_item("dst_tmp", o) then
|
||||
room_for_output = false
|
||||
break
|
||||
end
|
||||
inv:add_item("dst_tmp", o)
|
||||
end
|
||||
if not room_for_output then
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_desc_tier))
|
||||
meta:set_int(tier.."_EU_demand", 0)
|
||||
meta:set_int("src_time", round(result.time*10))
|
||||
return
|
||||
end
|
||||
meta:set_int("src_time", meta:get_int("src_time") - round(result.time*10))
|
||||
inv:set_list("src", result.new_input)
|
||||
inv:set_list("dst", inv:get_list("dst_tmp"))
|
||||
end
|
||||
end
|
||||
|
||||
local tentry = tube_entry
|
||||
if ltier == "lv" then
|
||||
tentry = ""
|
||||
end
|
||||
minetest.register_node("technic:"..ltier.."_"..machine_name, {
|
||||
description = machine_desc:format(tier),
|
||||
tiles = {
|
||||
"technic_"..ltier.."_"..machine_name.."_top.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = groups,
|
||||
tube = data.tube and tube or nil,
|
||||
connect_sides = data.connect_sides or connect_default,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
|
||||
meta:set_string("infotext", machine_desc:format(tier))
|
||||
meta:set_int("tube_time", 0)
|
||||
meta:set_string("formspec", formspec..form_buttons)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", input_size)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
after_place_node = data.tube and pipeworks.after_place,
|
||||
after_dig_node = technic.machine_after_dig_node,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local node = minetest.get_node(pos)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
meta:set_string("formspec", formspec..form_buttons)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
|
||||
description = machine_desc:format(tier),
|
||||
tiles = {
|
||||
"technic_"..ltier.."_"..machine_name.."_top.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||
"technic_"..ltier.."_"..machine_name.."_front_active.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
drop = "technic:"..ltier.."_"..machine_name,
|
||||
groups = active_groups,
|
||||
connect_sides = data.connect_sides or connect_default,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
tube = data.tube and tube or nil,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
technic_disabled_machine_name = "technic:"..ltier.."_"..machine_name,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local node = minetest.get_node(pos)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local form_buttons = ""
|
||||
if not string.find(node.name, ":lv_") then
|
||||
form_buttons = fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
end
|
||||
meta:set_string("formspec", formspec..form_buttons)
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name, technic.receiver)
|
||||
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name.."_active", technic.receiver)
|
||||
|
||||
end -- End registration
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user