microexpansion/modules/power/ctrl.lua

93 lines
2.4 KiB
Lua
Raw Normal View History

2017-03-02 06:38:53 +01:00
-- power/ctrl.lua
2017-03-02 02:27:00 +01:00
local me = microexpansion
2019-05-01 13:20:09 +02:00
local power = me.power
2017-03-02 02:27:00 +01:00
-- [register node] Controller
me.register_node("ctrl", {
2019-05-01 13:20:09 +02:00
description = "ME Drive",
2017-07-25 19:47:25 +02:00
tiles = {
2017-03-02 02:27:00 +01:00
"ctrl_sides",
"ctrl_bottom",
"ctrl_sides",
"ctrl_sides",
"ctrl_sides",
"ctrl_sides"
},
2017-07-25 19:47:25 +02:00
drawtype = "nodebox",
paramtype = "light",
2017-03-02 02:27:00 +01:00
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.375, -0.375, 0.375, 0.375, 0.375}, -- Core
{0.1875, -0.5, -0.5, 0.5, 0.5, -0.1875}, -- Corner1
{-0.5, -0.5, -0.5, -0.1875, 0.5, -0.1875}, -- Corner2
{-0.5, -0.5, 0.1875, -0.1875, 0.5, 0.5}, -- Corner3
{0.1875, -0.5, 0.1875, 0.5, 0.5, 0.5}, -- Corner4
{-0.5, -0.4375, -0.5, 0.5, -0.1875, 0.5}, -- Bottom
{-0.5, 0.1875, -0.5, 0.5, 0.5, -0.1875}, -- Top1
{0.1875, 0.1875, -0.5, 0.5, 0.5, 0.5}, -- Top2
{-0.5, 0.1875, -0.5, -0.1875, 0.5, 0.5}, -- Top3
{-0.5, 0.1875, 0.1875, 0.5, 0.5, 0.5}, -- Top4
{-0.1875, -0.5, -0.1875, 0.1875, -0.25, 0.1875}, -- Bottom2
},
},
2017-07-25 19:47:25 +02:00
groups = { cracky = 1, me_connect = 1, },
connect_sides = "nobottom",
status = "unstable",
after_place_node = function(pos, player)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local id = power.new_id()
meta:set_string("infotext", "Network Controller (owned by "..name..")"
.."\nNetwork ID: "..id)
meta:set_string("network_id", id)
meta:set_string("owner", name)
2019-05-01 13:20:09 +02:00
me.networks[id] = {pos = pos}
2017-07-25 19:47:25 +02:00
-- Trace Network
power.trace(pos)
end,
on_destruct = function(pos, player)
local meta = minetest.get_meta(pos)
local id = meta:get_string("network_id")
me.networks[id] = nil
-- Remove unit from network
2019-05-01 13:20:09 +02:00
--me.network_remove(pos)
2017-07-25 19:47:25 +02:00
-- Trace/clear network
power.trace(pos)
end,
machine = {
type = "transporter",
},
2017-03-02 06:38:53 +01:00
})
-- [register node] Cable
2017-07-25 19:47:25 +02:00
me.register_machine("cable", {
description = "ME Cable",
tiles = {
"cable",
},
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
2017-03-02 06:38:53 +01:00
connect_top = {-0.25, -0.25, -0.25, 0.25, 0.5, 0.25}, -- y+
connect_bottom = {-0.25, -0.5, -0.25, 0.25, 0.25, 0.25}, -- y-
connect_front = {-0.25, -0.25, -0.5, 0.25, 0.25, 0.25}, -- z-
connect_back = {-0.25, -0.25, 0.25, 0.25, 0.25, 0.5 }, -- z+
connect_left = {-0.5, -0.25, -0.25, 0.25, 0.25, 0.25}, -- x-
connect_right = {-0.25, -0.25, -0.25, 0.5, 0.25, 0.25}, -- x+
2017-07-25 19:47:25 +02:00
},
paramtype = "light",
groups = { crumbly = 1, },
status = "unstable",
machine = {
type = "transporter",
},
2017-03-02 02:27:00 +01:00
})