mirror of
https://codeberg.org/Wuzzy/pride_flags.git
synced 2025-03-15 21:01:22 +00:00
Add screwdriver support
This commit is contained in:
parent
a729d0ce3b
commit
52097be084
2 changed files with 34 additions and 8 deletions
40
init.lua
40
init.lua
|
@ -144,8 +144,29 @@ minetest.register_node( "pride_flags:lower_mast", {
|
|||
type = "fixed",
|
||||
fixed = { { -3/32, -1/2, -3/32, 3/32, 1/2, 3/32 } },
|
||||
},
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
if mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
end,
|
||||
} )
|
||||
|
||||
local function rotate_flag_by_param2( flag, param2 )
|
||||
local facedir_to_yaw = {
|
||||
[0] = rad_90,
|
||||
[1] = 0,
|
||||
[2] = -rad_90,
|
||||
[3] = rad_180,
|
||||
}
|
||||
local baseyaw = facedir_to_yaw[ param2 ]
|
||||
if not baseyaw then
|
||||
minetest.log("warning", "[pride_flags] Unsupported flag pole node param2: "..tostring(param2))
|
||||
return
|
||||
end
|
||||
flag:set_yaw( baseyaw - rad_180 )
|
||||
end
|
||||
|
||||
local function spawn_flag( pos )
|
||||
local node_idx = minetest.hash_node_position( pos )
|
||||
local param2 = minetest.get_node( pos ).param2
|
||||
|
@ -156,17 +177,11 @@ local function spawn_flag( pos )
|
|||
[3] = { x = 0.1, y = 0.6, z = 0 },
|
||||
}
|
||||
|
||||
local facedir_to_yaw = {
|
||||
[0] = rad_90,
|
||||
[1] = 0,
|
||||
[2] = -rad_90,
|
||||
[3] = rad_180,
|
||||
}
|
||||
local flag_pos = vector.add( pos, vector.multiply( facedir_to_pos[ param2 ], 1 ) )
|
||||
local obj = minetest.add_entity( flag_pos, "pride_flags:wavingflag" )
|
||||
|
||||
obj:get_luaentity( ).node_idx = node_idx
|
||||
obj:set_yaw( facedir_to_yaw[ param2 ] - rad_180 )
|
||||
rotate_flag_by_param2( obj, param2 )
|
||||
|
||||
active_flags[ node_idx ] = obj
|
||||
return obj
|
||||
|
@ -220,4 +235,15 @@ minetest.register_node( "pride_flags:upper_mast", {
|
|||
active_flags[ node_idx ]:remove( )
|
||||
end
|
||||
end,
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
if mode == screwdriver.ROTATE_AXIS then
|
||||
return false
|
||||
end
|
||||
local node_idx = minetest.hash_node_position( pos )
|
||||
local aflag = active_flags[ node_idx ]
|
||||
if aflag then
|
||||
rotate_flag_by_param2( aflag, new_param2 )
|
||||
end
|
||||
end,
|
||||
} )
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -2,5 +2,5 @@ name = pride_flags
|
|||
title = Pride Flags
|
||||
author = sorcerykid
|
||||
license = LGPL-3.0
|
||||
optional_depends = default
|
||||
optional_depends = default, screwdriver
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue