restructured
This commit is contained in:
parent
7bf4898160
commit
9378d4dbd5
@ -8,9 +8,6 @@
|
|||||||
LGPLv2.1+
|
LGPLv2.1+
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
The autocrafter is derived from pipeworks:
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> WTFPL
|
|
||||||
|
|
||||||
All items disappear.
|
All items disappear.
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
@ -19,12 +16,12 @@ minetest.register_node("techage:blackhole", {
|
|||||||
description = "Techage Black Hole",
|
description = "Techage Black Hole",
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
"techage_filling_ta3.png^techage_frame_ta3.png",
|
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||||
"techage_filling_ta3.png^techage_frame_ta3.png",
|
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_blackhole.png",
|
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_blackhole.png",
|
||||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_blackhole.png^techage_appl_inp.png",
|
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_blackhole.png^techage_appl_inp.png",
|
||||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_blackhole.png",
|
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_blackhole.png",
|
||||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_blackhole.png",
|
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_blackhole.png",
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
@ -46,9 +43,9 @@ minetest.register_node("techage:blackhole", {
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:blackhole",
|
output = "techage:blackhole",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:wood", "", "group:wood"},
|
{"group:wood", "", "group:wood"},
|
||||||
{"tubelib:tubeS", "default:coal_lump", ""},
|
{"tubelib:tubeS", "default:coal_lump", ""},
|
||||||
{"group:wood", "", "group:wood"},
|
{"group:wood", "techage:iron_ingot", "group:wood"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
--[[
|
--[[
|
||||||
|
|
||||||
Tube Library
|
TechAge
|
||||||
============
|
=======
|
||||||
|
|
||||||
Copyright (C) 2017-2019 Joachim Stolberg
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
LGPLv2.1+
|
LGPLv2.1+
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
forceload.lua:
|
Forceload block
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ local function remove_list_elem(list, x)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function chat(player, text)
|
local function chat(player, text)
|
||||||
minetest.chat_send_player(player:get_player_name(), "[Tubelib] "..text)
|
minetest.chat_send_player(player:get_player_name(), "[Techage] "..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_node_lvm(pos)
|
local function get_node_lvm(pos)
|
||||||
@ -72,33 +72,33 @@ local function get_node_lvm(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function add_pos(pos, player)
|
local function add_pos(pos, player)
|
||||||
local lPos = minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
local lPos = minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
|
||||||
if not in_list(lPos, pos) and #lPos < tubelib.max_num_forceload_blocks then
|
if not in_list(lPos, pos) and #lPos < techage.max_num_forceload_blocks then
|
||||||
lPos[#lPos+1] = pos
|
lPos[#lPos+1] = pos
|
||||||
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
player:set_attribute("techage_forceload_blocks", minetest.serialize(lPos))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function del_pos(pos, player)
|
local function del_pos(pos, player)
|
||||||
local lPos = minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
local lPos = minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
|
||||||
lPos = remove_list_elem(lPos, pos)
|
lPos = remove_list_elem(lPos, pos)
|
||||||
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
player:set_attribute("techage_forceload_blocks", minetest.serialize(lPos))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_pos_list(player)
|
local function get_pos_list(player)
|
||||||
return minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
return minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_pos_list(player, lPos)
|
local function set_pos_list(player, lPos)
|
||||||
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
player:set_attribute("techage_forceload_blocks", minetest.serialize(lPos))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_data(pos, player)
|
local function get_data(pos, player)
|
||||||
local pos1, pos2 = calc_area(pos)
|
local pos1, pos2 = calc_area(pos)
|
||||||
local num = #minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or 0
|
local num = #minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or 0
|
||||||
local max = tubelib.max_num_forceload_blocks
|
local max = techage.max_num_forceload_blocks
|
||||||
return pos1, pos2, num, max
|
return pos1, pos2, num, max
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -123,14 +123,14 @@ local function formspec(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("tubelib:forceload", {
|
minetest.register_node("techage:forceload", {
|
||||||
description = "Tubelib Forceload Block",
|
description = "Techage Forceload Block",
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
'tubelib_front.png',
|
'techage_filling_ta2.png^techage_frame_ta2_top.png',
|
||||||
'tubelib_front.png',
|
'techage_filling_ta2.png^techage_frame_ta2_top.png',
|
||||||
{
|
{
|
||||||
image = "tubelib_forceload.png",
|
image = "techage_filling_ta2.png^techage_frame_ta2_top.png^techage_appl_forceload.png",
|
||||||
backface_culling = false,
|
backface_culling = false,
|
||||||
animation = {
|
animation = {
|
||||||
type = "vertical_frames",
|
type = "vertical_frames",
|
||||||
@ -148,7 +148,7 @@ minetest.register_node("tubelib:forceload", {
|
|||||||
M(pos):set_string("infotext", "Area "..S(pos1).." to "..S(pos2).." loaded!\n"..
|
M(pos):set_string("infotext", "Area "..S(pos1).." to "..S(pos2).." loaded!\n"..
|
||||||
"Punch the block to make the area visible.")
|
"Punch the block to make the area visible.")
|
||||||
chat(placer, "Area ("..num.."/"..max..") "..S(pos1).." to "..S(pos2).." loaded!")
|
chat(placer, "Area ("..num.."/"..max..") "..S(pos1).." to "..S(pos2).." loaded!")
|
||||||
tubelib.mark_region(placer:get_player_name(), pos1, pos2)
|
techage.mark_region(placer:get_player_name(), pos1, pos2)
|
||||||
M(pos):set_string("owner", placer:get_player_name())
|
M(pos):set_string("owner", placer:get_player_name())
|
||||||
else
|
else
|
||||||
chat(placer, "Area already loaded or max. number of Forceload Blocks reached!")
|
chat(placer, "Area already loaded or max. number of Forceload Blocks reached!")
|
||||||
@ -163,38 +163,38 @@ minetest.register_node("tubelib:forceload", {
|
|||||||
del_pos(pos, player)
|
del_pos(pos, player)
|
||||||
end
|
end
|
||||||
minetest.forceload_free_block(pos, true)
|
minetest.forceload_free_block(pos, true)
|
||||||
tubelib.unmark_region(oldmetadata.fields.owner)
|
techage.unmark_region(oldmetadata.fields.owner)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
if M(pos):get_string("owner") == clicker:get_player_name() or
|
if M(pos):get_string("owner") == clicker:get_player_name() or
|
||||||
minetest.check_player_privs(clicker:get_player_name(), "server") then
|
minetest.check_player_privs(clicker:get_player_name(), "server") then
|
||||||
local s = formspec(clicker)
|
local s = formspec(clicker)
|
||||||
minetest.show_formspec(clicker:get_player_name(), "tubelib:forceload", s)
|
minetest.show_formspec(clicker:get_player_name(), "techage:forceload", s)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher, pointed_thing)
|
on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
local pos1, pos2 = calc_area(pos)
|
local pos1, pos2 = calc_area(pos)
|
||||||
tubelib.switch_region(puncher:get_player_name(), pos1, pos2)
|
techage.switch_region(puncher:get_player_name(), pos1, pos2)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {choppy=2, cracky=2, crumbly=2,
|
groups = {choppy=2, cracky=2, crumbly=2,
|
||||||
not_in_creative_inventory = tubelib.max_num_forceload_blocks == 0 and 1 or 0},
|
not_in_creative_inventory = techage.max_num_forceload_blocks == 0 and 1 or 0},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
if tubelib.max_num_forceload_blocks > 0 then
|
if techage.max_num_forceload_blocks > 0 then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "tubelib:forceload",
|
output = "techage:forceload",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:wood", "", "group:wood"},
|
{"group:wood", "", "group:wood"},
|
||||||
{"", "basic_materials:energy_crystal_simple", ""},
|
{"", "basic_materials:energy_crystal_simple", ""},
|
||||||
{"group:wood", "tubelib:wlanchip", "group:wood"},
|
{"group:wood", "techage:iron_ingot", "group:wood"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -203,7 +203,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
local lPos = {}
|
local lPos = {}
|
||||||
for _,pos in ipairs(get_pos_list(player)) do
|
for _,pos in ipairs(get_pos_list(player)) do
|
||||||
local node = get_node_lvm(pos)
|
local node = get_node_lvm(pos)
|
||||||
if node.name == "tubelib:forceload" then
|
if node.name == "techage:forceload" then
|
||||||
minetest.forceload_block(pos, true)
|
minetest.forceload_block(pos, true)
|
||||||
lPos[#lPos+1] = pos
|
lPos[#lPos+1] = pos
|
||||||
end
|
end
|
||||||
|
@ -1,93 +1,92 @@
|
|||||||
--[[
|
--[[
|
||||||
|
|
||||||
Tube Library
|
TechAge
|
||||||
============
|
=======
|
||||||
|
|
||||||
Copyright (C) 2019 Joachim Stolberg
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
Code derived from wordedit (sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote))
|
|
||||||
|
LGPLv2.1+
|
||||||
LGPLv2.1+
|
See LICENSE.txt for more information
|
||||||
See LICENSE.txt for more information
|
|
||||||
|
mark.lua:
|
||||||
mark.lua:
|
|
||||||
|
]]--
|
||||||
]]--
|
|
||||||
|
local marker_region = {}
|
||||||
local marker_region = {}
|
|
||||||
|
function techage.unmark_region(name)
|
||||||
function tubelib.unmark_region(name)
|
if marker_region[name] ~= nil then --marker already exists
|
||||||
if marker_region[name] ~= nil then --marker already exists
|
--wip: make the area stay loaded somehow
|
||||||
--wip: make the area stay loaded somehow
|
for _, entity in ipairs(marker_region[name]) do
|
||||||
for _, entity in ipairs(marker_region[name]) do
|
entity:remove()
|
||||||
entity:remove()
|
end
|
||||||
end
|
marker_region[name] = nil
|
||||||
marker_region[name] = nil
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
function techage.mark_region(name, pos1, pos2)
|
||||||
function tubelib.mark_region(name, pos1, pos2)
|
|
||||||
|
techage.unmark_region(name)
|
||||||
tubelib.unmark_region(name)
|
|
||||||
|
local thickness = 0.2
|
||||||
local thickness = 0.2
|
local sizex, sizey, sizez = (1 + pos2.x - pos1.x) / 2, (1 + pos2.y - pos1.y) / 2, (1 + pos2.z - pos1.z) / 2
|
||||||
local sizex, sizey, sizez = (1 + pos2.x - pos1.x) / 2, (1 + pos2.y - pos1.y) / 2, (1 + pos2.z - pos1.z) / 2
|
local markers = {}
|
||||||
local markers = {}
|
|
||||||
|
--XY plane markers
|
||||||
--XY plane markers
|
for _, z in ipairs({pos1.z - 0.5, pos2.z + 0.5}) do
|
||||||
for _, z in ipairs({pos1.z - 0.5, pos2.z + 0.5}) do
|
local marker = minetest.add_entity({x=pos1.x + sizex - 0.5, y=pos1.y + sizey - 0.5, z=z}, "techage:region_cube")
|
||||||
local marker = minetest.add_entity({x=pos1.x + sizex - 0.5, y=pos1.y + sizey - 0.5, z=z}, "tubelib:region_cube")
|
if marker ~= nil then
|
||||||
if marker ~= nil then
|
marker:set_properties({
|
||||||
marker:set_properties({
|
visual_size={x=sizex * 2, y=sizey * 2},
|
||||||
visual_size={x=sizex * 2, y=sizey * 2},
|
collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness},
|
||||||
collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness},
|
})
|
||||||
})
|
marker:get_luaentity().player_name = name
|
||||||
marker:get_luaentity().player_name = name
|
table.insert(markers, marker)
|
||||||
table.insert(markers, marker)
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
--YZ plane markers
|
||||||
--YZ plane markers
|
for _, x in ipairs({pos1.x - 0.5, pos2.x + 0.5}) do
|
||||||
for _, x in ipairs({pos1.x - 0.5, pos2.x + 0.5}) do
|
local marker = minetest.add_entity({x=x, y=pos1.y + sizey - 0.5, z=pos1.z + sizez - 0.5}, "techage:region_cube")
|
||||||
local marker = minetest.add_entity({x=x, y=pos1.y + sizey - 0.5, z=pos1.z + sizez - 0.5}, "tubelib:region_cube")
|
if marker ~= nil then
|
||||||
if marker ~= nil then
|
marker:set_properties({
|
||||||
marker:set_properties({
|
visual_size={x=sizez * 2, y=sizey * 2},
|
||||||
visual_size={x=sizez * 2, y=sizey * 2},
|
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
|
||||||
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
|
})
|
||||||
})
|
marker:setyaw(math.pi / 2)
|
||||||
marker:setyaw(math.pi / 2)
|
marker:get_luaentity().player_name = name
|
||||||
marker:get_luaentity().player_name = name
|
table.insert(markers, marker)
|
||||||
table.insert(markers, marker)
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
marker_region[name] = markers
|
||||||
marker_region[name] = markers
|
end
|
||||||
end
|
|
||||||
|
function techage.switch_region(name, pos1, pos2)
|
||||||
function tubelib.switch_region(name, pos1, pos2)
|
if marker_region[name] ~= nil then --marker already exists
|
||||||
if marker_region[name] ~= nil then --marker already exists
|
techage.unmark_region(name)
|
||||||
tubelib.unmark_region(name)
|
else
|
||||||
else
|
techage.mark_region(name, pos1, pos2)
|
||||||
tubelib.mark_region(name, pos1, pos2)
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
minetest.register_entity(":techage:region_cube", {
|
||||||
minetest.register_entity(":tubelib:region_cube", {
|
initial_properties = {
|
||||||
initial_properties = {
|
visual = "upright_sprite",
|
||||||
visual = "upright_sprite",
|
visual_size = {x=1.1, y=1.1},
|
||||||
visual_size = {x=1.1, y=1.1},
|
textures = {"techage_cube_mark.png"},
|
||||||
textures = {"tubelib_cube.png"},
|
use_texture_alpha = true,
|
||||||
use_texture_alpha = true,
|
visual_size = {x=10, y=10},
|
||||||
visual_size = {x=10, y=10},
|
physical = false,
|
||||||
physical = false,
|
},
|
||||||
},
|
on_step = function(self, dtime)
|
||||||
on_step = function(self, dtime)
|
if marker_region[self.player_name] == nil then
|
||||||
if marker_region[self.player_name] == nil then
|
self.object:remove()
|
||||||
self.object:remove()
|
return
|
||||||
return
|
end
|
||||||
end
|
end,
|
||||||
end,
|
on_punch = function(self, hitter)
|
||||||
on_punch = function(self, hitter)
|
techage.unmark_region(self.player_name)
|
||||||
tubelib.unmark_region(self.player_name)
|
end,
|
||||||
end,
|
})
|
||||||
})
|
|
||||||
|
|
||||||
|
2
init.lua
2
init.lua
@ -75,6 +75,8 @@ else
|
|||||||
dofile(MP.."/basic_machines/gravelsieve.lua")
|
dofile(MP.."/basic_machines/gravelsieve.lua")
|
||||||
dofile(MP.."/basic_machines/chest.lua")
|
dofile(MP.."/basic_machines/chest.lua")
|
||||||
dofile(MP.."/basic_machines/autocrafter.lua")
|
dofile(MP.."/basic_machines/autocrafter.lua")
|
||||||
|
dofile(MP.."/basic_machines/mark.lua")
|
||||||
|
dofile(MP.."/basic_machines/forceload.lua")
|
||||||
if techage.basalt_stone_enabled then
|
if techage.basalt_stone_enabled then
|
||||||
dofile(MP.."/basic_machines/basalt.lua")
|
dofile(MP.."/basic_machines/basalt.lua")
|
||||||
end
|
end
|
||||||
|
BIN
textures/techage_appl_forceload.png
Normal file
BIN
textures/techage_appl_forceload.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/techage_cube_mark.png
Normal file
BIN
textures/techage_cube_mark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 305 B |
Loading…
Reference in New Issue
Block a user