tubelib2.init_mem(pos) bugfixes
power_pole with protection wind turbine prototype added
This commit is contained in:
parent
2174916b01
commit
c871a9a2e3
@ -55,7 +55,8 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
|
||||
local function after_place_node(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.running = true
|
||||
mem.capa = 0
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
|
@ -65,7 +65,8 @@ minetest.register_node("techage:sink", {
|
||||
tiles = {'techage_electric_button.png'},
|
||||
|
||||
after_place_node = function(pos)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
M(pos):set_string("infotext", "off")
|
||||
end,
|
||||
|
||||
|
@ -46,7 +46,8 @@ minetest.register_node("techage:source", {
|
||||
'techage_electric_button.png^techage_appl_electronic_fab.png',
|
||||
},
|
||||
after_place_node = function(pos)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
M(pos):set_string("infotext", "off")
|
||||
end,
|
||||
|
||||
|
@ -126,7 +126,8 @@ minetest.register_node("techage:t2_source", {
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State2:node_init(pos, mem, "")
|
||||
mem.state_num = 2
|
||||
on_rightclick(pos)
|
||||
@ -155,6 +156,7 @@ minetest.register_node("techage:t3_source", {
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
after_place_node = function(pos, placer)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State3:node_init(pos, mem, "")
|
||||
mem.state_num = 3
|
||||
@ -184,6 +186,7 @@ minetest.register_node("techage:t4_source", {
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
after_place_node = function(pos, placer)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State4:node_init(pos, mem, "")
|
||||
mem.state_num = 4
|
||||
|
@ -130,7 +130,8 @@ minetest.register_node("techage:ta3_akku", {
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
mem.capa = get_capa(itemstack)
|
||||
on_rightclick(pos)
|
||||
|
@ -245,7 +245,8 @@ minetest.register_node("techage:coalboiler_top", {
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
if node.name == "techage:coalboiler_base" then
|
||||
|
@ -115,7 +115,8 @@ minetest.register_node("techage:generator", {
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local number = techage.add_node(pos, "techage:generator")
|
||||
State:node_init(pos, mem, number)
|
||||
on_rightclick(pos)
|
||||
|
@ -78,7 +78,8 @@ minetest.register_node("techage:ta3_booster", {
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local indir = techage.side_to_indir("R", node.param2)
|
||||
M(pos):set_int("indir", indir)
|
||||
|
5
init.lua
5
init.lua
@ -63,6 +63,7 @@ else
|
||||
dofile(MP.."/power/power_line.lua")
|
||||
dofile(MP.."/power/junctionbox.lua")
|
||||
dofile(MP.."/power/powerswitch.lua")
|
||||
dofile(MP.."/power/protection.lua")
|
||||
|
||||
-- Iron Age
|
||||
dofile(MP.."/iron_age/main.lua")
|
||||
@ -150,7 +151,6 @@ else
|
||||
end
|
||||
dofile(MP.."/nodes/gateblock.lua")
|
||||
dofile(MP.."/nodes/doorblock.lua")
|
||||
dofile(MP.."/nodes/pillar.lua")
|
||||
|
||||
-- Logic
|
||||
dofile(MP.."/logic/lib.lua")
|
||||
@ -178,4 +178,7 @@ else
|
||||
dofile(MP.."/nodes/silicon.lua")
|
||||
dofile(MP.."/solar/minicell.lua")
|
||||
|
||||
-- Wind
|
||||
dofile(MP.."/wind_turbine/rotor.lua")
|
||||
dofile(MP.."/nodes/pillar.lua")
|
||||
end
|
@ -23,12 +23,16 @@ local Cable = tubelib2.Tube:new({
|
||||
max_tube_length = 1000,
|
||||
show_infotext = false,
|
||||
tube_type = "electric_cable",
|
||||
primary_node_names = {"techage:electric_cableS", "techage:electric_cableA", "techage:power_line", "techage:power_lineS", "techage:power_lineA"},
|
||||
primary_node_names = {"techage:electric_cableS", "techage:electric_cableA",
|
||||
"techage:power_line", "techage:power_lineS", "techage:power_lineA", "techage:power_pole2"},
|
||||
secondary_node_names = {},
|
||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||
-- Handle "power line" nodes
|
||||
local name = minetest.get_node(pos).name
|
||||
if name == "techage:power_line" or name == "techage:power_lineS" or name == "techage:power_lineA" then
|
||||
if name == "techage:power_pole2" then
|
||||
M(pos):set_int("tl2_param2", param2)
|
||||
return
|
||||
elseif name == "techage:power_line" or name == "techage:power_lineS" or name == "techage:power_lineA" then
|
||||
minetest.swap_node(pos, {name = "techage:power_line"..tube_type, param2 = param2 % 32})
|
||||
M(pos):set_int("tl2_param2", param2)
|
||||
return
|
||||
|
@ -163,7 +163,7 @@ minetest.register_node("techage:power_lineA", {
|
||||
})
|
||||
|
||||
minetest.register_node("techage:power_pole", {
|
||||
description = S("TA Power Pole"),
|
||||
description = S("TA Power Pole Top 4"),
|
||||
--tiles = {"techage_power_pole.png"},
|
||||
tiles = {
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
@ -185,6 +185,109 @@ minetest.register_node("techage:power_pole", {
|
||||
{ -2/32, -4/32, 12/32, 2/32, 4/32, 16/32},
|
||||
},
|
||||
},
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
if techage.is_protected(pos, placer:get_player_name()) then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
M(pos):set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
can_dig = function(pos, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("owner") == digger:get_player_name() then
|
||||
return true
|
||||
end
|
||||
if minetest.check_player_privs(digger:get_player_name(), "powerline") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:power_pole2", {
|
||||
description = S("TA Power Pole Top 2"),
|
||||
--tiles = {"techage_power_pole.png"},
|
||||
tiles = {
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
"default_wood.png^techage_power_pole.png"
|
||||
},
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -4/32, -16/32, -4/32, 4/32, 16/32, 4/32},
|
||||
{ -1/32, -6/32, -16/32, 1/32, -4/32, 16/32},
|
||||
{ -2/32, -4/32, -16/32, 2/32, 4/32, -12/32},
|
||||
{ -2/32, -4/32, 12/32, 2/32, 4/32, 16/32},
|
||||
},
|
||||
},
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
if techage.is_protected(pos, placer:get_player_name()) then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
if not Cable:after_place_tube(pos, placer, pointed_thing) then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
M(pos):set_string("owner", placer:get_player_name())
|
||||
return false
|
||||
end,
|
||||
can_dig = function(pos, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("owner") == digger:get_player_name() then
|
||||
return true
|
||||
end
|
||||
if minetest.check_player_privs(digger:get_player_name(), "powerline") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
|
||||
oldnode.param2 = oldmetadata.fields.tl2_param2
|
||||
Cable:after_dig_tube(pos, oldnode)
|
||||
end
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:power_pole3", {
|
||||
description = S("TA Power Pole"),
|
||||
--tiles = {"techage_power_pole.png"},
|
||||
tiles = {
|
||||
"default_wood.png",
|
||||
"default_wood.png",
|
||||
"default_wood.png"
|
||||
},
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -4/32, -16/32, -4/32, 4/32, 16/32, 4/32},
|
||||
},
|
||||
},
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
@ -207,19 +310,29 @@ minetest.register_craft({
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:power_pole",
|
||||
output = "techage:power_pole2",
|
||||
recipe = {
|
||||
{"default:stick", "techage:power_lineS", "default:stick"},
|
||||
{"", "default:stick", ""},
|
||||
{"techage:power_lineS", "default:copper_ingot", "techage:power_lineS"},
|
||||
{"default:stick", "techage:power_lineS", "default:stick"},
|
||||
{"", "default:stick", ""},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:power_pole",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"", "techage:power_pole2", ""},
|
||||
{"", "techage:power_pole2", ""},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:power_pole3 4",
|
||||
recipe = {
|
||||
{"", "group:wood", ""},
|
||||
{"", "techage:power_lineS", ""},
|
||||
{"", "group:wood", ""},
|
||||
},
|
||||
})
|
||||
|
||||
if minetest.global_exists("minecart") and minecart.register_protected_node then
|
||||
minecart.register_protected_node("techage:power_line")
|
||||
minecart.register_protected_node("techage:power_lineS")
|
||||
minecart.register_protected_node("techage:power_lineA")
|
||||
minecart.register_protected_node("techage:power_pole")
|
||||
minecart.register_protected_node("default:fence_wood")
|
||||
|
||||
end
|
@ -15,7 +15,6 @@
|
||||
-- for lazy programmers
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
@ -85,7 +84,8 @@ minetest.register_node("techage:ta4_solar_minicell", {
|
||||
local number = techage.add_node(pos, "techage:ta4_solar_minicell")
|
||||
meta:set_string("node_number", number)
|
||||
meta:set_string("infotext", S("TA4 Streetlamp Solar Cell").." "..number)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.capa = 0
|
||||
mem.providing = false
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
|
@ -253,7 +253,8 @@ minetest.register_node("techage:boiler2", {
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
if node.name == "techage:boiler1" then
|
||||
|
@ -30,6 +30,7 @@ end
|
||||
|
||||
-- called with any pipe change
|
||||
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.running = false
|
||||
swap_node(pos, "techage:cylinder")
|
||||
|
@ -131,7 +131,8 @@ minetest.register_node("techage:flywheel", {
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
on_rightclick(pos)
|
||||
end,
|
||||
|
@ -56,7 +56,8 @@ local function on_rightclick(pos, node, clicker)
|
||||
end
|
||||
|
||||
local function after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
power.consumer_start(pos, mem, CYCLE_TIME, PWR_NEEDED)
|
||||
end
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 498 B |
@ -36,7 +36,7 @@ local function read_state(itemstack, user, pointed_thing)
|
||||
local name = minetest.get_biome_name(data.biome)
|
||||
minetest.chat_send_player(user:get_player_name(), S("Biome")..": "..name..", "..S("Position temperature")..": "..math.floor(data.heat).." ")
|
||||
if techage.OceanIdTbl[data.biome] then
|
||||
minetest.chat_send_player(user:get_player_name(), "Suitable for windmills")
|
||||
minetest.chat_send_player(user:get_player_name(), "Suitable for wind turbines")
|
||||
end
|
||||
end
|
||||
local number = techage.get_node_number(pos)
|
||||
@ -76,6 +76,11 @@ local function read_state(itemstack, user, pointed_thing)
|
||||
if power and power ~= "" and power ~= "unsupported" then
|
||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." % ")
|
||||
end
|
||||
local owner = M(pos):get_string("owner") or ""
|
||||
if owner ~= "" then
|
||||
minetest.chat_send_player(user:get_player_name(), S("Node owner")..": "..owner.." ")
|
||||
end
|
||||
minetest.chat_send_player(user:get_player_name(), S("Position")..": "..minetest.pos_to_string(pos).." ")
|
||||
itemstack:add_wear(65636/200)
|
||||
return itemstack
|
||||
end
|
||||
@ -87,6 +92,11 @@ local function read_state(itemstack, user, pointed_thing)
|
||||
minetest.chat_send_player(user:get_player_name(), ndef.description..":"..text)
|
||||
end
|
||||
end
|
||||
local owner = M(pos):get_string("owner") or ""
|
||||
if owner ~= "" then
|
||||
minetest.chat_send_player(user:get_player_name(), S("Node owner")..": "..owner.." ")
|
||||
end
|
||||
minetest.chat_send_player(user:get_player_name(), S("Position")..": "..minetest.pos_to_string(pos).." ")
|
||||
itemstack:add_wear(65636/200)
|
||||
return itemstack
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user