1
0
mirror of https://github.com/mt-mods/signs_lib.git synced 2025-06-28 13:56:06 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
de69b246ec fix wrong priv 2019-09-13 17:12:40 -04:00
e2d522373d add chat command to sweep-away
and regenerate all sign entities in loaded map
(uses LBM to log all loaded blocks,
but only those with nodes in "group:sign").
2019-09-13 16:51:51 -04:00
d262f95744 fix bad material order in facedir-onpole model 2019-09-12 12:01:51 -04:00
3 changed files with 152 additions and 92 deletions

72
api.lua
View File

@ -18,8 +18,8 @@ signs_lib.standard_xoffs = 4
signs_lib.standard_yoffs = 2
signs_lib.standard_cpl = 35
signs_lib.standard_wood_groups = {choppy = 2, flammable = 2, oddly_breakable_by_hand = 3}
signs_lib.standard_steel_groups = {cracky = 2, oddly_breakable_by_hand = 3}
signs_lib.standard_wood_groups = {sign = 1, choppy = 2, flammable = 2, oddly_breakable_by_hand = 3}
signs_lib.standard_steel_groups = {sign = 1, cracky = 2, oddly_breakable_by_hand = 3}
signs_lib.standard_yaw = {
0,
@ -694,3 +694,71 @@ minetest.register_lbm({
end
end
})
signs_lib.block_list = {}
signs_lib.totalblocks = 0
-- Maintain a list of currently-loaded blocks
minetest.register_lbm({
nodenames = {"group:sign"},
name = "signs_lib:update_block_list",
label = "Update list of loaded blocks, log only those with signs",
run_at_every_load = true,
action = function(pos, node)
-- yeah, yeah... I know I'm hashing a block pos, but it's still just a set of coords
local hash = minetest.hash_node_position(vector.floor(vector.divide(pos, core.MAP_BLOCKSIZE)))
if not signs_lib.block_list[hash] then
signs_lib.block_list[hash] = true
signs_lib.totalblocks = signs_lib.totalblocks + 1
end
end
})
minetest.register_chatcommand("regen_signs", {
params = "",
privs = {server = true},
description = "Skims through all currently-loaded sign-bearing mapblocks, clears away any entities within each sign's node space, and regenerates their text entities, if any.",
func = function(player_name, params)
local allsigns = {}
local totalsigns = 0
for b in pairs(signs_lib.block_list) do
local blockpos = minetest.get_position_from_hash(b)
local pos1 = vector.multiply(blockpos, core.MAP_BLOCKSIZE)
local pos2 = vector.add(pos1, core.MAP_BLOCKSIZE - 1)
if minetest.get_node_or_nil(vector.add(pos1, core.MAP_BLOCKSIZE/2)) then
local signs_in_block = minetest.find_nodes_in_area(pos1, pos2, {"group:sign"})
allsigns[#allsigns + 1] = signs_in_block
totalsigns = totalsigns + #signs_in_block
else
signs_lib.block_list[b] = nil -- if the block is no longer loaded, remove it from the table
signs_lib.totalblocks = signs_lib.totalblocks - 1
end
end
if signs_lib.totalblocks < 0 then signs_lib.totalblocks = 0 end
if totalsigns == 0 then
minetest.chat_send_player(player_name, "There are no signs in the currently-loaded terrain.")
signs_lib.block_list = {}
return
end
minetest.chat_send_player(player_name, "Found a total of "..totalsigns.." sign nodes across "..signs_lib.totalblocks.." blocks.")
minetest.chat_send_player(player_name, "Regenerating sign entities...")
for _, b in pairs(allsigns) do
for _, pos in ipairs(b) do
local objects = minetest.get_objects_inside_radius(pos, 0.5)
if #objects > 0 then
for _, v in ipairs(objects) do
v:remove()
end
end
local node = minetest.get_node(pos)
local def = minetest.registered_items[node.name]
if def and def.entity_info then
signs_lib.update_sign(pos)
end
end
end
minetest.chat_send_player(player_name, "Finished.")
end
})

View File

@ -1,6 +1,6 @@
# Blender v2.79 (sub 0) OBJ File: 'basic_signs wooden wall sign.blend'
# Blender v2.79 (sub 0) OBJ File: 'basic_signs wooden sign.blend'
# www.blender.org
o Cube.008_Cube
o sign_(3)_Cube
v 0.437500 -0.312500 0.500000
v 0.437500 -0.312500 0.437500
v 0.437500 0.312500 0.500000
@ -41,11 +41,11 @@ vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -1.0000 0.0000 0.0000
g Cube.008_Cube_front-back
g sign_(3)_Cube_front-back
s off
f 8/1/1 4/2/1 2/3/1 6/4/1
f 3/5/2 7/6/2 5/7/2 1/8/2
g Cube.008_Cube_edges
g sign_(3)_Cube_edges
f 13/9/3 14/10/3 10/11/3 9/12/3
f 11/13/4 12/14/4 16/15/4 15/16/4
f 11/13/5 9/17/5 10/18/5 12/14/5

View File

@ -1,6 +1,22 @@
# Blender v2.79 (sub 0) OBJ File: 'basic_signs wooden wall sign.blend'
# Blender v2.79 (sub 0) OBJ File: 'basic_signs wooden sign.blend'
# www.blender.org
o Cube.009_Cube.001
o sign_on_pole.001_Cube.002
v 0.437500 -0.312500 0.812500
v 0.437500 -0.312500 0.750000
v 0.437500 0.312500 0.812500
v 0.437500 0.312500 0.750000
v -0.437500 -0.312500 0.812500
v -0.437500 -0.312500 0.750000
v -0.437500 0.312500 0.812500
v -0.437500 0.312500 0.750000
v 0.437500 -0.312500 0.812500
v 0.437500 -0.312500 0.750000
v 0.437500 0.312500 0.812500
v 0.437500 0.312500 0.750000
v -0.437500 -0.312500 0.812500
v -0.437500 -0.312500 0.750000
v -0.437500 0.312500 0.812500
v -0.437500 0.312500 0.750000
v -0.125000 -0.187500 0.812500
v -0.125000 -0.187500 0.875000
v -0.125000 0.187500 0.812500
@ -57,6 +73,24 @@ v -0.164063 0.125000 1.125000
v 0.164062 0.125000 1.125000
v -0.164063 0.187500 1.125000
v 0.164062 0.187500 1.125000
vt 0.468750 0.812500
vt 0.031250 0.812500
vt 0.031250 0.187500
vt 0.468750 0.187500
vt 0.531250 0.812500
vt 0.968750 0.812500
vt 0.968750 0.187500
vt 0.531250 0.187500
vt 0.234375 0.000000
vt 0.234375 1.000000
vt 0.015625 1.000000
vt 0.015625 -0.000000
vt 0.609375 -0.000000
vt 0.609375 1.000000
vt 0.390625 1.000000
vt 0.390625 -0.000000
vt 0.765625 0.000000
vt 0.765625 1.000000
vt 0.843750 0.507812
vt 0.703125 0.507812
vt 0.703125 0.093750
@ -161,94 +195,52 @@ vt 0.453125 0.640625
vt 0.453125 0.593750
vt 0.312500 0.593750
vt 0.312500 0.640625
vn -1.0000 0.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 -0.0000 1.0000
vn 0.0000 0.0000 -1.0000
g Cube.009_Cube.001_pole_mount
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 6/5/2 5/6/2 8/7/2 7/8/2
f 4/3/3 8/7/3 5/9/3 3/10/3
f 1/11/4 6/12/4 7/8/4 2/2/4
f 2/2/5 7/8/5 8/7/5 4/3/5
f 9/13/2 10/14/2 12/15/2 11/16/2
f 11/17/3 12/18/3 16/19/3 15/20/3
f 15/21/1 16/22/1 14/23/1 13/24/1
f 13/24/4 14/23/4 10/25/4 9/26/4
f 17/27/2 18/28/2 20/29/2 19/30/2
f 19/31/3 20/32/3 24/33/3 23/34/3
f 23/35/1 24/36/1 22/37/1 21/38/1
f 21/38/4 22/37/4 18/39/4 17/40/4
f 25/41/2 26/42/2 28/43/2 27/44/2
f 27/45/3 28/46/3 32/47/3 31/48/3
f 31/49/1 32/50/1 30/51/1 29/52/1
f 29/52/4 30/51/4 26/53/4 25/54/4
f 33/55/2 34/56/2 36/57/2 35/58/2
f 35/59/3 36/60/3 40/61/3 39/62/3
f 39/63/1 40/64/1 38/65/1 37/66/1
f 37/66/4 38/65/4 34/67/4 33/68/4
f 41/69/5 42/70/5 44/71/5 43/72/5
f 43/73/3 44/74/3 48/75/3 47/76/3
f 47/76/6 48/75/6 46/77/6 45/78/6
f 45/78/4 46/77/4 42/70/4 41/69/4
f 43/79/1 47/80/1 45/81/1 41/82/1
f 48/83/2 44/84/2 42/85/2 46/86/2
f 49/87/5 50/88/5 52/89/5 51/90/5
f 51/91/3 52/92/3 56/93/3 55/94/3
f 55/94/6 56/93/6 54/95/6 53/96/6
f 53/96/4 54/95/4 50/88/4 49/87/4
f 51/97/1 55/98/1 53/99/1 49/100/1
f 56/101/2 52/102/2 50/103/2 54/104/2
o Cube.004_Cube
v 0.437500 -0.312500 0.812500
v 0.437500 -0.312500 0.750000
v 0.437500 0.312500 0.812500
v 0.437500 0.312500 0.750000
v -0.437500 -0.312500 0.812500
v -0.437500 -0.312500 0.750000
v -0.437500 0.312500 0.812500
v -0.437500 0.312500 0.750000
v 0.437500 -0.312500 0.812500
v 0.437500 -0.312500 0.750000
v 0.437500 0.312500 0.812500
v 0.437500 0.312500 0.750000
v -0.437500 -0.312500 0.812500
v -0.437500 -0.312500 0.750000
v -0.437500 0.312500 0.812500
v -0.437500 0.312500 0.750000
vt 0.468750 0.812500
vt 0.031250 0.812500
vt 0.031250 0.187500
vt 0.468750 0.187500
vt 0.531250 0.812500
vt 0.968750 0.812500
vt 0.968750 0.187500
vt 0.531250 0.187500
vt 0.234375 0.000000
vt 0.234375 1.000000
vt 0.015625 1.000000
vt 0.015625 -0.000000
vt 0.609375 -0.000000
vt 0.609375 1.000000
vt 0.390625 1.000000
vt 0.390625 -0.000000
vt 0.765625 0.000000
vt 0.765625 1.000000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -1.0000 0.0000 0.0000
g Cube.004_Cube_front-back
g sign_on_pole.001_Cube.002_front-back
s off
f 64/105/7 60/106/7 58/107/7 62/108/7
f 59/109/8 63/110/8 61/111/8 57/112/8
g Cube.004_Cube_edges
f 69/113/9 70/114/9 66/115/9 65/116/9
f 67/117/10 68/118/10 72/119/10 71/120/10
f 67/117/11 65/121/11 66/122/11 68/118/11
f 69/113/12 71/120/12 72/119/12 70/114/12
f 8/1/1 4/2/1 2/3/1 6/4/1
f 3/5/2 7/6/2 5/7/2 1/8/2
g sign_on_pole.001_Cube.002_edges
f 13/9/3 14/10/3 10/11/3 9/12/3
f 11/13/4 12/14/4 16/15/4 15/16/4
f 11/13/5 9/17/5 10/18/5 12/14/5
f 13/9/6 15/16/6 16/15/6 14/10/6
g sign_on_pole.001_Cube.002_pole_mount
f 17/19/6 18/20/6 20/21/6 19/22/6
f 22/23/5 21/24/5 24/25/5 23/26/5
f 20/21/4 24/25/4 21/27/4 19/28/4
f 17/29/3 22/30/3 23/26/3 18/20/3
f 18/20/2 23/26/2 24/25/2 20/21/2
f 25/31/5 26/32/5 28/33/5 27/34/5
f 27/35/4 28/36/4 32/37/4 31/38/4
f 31/39/6 32/40/6 30/41/6 29/42/6
f 29/42/3 30/41/3 26/43/3 25/44/3
f 33/45/5 34/46/5 36/47/5 35/48/5
f 35/49/4 36/50/4 40/51/4 39/52/4
f 39/53/6 40/54/6 38/55/6 37/56/6
f 37/56/3 38/55/3 34/57/3 33/58/3
f 41/59/5 42/60/5 44/61/5 43/62/5
f 43/63/4 44/64/4 48/65/4 47/66/4
f 47/67/6 48/68/6 46/69/6 45/70/6
f 45/70/3 46/69/3 42/71/3 41/72/3
f 49/73/5 50/74/5 52/75/5 51/76/5
f 51/77/4 52/78/4 56/79/4 55/80/4
f 55/81/6 56/82/6 54/83/6 53/84/6
f 53/84/3 54/83/3 50/85/3 49/86/3
f 57/87/2 58/88/2 60/89/2 59/90/2
f 59/91/4 60/92/4 64/93/4 63/94/4
f 63/94/1 64/93/1 62/95/1 61/96/1
f 61/96/3 62/95/3 58/88/3 57/87/3
f 59/97/6 63/98/6 61/99/6 57/100/6
f 64/101/5 60/102/5 58/103/5 62/104/5
f 65/105/2 66/106/2 68/107/2 67/108/2
f 67/109/4 68/110/4 72/111/4 71/112/4
f 71/112/1 72/111/1 70/113/1 69/114/1
f 69/114/3 70/113/3 66/106/3 65/105/3
f 67/115/6 71/116/6 69/117/6 65/118/6
f 72/119/5 68/120/5 66/121/5 70/122/5