initial commit

master
zing269 2018-03-18 13:19:23 -04:00 committed by GitHub
parent 9da4891df7
commit 00be61a355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 0 deletions

1
description.txt Normal file
View File

@ -0,0 +1 @@
A node that keeps the map block it is in loaded when players are not near by.

74
init.lua Normal file
View File

@ -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,
});

21
license.txt Normal file
View File

@ -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.

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = simple_anchor

BIN
simple_anchor_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 KiB

BIN
simple_anchor_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB