mirror of
https://codeberg.org/Wuzzy/pride_flags.git
synced 2025-03-21 23:42:20 +00:00
Respawn flags on loading chunk, part 2
This commit is contained in:
parent
f4964faaca
commit
ae0929a6dd
1 changed files with 13 additions and 11 deletions
24
init.lua
24
init.lua
|
@ -55,12 +55,6 @@ minetest.register_entity( "pride_flags:wavingflag", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local aflag = active_flags[ self.node_idx ]
|
|
||||||
if aflag then
|
|
||||||
minetest.log("error", "stop_a")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:reset_texture( self.flag_idx )
|
self:reset_texture( self.flag_idx )
|
||||||
|
|
||||||
active_flags[ self.node_idx ] = self.object
|
active_flags[ self.node_idx ] = self.object
|
||||||
|
@ -243,13 +237,14 @@ local function spawn_flag( pos )
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
|
|
||||||
local function spawn_flag_and_set_meta( pos )
|
local function spawn_flag_and_set_texture( pos )
|
||||||
local flag = spawn_flag( pos )
|
local flag = spawn_flag( pos )
|
||||||
if flag and flag:get_luaentity() then
|
if flag and flag:get_luaentity() then
|
||||||
local meta = minetest.get_meta( pos )
|
local meta = minetest.get_meta( pos )
|
||||||
local flag_idx = meta:get_int("flag_idx")
|
local flag_idx = meta:get_int("flag_idx")
|
||||||
flag:get_luaentity():reset_texture( flag_idx )
|
flag:get_luaentity():reset_texture( flag_idx )
|
||||||
end
|
end
|
||||||
|
return flag
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cycle_flag( pos, player, cycle_backwards )
|
local function cycle_flag( pos, player, cycle_backwards )
|
||||||
|
@ -271,7 +266,7 @@ local function cycle_flag( pos, player, cycle_backwards )
|
||||||
local meta = minetest.get_meta( pos )
|
local meta = minetest.get_meta( pos )
|
||||||
meta:set_int("flag_idx", flag_idx)
|
meta:set_int("flag_idx", flag_idx)
|
||||||
else
|
else
|
||||||
spawn_flag_and_set_meta( pos )
|
spawn_flag_and_set_texture( pos )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -328,6 +323,15 @@ minetest.register_node( "pride_flags:upper_mast", {
|
||||||
local aflag = active_flags[ node_idx ]
|
local aflag = active_flags[ node_idx ]
|
||||||
if aflag then
|
if aflag then
|
||||||
local lua = aflag:get_luaentity( )
|
local lua = aflag:get_luaentity( )
|
||||||
|
if not lua then
|
||||||
|
aflag = spawn_flag_and_set_texture( pos )
|
||||||
|
if aflag then
|
||||||
|
lua = aflag:get_luaentity()
|
||||||
|
if not lua then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local flag_pos_idx = lua.node_idx
|
local flag_pos_idx = lua.node_idx
|
||||||
local flag_pos = minetest.get_position_from_hash( flag_pos_idx )
|
local flag_pos = minetest.get_position_from_hash( flag_pos_idx )
|
||||||
flag_pos = get_flag_pos( flag_pos, new_param2 )
|
flag_pos = get_flag_pos( flag_pos, new_param2 )
|
||||||
|
@ -346,10 +350,8 @@ minetest.register_lbm({
|
||||||
local node_idx = minetest.hash_node_position( pos )
|
local node_idx = minetest.hash_node_position( pos )
|
||||||
local aflag = active_flags[ node_idx ]
|
local aflag = active_flags[ node_idx ]
|
||||||
if aflag then
|
if aflag then
|
||||||
minetest.log("error", "stop")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
spawn_flag_and_set_meta( pos )
|
spawn_flag_and_set_texture( pos )
|
||||||
minetest.log("error", "sp:"..minetest.pos_to_string(pos))
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue