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