initial commit
parent
9da4891df7
commit
00be61a355
|
@ -0,0 +1 @@
|
|||
A node that keeps the map block it is in loaded when players are not near by.
|
|
@ -0,0 +1,74 @@
|
|||
|
||||
-- display entity shown when loader node is punched
|
||||
minetest.register_entity("simple_anchor:display", {
|
||||
physical = false,
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
visual = "wielditem",
|
||||
-- wielditem seems to be scaled to 1.5 times original node size
|
||||
visual_size = {x = 1.0 / 1.5, y = 1.0 / 1.5},
|
||||
textures = {"simple_anchor:display_node"},
|
||||
timer = 0,
|
||||
on_step = function(self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
-- remove after 8 seconds
|
||||
if self.timer > 8 then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Display-zone node, Do NOT place the display as a node,
|
||||
-- it is made to be used as an entity (see above)
|
||||
local x = 8
|
||||
minetest.register_node("simple_anchor:display_node", {
|
||||
tiles = {"loader_display.png"},
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- sides
|
||||
{-(x+.55), -(x+.55), -(x+.55), -(x+.45), (x+.55), (x+.55)},
|
||||
{-(x+.55), -(x+.55), (x+.45), (x+.55), (x+.55), (x+.55)},
|
||||
{(x+.45), -(x+.55), -(x+.55), (x+.55), (x+.55), (x+.55)},
|
||||
{-(x+.55), -(x+.55), -(x+.55), (x+.55), (x+.55), -(x+.45)},
|
||||
-- top
|
||||
{-(x+.55), (x+.45), -(x+.55), (x+.55), (x+.55), (x+.55)},
|
||||
-- bottom
|
||||
{-(x+.55), -(x+.55), -(x+.55), (x+.55), -(x+.45), (x+.55)},
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||
drop = "",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("simple_anchor:loader_block", {
|
||||
description = "forceload anchor",
|
||||
tiles = {"loader_block.png"},
|
||||
groups = {dig_immediate=2},
|
||||
light_source = 4,
|
||||
on_construct = function (pos)
|
||||
if minetest.forceload_block(pos) then
|
||||
minetest.debug("forceload block ".. minetest.pos_to_string(pos))
|
||||
local meta = minetest.get_meta(pos)
|
||||
local vm = minetest.get_voxel_manip(pos, pos)
|
||||
local pmin, pmax = vm:get_emerged_area()
|
||||
local epos = vector.divide(vector.add(pmin,pmax),2)
|
||||
meta:set_string("epos",minetest.pos_to_string(epos))
|
||||
else
|
||||
minetest.debug("failed forceload block ".. minetest.pos_to_string(pos))
|
||||
end
|
||||
end,
|
||||
on_destruct = function (pos)
|
||||
minetest.forceload_free_block(pos)
|
||||
minetest.debug("unforceloaded block ".. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_punch = function (pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local epos = minetest.string_to_pos(meta:get_string("epos"))
|
||||
minetest.add_entity(epos, "simple_anchor:display")
|
||||
end,
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 zing269
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
Binary file not shown.
After Width: | Height: | Size: 503 KiB |
Binary file not shown.
After Width: | Height: | Size: 366 KiB |
Loading…
Reference in New Issue